diff options
author | David Robillard <d@drobilla.net> | 2022-09-09 13:25:17 -0400 |
---|---|---|
committer | David Robillard <d@drobilla.net> | 2022-09-09 13:26:44 -0400 |
commit | 93349b03bcf1552223a9c49f3f2e99bace4a1c04 (patch) | |
tree | b6f0bde0a9ba39f632f3fe9e647e6a293e544741 | |
parent | a459db9bf692e11c2d4ecb6047c2878cdcbeb2bd (diff) | |
download | lv2-93349b03bcf1552223a9c49f3f2e99bace4a1c04.tar.xz |
Fix allegedly "suspicious" string comparisons
I guess it's suspicious if you've got about 5 minutes of C experience?
-rw-r--r-- | test/.clang-tidy | 1 | ||||
-rw-r--r-- | 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"); } |