From 69ba6c776216548752169437b4751bd70c6a9b8a Mon Sep 17 00:00:00 2001 From: Guy Harris Date: Tue, 6 Nov 2007 08:46:57 +0000 Subject: The "bitwise AND" display filter operator is supposed to evaluate to TRUE if the result of the operation has any bit set; that means that the test should stop and return TRUE as soon as it finds two bytes that when ANDed together are non-zero, and return FALSE if no such byte was found. The other test functions don't have "_bytes" in the routine name; don't put it into this one. svn path=/trunk/; revision=23374 --- epan/ftypes/ftype-bytes.c | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/epan/ftypes/ftype-bytes.c b/epan/ftypes/ftype-bytes.c index 373ab7d8ae..f54cb2acb9 100644 --- a/epan/ftypes/ftype-bytes.c +++ b/epan/ftypes/ftype-bytes.c @@ -435,7 +435,8 @@ cmp_le(fvalue_t *fv_a, fvalue_t *fv_b) return (memcmp(a->data, b->data, a->len) <= 0); } -static gboolean cmp_bytes_bitwise_and(fvalue_t *fv_a, fvalue_t *fv_b) +static gboolean +cmp_bitwise_and(fvalue_t *fv_a, fvalue_t *fv_b) { GByteArray *a = fv_a->value.bytes; GByteArray *b = fv_b->value.bytes; @@ -449,11 +450,11 @@ static gboolean cmp_bytes_bitwise_and(fvalue_t *fv_a, fvalue_t *fv_b) p_b = b->data; while (i < b->len) { if (p_a[i] & p_b[i]) - i++; + return TRUE; else - return FALSE; + i++; } - return TRUE; + return FALSE; } static gboolean @@ -541,7 +542,7 @@ ftype_register_bytes(void) cmp_ge, cmp_lt, cmp_le, - cmp_bytes_bitwise_and, + cmp_bitwise_and, cmp_contains, CMP_MATCHES, @@ -579,7 +580,7 @@ ftype_register_bytes(void) cmp_ge, cmp_lt, cmp_le, - cmp_bytes_bitwise_and, + cmp_bitwise_and, cmp_contains, NULL, /* cmp_matches */ @@ -617,7 +618,7 @@ ftype_register_bytes(void) cmp_ge, cmp_lt, cmp_le, - cmp_bytes_bitwise_and, + cmp_bitwise_and, cmp_contains, CMP_MATCHES, @@ -655,7 +656,7 @@ ftype_register_bytes(void) cmp_ge, cmp_lt, cmp_le, - cmp_bytes_bitwise_and, + cmp_bitwise_and, cmp_contains, NULL, /* cmp_matches */ @@ -693,7 +694,7 @@ ftype_register_bytes(void) cmp_ge, cmp_lt, cmp_le, - cmp_bytes_bitwise_and, + cmp_bitwise_and, cmp_contains, NULL, /* cmp_matches */ -- cgit v1.2.1