diff --git a/src/util-memcmp.c b/src/util-memcmp.c index 5d9f4f9a94..39dc02456b 100644 --- a/src/util-memcmp.c +++ b/src/util-memcmp.c @@ -67,8 +67,11 @@ static int MemcmpTest04 (void) { uint8_t a[] = "abcd"; uint8_t b[] = "abcD"; - if (SCMemcmp(a, b, sizeof(a)-1) != 1) + int r = SCMemcmp(a, b, sizeof(a)-1); + if (r != 1) { + printf("%s != %s, but memcmp returned %d: ", a, b, r); return 0; + } return 1; } diff --git a/src/util-memcmp.h b/src/util-memcmp.h index 6883c44c60..ba44e078cd 100644 --- a/src/util-memcmp.h +++ b/src/util-memcmp.h @@ -21,6 +21,9 @@ * \author Victor Julien * * Memcmp implementations for SSE3, SSE4.1 and SSE4.2. + * + * Both SCMemcmp and SCMemcmpLowercase return 0 on a exact match, + * 1 on a failed match. */ #ifndef __UTIL_MEMCMP_H__ @@ -302,7 +305,10 @@ static inline int SCMemcmpLowercase(void *s1, void *s2, size_t len) { /* No SIMD support, fall back to plain memcmp and a home grown lowercase one */ -#define SCMemcmp memcmp +/* wrapper around memcmp to match the retvals of the SIMD implementations */ +#define SCMemcmp(a,b,c) ({ \ + memcmp((a), (b), (c)) ? 1 : 0; \ +}) static inline int SCMemcmpLowercase(void *s1, void *s2, size_t n) {