From 0945afa159d0da327d4da8d2c4e7d345d308cd97 Mon Sep 17 00:00:00 2001 From: David Robillard Date: Fri, 2 Jul 2021 13:56:21 -0400 Subject: Avoid allegedly "suspicious" string comparisons I guess these are suspicious if you've never seen C before? --- benchmark/dict_bench.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'benchmark/dict_bench.c') diff --git a/benchmark/dict_bench.c b/benchmark/dict_bench.c index 4a77257..90b0abc 100644 --- a/benchmark/dict_bench.c +++ b/benchmark/dict_bench.c @@ -165,7 +165,7 @@ main(int argc, char** argv) for (size_t i = 0; i < n; ++i) { const size_t index = lcg64(seed + i) % n; char* match = (char*)g_hash_table_lookup(hash, strings[index]); - if (strcmp(match, strings[index])) { + if (!!strcmp(match, strings[index])) { return test_fail("Bad match for `%s'\n", strings[index]); } } @@ -181,7 +181,7 @@ main(int argc, char** argv) return test_fail("Hash: Failed to find `%s'\n", strings[index]); } - if (strcmp((const char*)match->buf, strings[index])) { + if (!!strcmp((const char*)match->buf, strings[index])) { return test_fail("Hash: Bad match %p for `%s': `%s'\n", (const void*)match, strings[index], -- cgit v1.2.1