diff options
-rw-r--r-- | .clang-tidy | 1 | ||||
-rw-r--r-- | include/lilv/lilv.h | 4 | ||||
-rw-r--r-- | src/filesystem.c | 21 | ||||
-rw-r--r-- | src/lib.c | 5 | ||||
-rw-r--r-- | src/lilv_internal.h | 10 | ||||
-rw-r--r-- | src/node.c | 11 | ||||
-rw-r--r-- | src/plugin.c | 18 | ||||
-rw-r--r-- | src/query.c | 28 | ||||
-rw-r--r-- | src/state.c | 16 | ||||
-rw-r--r-- | src/util.c | 7 | ||||
-rw-r--r-- | src/world.c | 16 | ||||
-rw-r--r-- | src/zix/tree.c | 4 | ||||
-rw-r--r-- | utils/lv2apply.c | 8 | ||||
-rw-r--r-- | utils/lv2bench.c | 8 | ||||
-rw-r--r-- | utils/lv2info.c | 8 |
15 files changed, 105 insertions, 60 deletions
diff --git a/.clang-tidy b/.clang-tidy index 4a97ca0..a0a8e0b 100644 --- a/.clang-tidy +++ b/.clang-tidy @@ -1,6 +1,5 @@ Checks: > *, - -*-else-after-return, -*-magic-numbers, -*-uppercase-literal-suffix, -android-cloexec-fopen, diff --git a/include/lilv/lilv.h b/include/lilv/lilv.h index 8c9ee22..af75913 100644 --- a/include/lilv/lilv.h +++ b/include/lilv/lilv.h @@ -1741,9 +1741,9 @@ lilv_instance_get_extension_data(const LilvInstance* instance, { if (instance->lv2_descriptor->extension_data) { return instance->lv2_descriptor->extension_data(uri); - } else { - return NULL; } + + return NULL; } /** diff --git a/src/filesystem.c b/src/filesystem.c index b674113..dadd977 100644 --- a/src/filesystem.c +++ b/src/filesystem.c @@ -126,12 +126,12 @@ lilv_path_absolute(const char* path) { if (lilv_path_is_absolute(path)) { return lilv_strdup(path); - } else { - char* cwd = getcwd(NULL, 0); - char* abs_path = lilv_path_join(cwd, path); - free(cwd); - return abs_path; } + + char* cwd = getcwd(NULL, 0); + char* abs_path = lilv_path_join(cwd, path); + free(cwd); + return abs_path; } char* @@ -204,12 +204,13 @@ lilv_path_parent(const char* path) if (s == path) { // Hit beginning return lilv_is_dir_sep(*s) ? lilv_strdup("/") : lilv_strdup("."); - } else { // Pointing to the last character of the result (inclusive) - char* dirname = (char*)malloc(s - path + 2); - memcpy(dirname, path, s - path + 1); - dirname[s - path + 1] = '\0'; - return dirname; } + + // Pointing to the last character of the result (inclusive) + char* dirname = (char*)malloc(s - path + 2); + memcpy(dirname, path, s - path + 1); + dirname[s - path + 1] = '\0'; + return dirname; } char* @@ -101,9 +101,12 @@ lilv_lib_get_plugin(LilvLib* lib, uint32_t index) { if (lib->lv2_descriptor) { return lib->lv2_descriptor(index); - } else if (lib->desc) { + } + + if (lib->desc) { return lib->desc->get_plugin(lib->desc->handle, index); } + return NULL; } diff --git a/src/lilv_internal.h b/src/lilv_internal.h index 90cd89b..e5fde7a 100644 --- a/src/lilv_internal.h +++ b/src/lilv_internal.h @@ -325,12 +325,14 @@ lilv_version_cmp(const LilvVersion* a, const LilvVersion* b) { if (a->minor == b->minor && a->micro == b->micro) { return 0; - } else if ((a->minor < b->minor) - || (a->minor == b->minor && a->micro < b->micro)) { + } + + if ((a->minor < b->minor) + || (a->minor == b->minor && a->micro < b->micro)) { return -1; - } else { - return 1; } + + return 1; } struct LilvHeader* @@ -241,9 +241,9 @@ lilv_node_equals(const LilvNode* value, const LilvNode* other) { if (value == NULL && other == NULL) { return true; - } else if (value == NULL || other == NULL) { - return false; - } else if (value->type != other->type) { + } + + if (value == NULL || other == NULL || value->type != other->type) { return false; } @@ -384,9 +384,12 @@ lilv_node_as_float(const LilvNode* value) { if (lilv_node_is_float(value)) { return value->val.float_val; - } else if (lilv_node_is_int(value)) { + } + + if (lilv_node_is_int(value)) { return (float)value->val.int_val; } + return NAN; } diff --git a/src/plugin.c b/src/plugin.c index 9e9eba1..c72cc28 100644 --- a/src/plugin.c +++ b/src/plugin.c @@ -740,11 +740,13 @@ lilv_plugin_get_latency_port_index(const LilvPlugin* plugin) if (prop_port) { return prop_port->index; - } else if (des_port) { + } + + if (des_port) { return des_port->index; - } else { - return (uint32_t)-1; } + + return (uint32_t)-1; } bool @@ -827,9 +829,9 @@ lilv_plugin_get_port_by_index(const LilvPlugin* plugin, lilv_plugin_load_ports_if_necessary(plugin); if (index < plugin->num_ports) { return plugin->ports[index]; - } else { - return NULL; } + + return NULL; } const LilvPort* @@ -1005,10 +1007,10 @@ lilv_plugin_get_uis(const LilvPlugin* plugin) if (lilv_uis_size(result) > 0) { return result; - } else { - lilv_uis_free(result); - return NULL; } + + lilv_uis_free(result); + return NULL; } LilvNodes* diff --git a/src/query.c b/src/query.c index cf5e44f..5081a9a 100644 --- a/src/query.c +++ b/src/query.c @@ -34,7 +34,9 @@ lilv_lang_matches(const char* a, const char* b) { if (!a || !b) { return LILV_LANG_MATCH_NONE; - } else if (!strcmp(a, b)) { + } + + if (!strcmp(a, b)) { return LILV_LANG_MATCH_EXACT; } @@ -125,18 +127,20 @@ lilv_nodes_from_stream_objects(LilvWorld* world, if (sord_iter_end(stream)) { sord_iter_free(stream); return NULL; - } else if (world->opt.filter_language) { + } + + if (world->opt.filter_language) { return lilv_nodes_from_stream_objects_i18n(world, stream, field); - } else { - LilvNodes* values = lilv_nodes_new(); - FOREACH_MATCH(stream) { - const SordNode* value = sord_iter_get_node(stream, field); - LilvNode* node = lilv_node_new_from_node(world, value); - if (node) { - zix_tree_insert((ZixTree*)values, node, NULL); - } + } + + LilvNodes* values = lilv_nodes_new(); + FOREACH_MATCH(stream) { + const SordNode* value = sord_iter_get_node(stream, field); + LilvNode* node = lilv_node_new_from_node(world, value); + if (node) { + zix_tree_insert((ZixTree*)values, node, NULL); } - sord_iter_free(stream); - return values; } + sord_iter_free(stream); + return values; } diff --git a/src/state.c b/src/state.c index fed7b18..f30cfd4 100644 --- a/src/state.c +++ b/src/state.c @@ -100,7 +100,9 @@ property_cmp(const void* a, const void* b) if (a_key < b_key) { return -1; - } else if (b_key < a_key) { + } + + if (b_key < a_key) { return 1; } @@ -270,12 +272,16 @@ abstract_path(LV2_State_Map_Path_Handle handle, if (abs_path[0] == '\0') { return lilv_strdup(abs_path); - } else if (!zix_tree_find(state->abs2rel, &key, &iter)) { + } + + if (!zix_tree_find(state->abs2rel, &key, &iter)) { // Already mapped path in a previous call PathMap* pm = (PathMap*)zix_tree_get(iter); free(real_path); return lilv_strdup(pm->rel); - } else if (lilv_path_is_child(real_path, state->dir)) { + } + + if (lilv_path_is_child(real_path, state->dir)) { // File in state directory (loaded, or created by plugin during save) path = lilv_path_relative_to(real_path, state->dir); } else if (lilv_path_is_child(real_path, state->scratch_dir)) { @@ -1460,7 +1466,9 @@ lilv_state_equals(const LilvState* a, const LilvState* b) || ap->type != bp->type || ap->flags != bp->flags) { return false; - } else if (ap->type == a->atom_Path) { + } + + if (ap->type == a->atom_Path) { if (!lilv_file_equals(lilv_state_rel2abs(a, (char*)ap->value), lilv_state_rel2abs(b, (char*)bp->value))) { return false; @@ -165,10 +165,11 @@ append_var(char* dst, size_t* dst_len, const char* var) const char* val = getenv(var); if (val) { // Value found, append it return strappend(dst, dst_len, val, strlen(val)); - } else { // No value found, append variable reference as-is - return strappend(strappend(dst, dst_len, "$", 1), - dst_len, var, strlen(var)); } + + // No value found, append variable reference as-is + return strappend(strappend(dst, dst_len, "$", 1), + dst_len, var, strlen(var)); } #endif diff --git a/src/world.c b/src/world.c index 7095a6e..a04ba26 100644 --- a/src/world.c +++ b/src/world.c @@ -217,14 +217,20 @@ lilv_world_find_nodes(LilvWorld* world, LILV_ERRORF("Subject `%s' is not a resource\n", sord_node_get_string(subject->node)); return NULL; - } else if (!predicate) { + } + + if (!predicate) { LILV_ERROR("Missing required predicate\n"); return NULL; - } else if (!lilv_node_is_uri(predicate)) { + } + + if (!lilv_node_is_uri(predicate)) { LILV_ERRORF("Predicate `%s' is not a URI\n", sord_node_get_string(predicate->node)); return NULL; - } else if (!subject && !object) { + } + + if (!subject && !object) { LILV_ERROR("Both subject and object are NULL\n"); return NULL; } @@ -1115,7 +1121,9 @@ lilv_world_load_file(LilvWorld* world, SerdReader* reader, const LilvNode* uri) uri->node, &uri_len); if (strncmp((const char*)uri_str, "file:", 5)) { return SERD_FAILURE; // Not a local file - } else 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/src/zix/tree.c b/src/zix/tree.c index 55d39dc..15cea9a 100644 --- a/src/zix/tree.c +++ b/src/zix/tree.c @@ -599,7 +599,9 @@ zix_tree_find(const ZixTree* t, const void* e, ZixTreeIter** ti) const int cmp = t->cmp(e, n->data, t->cmp_data); if (cmp == 0) { break; - } else if (cmp < 0) { + } + + if (cmp < 0) { n = n->left; } else { n = n->right; diff --git a/utils/lv2apply.c b/utils/lv2apply.c index 96fcf91..1d11c50 100644 --- a/utils/lv2apply.c +++ b/utils/lv2apply.c @@ -243,10 +243,14 @@ main(int argc, char** argv) free(self.params); print_version(); return 0; - } else if (!strcmp(argv[i], "--help")) { + } + + if (!strcmp(argv[i], "--help")) { free(self.params); return print_usage(0); - } else if (!strcmp(argv[i], "-i")) { + } + + if (!strcmp(argv[i], "-i")) { self.in_path = argv[++i]; } else if (!strcmp(argv[i], "-o")) { self.out_path = argv[++i]; diff --git a/utils/lv2bench.c b/utils/lv2bench.c index 39ee6a7..000f062 100644 --- a/utils/lv2bench.c +++ b/utils/lv2bench.c @@ -217,10 +217,14 @@ main(int argc, char** argv) if (!strcmp(argv[a], "--version")) { print_version(); return 0; - } else if (!strcmp(argv[a], "--help")) { + } + + if (!strcmp(argv[a], "--help")) { print_usage(); return 0; - } else if (!strcmp(argv[a], "-f")) { + } + + if (!strcmp(argv[a], "-f")) { full_output = true; } else if (!strcmp(argv[a], "-n") && (a + 1 < argc)) { sample_count = atoi(argv[++a]); diff --git a/utils/lv2info.c b/utils/lv2info.c index 0027da1..f5dd621 100644 --- a/utils/lv2info.c +++ b/utils/lv2info.c @@ -371,10 +371,14 @@ main(int argc, char** argv) if (!strcmp(argv[i], "--version")) { print_version(); return 0; - } else if (!strcmp(argv[i], "--help")) { + } + + if (!strcmp(argv[i], "--help")) { print_usage(); return 0; - } else if (!strcmp(argv[i], "-p")) { + } + + if (!strcmp(argv[i], "-p")) { plugin_file = argv[++i]; } else if (!strcmp(argv[i], "-m")) { manifest_file = argv[++i]; |