summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2020-12-31 14:07:31 +0100
committerDavid Robillard <d@drobilla.net>2020-12-31 14:07:31 +0100
commit7a51f0b8e95d29b5e053db97bf72094e847ee7ef (patch)
tree388ce4b62ee033777125370be4105c5b8aa8b2df /src
parenta5a72832c05ba2894d90def0b74128a93dcca937 (diff)
downloadlilv-7a51f0b8e95d29b5e053db97bf72094e847ee7ef.tar.gz
lilv-7a51f0b8e95d29b5e053db97bf72094e847ee7ef.tar.bz2
lilv-7a51f0b8e95d29b5e053db97bf72094e847ee7ef.zip
Avoid "else" after "return"
Diffstat (limited to 'src')
-rw-r--r--src/filesystem.c21
-rw-r--r--src/lib.c5
-rw-r--r--src/lilv_internal.h10
-rw-r--r--src/node.c11
-rw-r--r--src/plugin.c18
-rw-r--r--src/query.c28
-rw-r--r--src/state.c16
-rw-r--r--src/util.c7
-rw-r--r--src/world.c16
-rw-r--r--src/zix/tree.c4
10 files changed, 85 insertions, 51 deletions
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*
diff --git a/src/lib.c b/src/lib.c
index b2a93bb..b2ad20c 100644
--- a/src/lib.c
+++ b/src/lib.c
@@ -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*
diff --git a/src/node.c b/src/node.c
index 59b3353..fa7e9fe 100644
--- a/src/node.c
+++ b/src/node.c
@@ -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;
diff --git a/src/util.c b/src/util.c
index d299c1e..e8f034e 100644
--- a/src/util.c
+++ b/src/util.c
@@ -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;