aboutsummaryrefslogtreecommitdiffstats
path: root/epan/ftypes/ftype-guid.c
diff options
context:
space:
mode:
authorJoão Valverde <j@v6e.pt>2021-10-10 16:00:51 +0100
committerWireshark GitLab Utility <gerald+gitlab-utility@wireshark.org>2021-10-10 20:48:29 +0000
commit13e9e7199c64256370af1f27a57b11acdcd11caf (patch)
treee6ffd9c54a893963a2db230dc8c2666327715b15 /epan/ftypes/ftype-guid.c
parent6299a66a929b446ebf7beeb853b19634aa2c1f1e (diff)
ftypes: Use an order function to compare ftypes
All the order operators can be defined in terms of 'lt' and 'eq' so use that to reduce the number of required methods from 6 to 2. Further reduce to one by combining those two into a single function that has memcmp semantics: negative return is "less than", positive is "greater than" and zero is equal.
Diffstat (limited to 'epan/ftypes/ftype-guid.c')
-rw-r--r--epan/ftypes/ftype-guid.c19
1 files changed, 4 insertions, 15 deletions
diff --git a/epan/ftypes/ftype-guid.c b/epan/ftypes/ftype-guid.c
index 96fb476fb0..648757b161 100644
--- a/epan/ftypes/ftype-guid.c
+++ b/epan/ftypes/ftype-guid.c
@@ -93,16 +93,10 @@ guid_to_repr(fvalue_t *fv, ftrepr_t rtype _U_, int field_display _U_, char *buf,
guid_to_str_buf(&fv->value.guid, buf, size);
}
-static gboolean
-cmp_eq(const fvalue_t *a, const fvalue_t *b)
-{
- return memcmp(&a->value.guid, &b->value.guid, sizeof(e_guid_t)) == 0;
-}
-
-static gboolean
-cmp_ne(const fvalue_t *a, const fvalue_t *b)
+static int
+cmp_order(const fvalue_t *a, const fvalue_t *b)
{
- return memcmp(&a->value.guid, &b->value.guid, sizeof(e_guid_t)) != 0;
+ return memcmp(&a->value.guid, &b->value.guid, sizeof(e_guid_t));
}
void
@@ -124,12 +118,7 @@ ftype_register_guid(void)
{ .set_value_guid = guid_fvalue_set_guid }, /* union set_value */
{ .get_value_ptr = value_get }, /* union get_value */
- cmp_eq,
- cmp_ne,
- NULL,
- NULL,
- NULL,
- NULL,
+ cmp_order,
NULL,
NULL,
NULL, /* cmp_matches */