summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2022-12-10 13:48:57 -0500
committerDavid Robillard <d@drobilla.net>2022-12-10 19:04:45 -0500
commit708911daa222ac5f1423a02ebc89eeaf21548f5a (patch)
tree697278b2b700d3856b52a6150c1a7da82a91d4f2
parent1988db57ca8003a406e08855ab66d1891fc5ce6b (diff)
downloadlilv-708911daa222ac5f1423a02ebc89eeaf21548f5a.tar.gz
lilv-708911daa222ac5f1423a02ebc89eeaf21548f5a.tar.bz2
lilv-708911daa222ac5f1423a02ebc89eeaf21548f5a.zip
Avoid "suspicious" string comparisons
-rw-r--r--src/.clang-tidy1
-rw-r--r--src/state.c11
-rw-r--r--src/world.c4
-rw-r--r--test/.clang-tidy1
-rw-r--r--test/test_plugin.lv2/test_plugin.c4
5 files changed, 10 insertions, 11 deletions
diff --git a/src/.clang-tidy b/src/.clang-tidy
index 1c26307..21665f3 100644
--- a/src/.clang-tidy
+++ b/src/.clang-tidy
@@ -6,7 +6,6 @@ Checks: >
-android-cloexec-fopen,
-bugprone-branch-clone,
-bugprone-narrowing-conversions,
- -bugprone-suspicious-string-compare,
-cert-err33-c,
-cert-err34-c,
-clang-analyzer-security.insecureAPI.DeprecatedOrUnsafeBufferHandling,
diff --git a/src/state.c b/src/state.c
index a662b8d..e67714d 100644
--- a/src/state.c
+++ b/src/state.c
@@ -1204,7 +1204,7 @@ lilv_state_make_links(const LilvState* state, const char* dir)
char* const path = zix_path_join(NULL, dir, pm->rel);
if (path_is_child(pm->abs, state->copy_dir) &&
- strcmp(state->copy_dir, dir)) {
+ !!strcmp(state->copy_dir, dir)) {
// Link directly to snapshot in the copy directory
maybe_symlink(pm->abs, path);
} else if (!path_is_child(pm->abs, dir)) {
@@ -1486,7 +1486,7 @@ lilv_state_equals(const LilvState* a, const LilvState* b)
{
if (!lilv_node_equals(a->plugin_uri, b->plugin_uri) ||
(a->label && !b->label) || (b->label && !a->label) ||
- (a->label && b->label && strcmp(a->label, b->label)) ||
+ (a->label && b->label && !!strcmp(a->label, b->label)) ||
a->props.n != b->props.n || a->n_values != b->n_values) {
return false;
}
@@ -1495,8 +1495,8 @@ lilv_state_equals(const LilvState* a, const LilvState* b)
PortValue* const av = &a->values[i];
PortValue* const bv = &b->values[i];
if (av->atom->size != bv->atom->size || av->atom->type != bv->atom->type ||
- strcmp(av->symbol, bv->symbol) ||
- memcmp(av->atom + 1, bv->atom + 1, av->atom->size)) {
+ !!strcmp(av->symbol, bv->symbol) ||
+ !!memcmp(av->atom + 1, bv->atom + 1, av->atom->size)) {
return false;
}
}
@@ -1514,7 +1514,8 @@ lilv_state_equals(const LilvState* a, const LilvState* b)
lilv_state_rel2abs(b, (char*)bp->value))) {
return false;
}
- } else if (ap->size != bp->size || memcmp(ap->value, bp->value, ap->size)) {
+ } else if (ap->size != bp->size ||
+ !!memcmp(ap->value, bp->value, ap->size)) {
return false;
}
}
diff --git a/src/world.c b/src/world.c
index 23116e9..695cc29 100644
--- a/src/world.c
+++ b/src/world.c
@@ -1093,11 +1093,11 @@ lilv_world_load_file(LilvWorld* world, SerdReader* reader, const LilvNode* uri)
size_t uri_len = 0;
const uint8_t* const uri_str =
sord_node_get_string_counted(uri->node, &uri_len);
- if (strncmp((const char*)uri_str, "file:", 5)) {
+ if (!!strncmp((const char*)uri_str, "file:", 5)) {
return SERD_FAILURE; // Not a local file
}
- if (strcmp((const char*)uri_str + uri_len - 4, ".ttl")) {
+ if (!!strcmp((const char*)uri_str + uri_len - 4, ".ttl")) {
return SERD_FAILURE; // Not a Turtle file
}
diff --git a/test/.clang-tidy b/test/.clang-tidy
index d359da0..4ef27ee 100644
--- a/test/.clang-tidy
+++ b/test/.clang-tidy
@@ -7,7 +7,6 @@ Checks: >
-android-cloexec-fopen,
-bugprone-branch-clone,
-bugprone-narrowing-conversions,
- -bugprone-suspicious-string-compare,
-cert-err33-c,
-clang-analyzer-security.insecureAPI.DeprecatedOrUnsafeBufferHandling,
-concurrency-mt-unsafe,
diff --git a/test/test_plugin.lv2/test_plugin.c b/test/test_plugin.lv2/test_plugin.c
index a0deccc..582fd9b 100644
--- a/test/test_plugin.lv2/test_plugin.c
+++ b/test/test_plugin.lv2/test_plugin.c
@@ -305,7 +305,7 @@ save(LV2_Handle instance,
char* apath = map_path->abstract_path(map_path->handle, tmp_file_path);
char* apath2 = map_path->abstract_path(map_path->handle, tmp_file_path);
free(tmp_file_path);
- if (strcmp(apath, apath2)) {
+ if (!!strcmp(apath, apath2)) {
fprintf(stderr, "error: Path %s != %s\n", apath, apath2);
}
@@ -407,7 +407,7 @@ restore(LV2_Handle instance,
char str[8];
size_t n_read = fread(str, 1, sizeof(str), f);
fclose(f);
- if (strncmp(str, "Hello\n", n_read)) {
+ if (!!strncmp(str, "Hello\n", n_read)) {
fprintf(
stderr, "error: Restored bad file contents `%s' != `Hello'\n", str);
}