diff options
author | João Valverde <j@v6e.pt> | 2021-10-27 21:56:03 +0100 |
---|---|---|
committer | João Valverde <j@v6e.pt> | 2021-11-07 22:44:59 +0000 |
commit | 69c850df51db8b755c7e728e81165806b682ec17 (patch) | |
tree | 9ea844029a5069f5c57b9d55db29a481f3d909fa /epan | |
parent | e9f2153eed8703bb58bd52b73cd59bea27c9de2e (diff) |
ftypes: Simplify fvalue_can_*() interface
If an ftype can participate in equala assume it can also participate in
not equals. Use fvalue_can_eq() instead of fvalue_can_ne().
If it can participate in one order comparison it can participate in all.
Replace any comparison with fvalue_can_cmp().
Diffstat (limited to 'epan')
-rw-r--r-- | epan/dfilter/semcheck.c | 22 | ||||
-rw-r--r-- | epan/ftypes/ftypes.c | 38 | ||||
-rw-r--r-- | epan/ftypes/ftypes.h | 18 |
3 files changed, 12 insertions, 66 deletions
diff --git a/epan/dfilter/semcheck.c b/epan/dfilter/semcheck.c index c0eeb976ab..6f632a55ab 100644 --- a/epan/dfilter/semcheck.c +++ b/epan/dfilter/semcheck.c @@ -682,15 +682,15 @@ check_relation_LHS_FIELD(dfwork_t *dfw, const char *relation_string, stnode_t *node_right = (stnode_t *)nodelist->data; if (node_right) { /* range type, check if comparison is possible. */ - if (!ftype_can_ge(ftype1)) { + if (!ftype_can_cmp(ftype1)) { dfilter_fail(dfw, "%s (type=%s) cannot participate in '%s' comparison.", hfinfo1->abbrev, ftype_pretty_name(ftype1), ">="); THROW(TypeError); } - check_relation_LHS_FIELD(dfw, ">=", ftype_can_ge, + check_relation_LHS_FIELD(dfw, ">=", ftype_can_cmp, allow_partial_value, st_arg2, st_arg1, node); - check_relation_LHS_FIELD(dfw, "<=", ftype_can_le, + check_relation_LHS_FIELD(dfw, "<=", ftype_can_cmp, allow_partial_value, st_arg2, st_arg1, node_right); } else { check_relation_LHS_FIELD(dfw, "==", can_func, @@ -1214,22 +1214,22 @@ check_test(dfwork_t *dfw, stnode_t *st_node) check_relation(dfw, "==", FALSE, ftype_can_eq, st_node, st_arg1, st_arg2); break; case TEST_OP_ALL_NE: - check_relation(dfw, "!=", FALSE, ftype_can_ne, st_node, st_arg1, st_arg2); + check_relation(dfw, "!=", FALSE, ftype_can_eq, st_node, st_arg1, st_arg2); break; case TEST_OP_ANY_NE: - check_relation(dfw, "~=", FALSE, ftype_can_ne, st_node, st_arg1, st_arg2); + check_relation(dfw, "~=", FALSE, ftype_can_eq, st_node, st_arg1, st_arg2); break; case TEST_OP_GT: - check_relation(dfw, ">", FALSE, ftype_can_gt, st_node, st_arg1, st_arg2); + check_relation(dfw, ">", FALSE, ftype_can_cmp, st_node, st_arg1, st_arg2); break; case TEST_OP_GE: - check_relation(dfw, ">=", FALSE, ftype_can_ge, st_node, st_arg1, st_arg2); + check_relation(dfw, ">=", FALSE, ftype_can_cmp, st_node, st_arg1, st_arg2); break; case TEST_OP_LT: - check_relation(dfw, "<", FALSE, ftype_can_lt, st_node, st_arg1, st_arg2); + check_relation(dfw, "<", FALSE, ftype_can_cmp, st_node, st_arg1, st_arg2); break; case TEST_OP_LE: - check_relation(dfw, "<=", FALSE, ftype_can_le, st_node, st_arg1, st_arg2); + check_relation(dfw, "<=", FALSE, ftype_can_cmp, st_node, st_arg1, st_arg2); break; case TEST_OP_BITWISE_AND: check_relation(dfw, "&", FALSE, ftype_can_bitwise_and, st_node, st_arg1, st_arg2); @@ -1241,9 +1241,7 @@ check_test(dfwork_t *dfw, stnode_t *st_node) check_relation_matches(dfw, st_node, st_arg1, st_arg2); break; case TEST_OP_IN: - /* Use the ftype_can_eq as the items in the set are evaluated using the - * semantics of equality. */ - check_relation(dfw, "in", FALSE, ftype_can_eq, st_node, st_arg1, st_arg2); + check_relation(dfw, "in", FALSE, ftype_can_cmp, st_node, st_arg1, st_arg2); break; default: diff --git a/epan/ftypes/ftypes.c b/epan/ftypes/ftypes.c index 12eb0940ed..c4e816fead 100644 --- a/epan/ftypes/ftypes.c +++ b/epan/ftypes/ftypes.c @@ -179,43 +179,7 @@ ftype_can_eq(enum ftenum ftype) } gboolean -ftype_can_ne(enum ftenum ftype) -{ - ftype_t *ft; - - FTYPE_LOOKUP(ftype, ft); - return ft->cmp_order != NULL; -} - -gboolean -ftype_can_gt(enum ftenum ftype) -{ - ftype_t *ft; - - FTYPE_LOOKUP(ftype, ft); - return ft->cmp_order != NULL; -} - -gboolean -ftype_can_ge(enum ftenum ftype) -{ - ftype_t *ft; - - FTYPE_LOOKUP(ftype, ft); - return ft->cmp_order != NULL; -} - -gboolean -ftype_can_lt(enum ftenum ftype) -{ - ftype_t *ft; - - FTYPE_LOOKUP(ftype, ft); - return ft->cmp_order != NULL; -} - -gboolean -ftype_can_le(enum ftenum ftype) +ftype_can_cmp(enum ftenum ftype) { ftype_t *ft; diff --git a/epan/ftypes/ftypes.h b/epan/ftypes/ftypes.h index fb7ff19fe7..e7b6c2af8f 100644 --- a/epan/ftypes/ftypes.h +++ b/epan/ftypes/ftypes.h @@ -179,23 +179,7 @@ ftype_can_eq(enum ftenum ftype); WS_DLL_PUBLIC gboolean -ftype_can_ne(enum ftenum ftype); - -WS_DLL_PUBLIC -gboolean -ftype_can_gt(enum ftenum ftype); - -WS_DLL_PUBLIC -gboolean -ftype_can_ge(enum ftenum ftype); - -WS_DLL_PUBLIC -gboolean -ftype_can_lt(enum ftenum ftype); - -WS_DLL_PUBLIC -gboolean -ftype_can_le(enum ftenum ftype); +ftype_can_cmp(enum ftenum ftype); gboolean ftype_can_bitwise_and(enum ftenum ftype); |