From 73aa1e78076ddf9c4d8dc0c581b9d4cdf2b9b86c Mon Sep 17 00:00:00 2001 From: Jakub Zawadzki Date: Sat, 27 Jul 2013 19:14:34 +0000 Subject: [PATCH] Support drange for functions last think from bug #8979 + fix semcheck.c:875: warning: signed and unsigned type in conditional expression svn path=/trunk/; revision=50951 --- epan/dfilter/grammar.lemon | 4 ++-- epan/dfilter/semcheck.c | 17 ++++++++++++++--- 2 files changed, 16 insertions(+), 5 deletions(-) diff --git a/epan/dfilter/grammar.lemon b/epan/dfilter/grammar.lemon index 46c3d3ae7a..88c59b6347 100644 --- a/epan/dfilter/grammar.lemon +++ b/epan/dfilter/grammar.lemon @@ -165,10 +165,10 @@ entity(E) ::= range(R). { E = R; } /* Ranges */ -range(R) ::= FIELD(F) LBRACKET drnode_list(L) RBRACKET. +range(R) ::= entity(E) LBRACKET drnode_list(L) RBRACKET. { R = stnode_new(STTYPE_RANGE, NULL); - sttype_range_set(R, F, L); + sttype_range_set(R, E, L); /* Delete the list, but not the drange_nodes that * the list contains. */ diff --git a/epan/dfilter/semcheck.c b/epan/dfilter/semcheck.c index 944a7bfa32..5f061a67a9 100644 --- a/epan/dfilter/semcheck.c +++ b/epan/dfilter/semcheck.c @@ -850,7 +850,6 @@ check_relation_LHS_RANGE(const char *relation_string, FtypeCanFunc can_func _U_, sttype_id_t type2; stnode_t *entity1; header_field_info *hfinfo1, *hfinfo2; - df_func_def_t *funcdef; ftenum_t ftype1, ftype2; fvalue_t *fvalue; char *s; @@ -870,9 +869,21 @@ check_relation_LHS_RANGE(const char *relation_string, FtypeCanFunc can_func _U_, hfinfo1->abbrev, ftype_pretty_name(ftype1)); THROW(TypeError); } + } else if (entity1 && stnode_type_id(entity1) == STTYPE_FUNCTION) { + df_func_def_t *funcdef = sttype_function_funcdef(entity1); + ftype1 = funcdef->retval_ftype; + + if (!ftype_can_slice(ftype1)) { + dfilter_fail("Return value of function \"%s\" is a %s and cannot be converted into a sequence of bytes.", + funcdef->name, ftype_pretty_name(ftype1)); + THROW(TypeError); + } + + check_function(entity1); + } else { dfilter_fail("Range is not supported, details: " G_STRLOC " entity: %p of type %d", - entity1, entity1 ? stnode_type_id(entity1) : -1); + entity1, entity1 ? (int) stnode_type_id(entity1) : -1); THROW(TypeError); } @@ -963,7 +974,7 @@ check_relation_LHS_RANGE(const char *relation_string, FtypeCanFunc can_func _U_, check_drange_sanity(st_arg2); } else if (type2 == STTYPE_FUNCTION) { - funcdef = sttype_function_funcdef(st_arg2); + df_func_def_t *funcdef = sttype_function_funcdef(st_arg2); ftype2 = funcdef->retval_ftype; if (!is_bytes_type(ftype2)) {