From 93349b03bcf1552223a9c49f3f2e99bace4a1c04 Mon Sep 17 00:00:00 2001 From: David Robillard Date: Fri, 9 Sep 2022 13:25:17 -0400 Subject: Fix allegedly "suspicious" string comparisons I guess it's suspicious if you've got about 5 minutes of C experience? --- test/.clang-tidy | 1 - test/test_atom.c | 10 +++++----- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/test/.clang-tidy b/test/.clang-tidy index 53f37b1..ca868be 100644 --- a/test/.clang-tidy +++ b/test/.clang-tidy @@ -9,7 +9,6 @@ Checks: > -bugprone-easily-swappable-parameters, -bugprone-macro-parentheses, -bugprone-suspicious-include, - -bugprone-suspicious-string-compare, -llvm-header-guard, -llvmlibc-implementation-in-namespace, -llvmlibc-restrict-system-libc-headers, diff --git a/test/test_atom.c b/test/test_atom.c index 907028a..beac05c 100644 --- a/test/test_atom.c +++ b/test/test_atom.c @@ -102,7 +102,7 @@ main(void) LV2_Atom_String* path = (LV2_Atom_String*)lv2_atom_forge_deref( &forge, lv2_atom_forge_uri(&forge, pstr, pstr_len)); char* pbody = (char*)LV2_ATOM_BODY(path); - if (strcmp(pbody, pstr)) { + if (!!strcmp(pbody, pstr)) { return test_fail("%s != \"%s\"\n", pbody, pstr); } @@ -113,7 +113,7 @@ main(void) LV2_Atom_String* uri = (LV2_Atom_String*)lv2_atom_forge_deref( &forge, lv2_atom_forge_uri(&forge, ustr, ustr_len)); char* ubody = (char*)LV2_ATOM_BODY(uri); - if (strcmp(ubody, ustr)) { + if (!!strcmp(ubody, ustr)) { return test_fail("%s != \"%s\"\n", ubody, ustr); } @@ -131,7 +131,7 @@ main(void) LV2_Atom_String* string = (LV2_Atom_String*)lv2_atom_forge_deref( &forge, lv2_atom_forge_string(&forge, "hello", strlen("hello"))); char* sbody = (char*)LV2_ATOM_BODY(string); - if (strcmp(sbody, "hello")) { + if (!!strcmp(sbody, "hello")) { return test_fail("%s != \"hello\"\n", sbody); } @@ -145,7 +145,7 @@ main(void) 0, urid_map(NULL, "http://lexvo.org/id/term/fr"))); char* lbody = (char*)LV2_ATOM_CONTENTS(LV2_Atom_Literal, literal); - if (strcmp(lbody, "bonjour")) { + if (!!strcmp(lbody, "bonjour")) { return test_fail("%s != \"bonjour\"\n", lbody); } @@ -187,7 +187,7 @@ main(void) &forge, lv2_atom_forge_vector(&forge, sizeof(int32_t), forge.Int, 4, elems)); void* vec_body = LV2_ATOM_CONTENTS(LV2_Atom_Vector, vector); - if (memcmp(elems, vec_body, sizeof(elems))) { + if (!!memcmp(elems, vec_body, sizeof(elems))) { return test_fail("Corrupt vector\n"); } -- cgit v1.2.1