diff options
author | David Robillard <d@drobilla.net> | 2017-12-26 14:56:35 -0500 |
---|---|---|
committer | David Robillard <d@drobilla.net> | 2017-12-29 10:44:36 -0500 |
commit | d1f677c22311d6eb7bc2073aa1e80921e45dbb1d (patch) | |
tree | 461e1f1e8e88fd1ab36d1cee8a675de859b81eff | |
parent | 105294454ba1f3f89fa0f6a679503204397d35d2 (diff) | |
download | lilv-d1f677c22311d6eb7bc2073aa1e80921e45dbb1d.tar.gz lilv-d1f677c22311d6eb7bc2073aa1e80921e45dbb1d.tar.bz2 lilv-d1f677c22311d6eb7bc2073aa1e80921e45dbb1d.zip |
Use braces everywhere
-rw-r--r-- | lilv/lilv.h | 11 | ||||
-rw-r--r-- | src/collections.c | 9 | ||||
-rw-r--r-- | src/instance.c | 3 | ||||
-rw-r--r-- | src/node.c | 25 | ||||
-rw-r--r-- | src/plugin.c | 20 | ||||
-rw-r--r-- | src/pluginclass.c | 3 | ||||
-rw-r--r-- | src/port.c | 15 | ||||
-rw-r--r-- | src/util.c | 3 | ||||
-rw-r--r-- | src/world.c | 12 | ||||
-rw-r--r-- | test/lilv_test.c | 57 | ||||
-rw-r--r-- | utils/lv2info.c | 45 |
11 files changed, 132 insertions, 71 deletions
diff --git a/lilv/lilv.h b/lilv/lilv.h index 7562f09..c1233bb 100644 --- a/lilv/lilv.h +++ b/lilv/lilv.h @@ -1678,8 +1678,9 @@ lilv_instance_connect_port(LilvInstance* instance, static inline void lilv_instance_activate(LilvInstance* instance) { - if (instance->lv2_descriptor->activate) + if (instance->lv2_descriptor->activate) { instance->lv2_descriptor->activate(instance->lv2_handle); + } } /** @@ -1702,8 +1703,9 @@ lilv_instance_run(LilvInstance* instance, static inline void lilv_instance_deactivate(LilvInstance* instance) { - if (instance->lv2_descriptor->deactivate) + if (instance->lv2_descriptor->deactivate) { instance->lv2_descriptor->deactivate(instance->lv2_handle); + } } /** @@ -1715,10 +1717,11 @@ static inline const void* lilv_instance_get_extension_data(const LilvInstance* instance, const char* uri) { - if (instance->lv2_descriptor->extension_data) + if (instance->lv2_descriptor->extension_data) { return instance->lv2_descriptor->extension_data(uri); - else + } else { return NULL; + } } /** diff --git a/src/collections.c b/src/collections.c index 95d8fe6..f519b71 100644 --- a/src/collections.c +++ b/src/collections.c @@ -41,8 +41,9 @@ lilv_collection_new(ZixComparator cmp, ZixDestroyFunc destructor) void lilv_collection_free(LilvCollection* coll) { - if (coll) + if (coll) { zix_tree_free((ZixTree*)coll); + } } unsigned @@ -129,9 +130,11 @@ lilv_plugins_get_by_uri(const LilvPlugins* list, const LilvNode* uri) LILV_API bool lilv_nodes_contains(const LilvNodes* list, const LilvNode* value) { - LILV_FOREACH(nodes, i, list) - if (lilv_node_equals(lilv_nodes_get(list, i), value)) + LILV_FOREACH(nodes, i, list) { + if (lilv_node_equals(lilv_nodes_get(list, i), value)) { return true; + } + } return false; } diff --git a/src/instance.c b/src/instance.c index 93f0754..030c6ff 100644 --- a/src/instance.c +++ b/src/instance.c @@ -98,8 +98,9 @@ lilv_plugin_instantiate(const LilvPlugin* plugin, LILV_API void lilv_instance_free(LilvInstance* instance) { - if (!instance) + if (!instance) { return; + } instance->lv2_descriptor->cleanup(instance->lv2_handle); instance->lv2_descriptor = NULL; @@ -121,19 +121,20 @@ lilv_node_new_from_node(LilvWorld* world, const SordNode* node) case SORD_LITERAL: datatype_uri = sord_node_get_datatype(node); if (datatype_uri) { - if (sord_node_equals(datatype_uri, world->uris.xsd_boolean)) + if (sord_node_equals(datatype_uri, world->uris.xsd_boolean)) { type = LILV_VALUE_BOOL; - else if (sord_node_equals(datatype_uri, world->uris.xsd_decimal) - || sord_node_equals(datatype_uri, world->uris.xsd_double)) + } else if (sord_node_equals(datatype_uri, world->uris.xsd_decimal) || + sord_node_equals(datatype_uri, world->uris.xsd_double)) { type = LILV_VALUE_FLOAT; - else if (sord_node_equals(datatype_uri, world->uris.xsd_integer)) + } else if (sord_node_equals(datatype_uri, world->uris.xsd_integer)) { type = LILV_VALUE_INT; - else if (sord_node_equals(datatype_uri, - world->uris.xsd_base64Binary)) + } else if (sord_node_equals(datatype_uri, + world->uris.xsd_base64Binary)) { type = LILV_VALUE_BLOB; - else + } else { LILV_ERRORF("Unknown datatype `%s'\n", sord_node_get_string(datatype_uri)); + } } result = lilv_node_new( world, type, (const char*)sord_node_get_string(node)); @@ -225,12 +226,13 @@ lilv_node_free(LilvNode* val) LILV_API bool lilv_node_equals(const LilvNode* value, const LilvNode* other) { - if (value == NULL && other == NULL) + if (value == NULL && other == NULL) { return true; - else if (value == NULL || other == NULL) + } else if (value == NULL || other == NULL) { return false; - else if (value->type != other->type) + } else if (value->type != other->type) { return false; + } switch (value->type) { case LILV_VALUE_URI: @@ -317,8 +319,9 @@ lilv_node_as_blank(const LilvNode* value) LILV_API bool lilv_node_is_literal(const LilvNode* value) { - if (!value) + if (!value) { return false; + } switch (value->type) { case LILV_VALUE_STRING: diff --git a/src/plugin.c b/src/plugin.c index 5e10d7c..e8956fb 100644 --- a/src/plugin.c +++ b/src/plugin.c @@ -359,8 +359,9 @@ lilv_plugin_load_ports_if_necessary(const LilvPlugin* const_p) void lilv_plugin_load_if_necessary(const LilvPlugin* p) { - if (!p->loaded) + if (!p->loaded) { lilv_plugin_load((LilvPlugin*)p); + } } LILV_API const LilvNode* @@ -441,8 +442,9 @@ lilv_plugin_get_class(const LilvPlugin* const_p) } sord_iter_free(c); - if (p->plugin_class == NULL) + if (p->plugin_class == NULL) { p->plugin_class = p->world->lv2_plugin_class; + } } return p->plugin_class; } @@ -499,14 +501,16 @@ lilv_plugin_get_name(const LilvPlugin* plugin) LilvNode* ret = NULL; if (results) { LilvNode* val = lilv_nodes_get_first(results); - if (lilv_node_is_string(val)) + if (lilv_node_is_string(val)) { ret = lilv_node_duplicate(val); + } lilv_nodes_free(results); } - if (!ret) + if (!ret) { LILV_WARNF("Plugin <%s> has no (mandatory) doap:name\n", lilv_node_as_string(lilv_plugin_get_uri(plugin))); + } return ret; } @@ -807,10 +811,11 @@ lilv_plugin_get_port_by_index(const LilvPlugin* p, uint32_t index) { lilv_plugin_load_ports_if_necessary(p); - if (index < p->num_ports) + if (index < p->num_ports) { return p->ports[index]; - else + } else { return NULL; + } } LILV_API const LilvPort* @@ -820,8 +825,9 @@ lilv_plugin_get_port_by_symbol(const LilvPlugin* p, lilv_plugin_load_ports_if_necessary(p); for (uint32_t i = 0; i < p->num_ports; ++i) { LilvPort* port = p->ports[i]; - if (lilv_node_equals(port->symbol, symbol)) + if (lilv_node_equals(port->symbol, symbol)) { return port; + } } return NULL; diff --git a/src/pluginclass.c b/src/pluginclass.c index 0afb39a..622ff8f 100644 --- a/src/pluginclass.c +++ b/src/pluginclass.c @@ -79,8 +79,9 @@ lilv_plugin_class_get_children(const LilvPluginClass* plugin_class) const LilvPluginClass* c = (LilvPluginClass*)zix_tree_get(i); const LilvNode* parent = lilv_plugin_class_get_parent_uri(c); if (parent && lilv_node_equals(lilv_plugin_class_get_uri(plugin_class), - parent)) + parent)) { zix_tree_insert((ZixTree*)result, (LilvPluginClass*)c, NULL); + } } return result; @@ -55,9 +55,11 @@ lilv_port_is_a(const LilvPlugin* plugin, const LilvPort* port, const LilvNode* port_class) { - LILV_FOREACH(nodes, i, port->classes) - if (lilv_node_equals(lilv_nodes_get(port->classes, i), port_class)) + LILV_FOREACH(nodes, i, port->classes) { + if (lilv_node_equals(lilv_nodes_get(port->classes, i), port_class)) { return true; + } + } return false; } @@ -163,14 +165,16 @@ lilv_port_get_name(const LilvPlugin* p, LilvNode* ret = NULL; if (results) { LilvNode* val = lilv_nodes_get_first(results); - if (lilv_node_is_string(val)) + if (lilv_node_is_string(val)) { ret = lilv_node_duplicate(val); + } lilv_nodes_free(results); } - if (!ret) + if (!ret) { LILV_WARNF("Plugin <%s> port has no (mandatory) doap:name\n", lilv_node_as_string(lilv_plugin_get_uri(p))); + } return ret; } @@ -226,8 +230,9 @@ lilv_port_get_scale_points(const LilvPlugin* p, NULL); LilvScalePoints* ret = NULL; - if (!sord_iter_end(points)) + if (!sord_iter_end(points)) { ret = lilv_scale_points_new(); + } FOREACH_MATCH(points) { const SordNode* point = sord_iter_get_node(points, SORD_OBJECT); @@ -86,8 +86,9 @@ lilv_strjoin(const char* first, ...) va_start(args, first); while (1) { const char* const s = va_arg(args, const char *); - if (s == NULL) + if (s == NULL) { break; + } const size_t this_len = strlen(s); char* new_result = (char*)realloc(result, len + this_len + 1); diff --git a/src/world.c b/src/world.c index a053b0d..80aad28 100644 --- a/src/world.c +++ b/src/world.c @@ -32,12 +32,14 @@ lilv_world_new(void) LilvWorld* world = (LilvWorld*)malloc(sizeof(LilvWorld)); world->world = sord_world_new(); - if (!world->world) + if (!world->world) { goto fail; + } world->model = sord_new(world->world, SORD_SPO|SORD_OPS, true); - if (!world->model) + if (!world->model) { goto fail; + } world->specs = NULL; world->plugin_classes = lilv_plugin_classes_new(); @@ -893,8 +895,9 @@ static void load_dir_entry(const char* dir, const char* name, void* data) { LilvWorld* world = (LilvWorld*)data; - if (!strcmp(name, ".") || !strcmp(name, "..")) + if (!strcmp(name, ".") || !strcmp(name, "..")) { return; + } char* path = lilv_strjoin(dir, "/", name, "/", NULL); SerdNode suri = serd_node_new_file_uri((const uint8_t*)path, 0, 0, true); @@ -1012,8 +1015,9 @@ LILV_API void lilv_world_load_all(LilvWorld* world) { const char* lv2_path = getenv("LV2_PATH"); - if (!lv2_path) + if (!lv2_path) { lv2_path = LILV_DEFAULT_LV2_PATH; + } // Discover bundles and read all manifest files into model lilv_world_load_path(world, lv2_path); diff --git a/test/lilv_test.c b/test/lilv_test.c index 106f5c8..1dac17a 100644 --- a/test/lilv_test.c +++ b/test/lilv_test.c @@ -103,8 +103,9 @@ write_file(const char* name, const char* content) { FILE* f = fopen(name, "w"); size_t len = strlen(content); - if (fwrite(content, 1, len, f) != len) + if (fwrite(content, 1, len, f) != len) { fatal_error("Cannot write file %s\n", name); + } fclose(f); } @@ -118,8 +119,9 @@ init_world(void) static int load_all_bundles(void) { - if (!init_world()) + if (!init_world()) { return 0; + } lilv_world_load_all(world); return 1; } @@ -127,8 +129,9 @@ load_all_bundles(void) static void create_bundle(const char* manifest, const char* content) { - if (mkdir(bundle_dir_name, 0700) && errno != EEXIST) + if (mkdir(bundle_dir_name, 0700) && errno != EEXIST) { fatal_error("Cannot create directory %s\n", bundle_dir_name); + } write_file(manifest_name, manifest); write_file(content_name, content); } @@ -143,8 +146,9 @@ start_bundle(const char* manifest, const char* content) static void unload_bundle(void) { - if (world) + if (world) { lilv_world_free(world); + } world = NULL; } @@ -227,8 +231,9 @@ test_value(void) "lv2:port [ " " a lv2:ControlPort ; a lv2:InputPort ; " " lv2:index 0 ; lv2:symbol \"foo\" ; lv2:name \"Foo\" ; " - "] .")) + "] .")) { return 0; + } init_uris(); @@ -420,8 +425,9 @@ test_discovery(void) PLUGIN_NAME("Test plugin") " ; " LICENSE_GPL " ; " "lv2:port [ a lv2:ControlPort ; a lv2:InputPort ;" - " lv2:index 0 ; lv2:symbol \"foo\" ; lv2:name \"bar\" ; ] .")) + " lv2:index 0 ; lv2:symbol \"foo\" ; lv2:name \"bar\" ; ] .")) { return 0; + } init_uris(); @@ -499,8 +505,9 @@ test_verify(void) PLUGIN_NAME("Test plugin") " ; " LICENSE_GPL " ; " "lv2:port [ a lv2:ControlPort ; a lv2:InputPort ;" - " lv2:index 0 ; lv2:symbol \"foo\" ; lv2:name \"bar\" ] .")) + " lv2:index 0 ; lv2:symbol \"foo\" ; lv2:name \"bar\" ] .")) { return 0; + } init_uris(); const LilvPlugins* plugins = lilv_world_get_all_plugins(world); @@ -519,8 +526,9 @@ test_no_verify(void) if (!start_bundle(MANIFEST_PREFIXES ":plug a lv2:Plugin ; lv2:binary <foo" SHLIB_EXT "> ; rdfs:seeAlso <plugin.ttl> .\n", BUNDLE_PREFIXES - ":plug a lv2:Plugin . ")) + ":plug a lv2:Plugin . ")) { return 0; + } init_uris(); const LilvPlugins* plugins = lilv_world_get_all_plugins(world); @@ -545,8 +553,9 @@ test_classes(void) "lv2:port [ " " a lv2:ControlPort ; a lv2:InputPort ; " " lv2:index 0 ; lv2:symbol \"foo\" ; lv2:name \"Foo\" ; " - "] .")) + "] .")) { return 0; + } init_uris(); const LilvPluginClass* plugin = lilv_world_get_plugin_class(world); @@ -609,8 +618,9 @@ test_plugin(void) " lv2:portProperty lv2:reportsLatency ; " " lv2:designation lv2:latency " "] . \n" - ":thing doap:name \"Something else\" .\n")) + ":thing doap:name \"Something else\" .\n")) { return 0; + } init_uris(); const LilvPlugins* plugins = lilv_world_get_all_plugins(world); @@ -842,8 +852,9 @@ test_project(void) " lv2:portProperty lv2:reportsLatency ; " " lv2:designation lv2:latency " "] . \n" - ":thing doap:name \"Something else\" .\n")) + ":thing doap:name \"Something else\" .\n")) { return 0; + } init_uris(); const LilvPlugins* plugins = lilv_world_get_all_plugins(world); @@ -891,8 +902,9 @@ test_no_author(void) " lv2:portProperty lv2:reportsLatency ; " " lv2:designation lv2:latency " "] . \n" - ":thing doap:name \"Something else\" .\n")) + ":thing doap:name \"Something else\" .\n")) { return 0; + } init_uris(); const LilvPlugins* plugins = lilv_world_get_all_plugins(world); @@ -940,8 +952,9 @@ test_project_no_author(void) " lv2:portProperty lv2:reportsLatency ; " " lv2:designation lv2:latency " "] . \n" - ":thing doap:name \"Something else\" .\n")) + ":thing doap:name \"Something else\" .\n")) { return 0; + } init_uris(); const LilvPlugins* plugins = lilv_world_get_all_plugins(world); @@ -991,8 +1004,9 @@ test_preset(void) "] . \n" "<http://example.org/preset> a pset:Preset ;" " lv2:appliesTo :plug ;" - " rdfs:label \"some preset\" .\n")) + " rdfs:label \"some preset\" .\n")) { return 0; + } init_uris(); const LilvPlugins* plugins = lilv_world_get_all_plugins(world); @@ -1038,8 +1052,9 @@ test_prototype(void) " lv2:portProperty lv2:reportsLatency ; " " lv2:designation lv2:latency " "] . \n" - ":plug doap:name \"Instance\" .\n")) + ":plug doap:name \"Instance\" .\n")) { return 0; + } init_uris(); const LilvPlugins* plugins = lilv_world_get_all_plugins(world); @@ -1096,8 +1111,9 @@ test_port(void) " a lv2:AudioPort ; a lv2:OutputPort ; " " lv2:index 3 ; lv2:symbol \"audio_out\" ; " " lv2:name \"Audio Output\" ; " - "] .")) + "] .")) { return 0; + } init_uris(); const LilvPlugins* plugins = lilv_world_get_all_plugins(world); @@ -1378,8 +1394,9 @@ test_ui(void) " lv2ui:optionalFeature lv2ui:ext_presets . " ":ui2 a lv2ui:GtkUI ; lv2ui:binary <ui2" SHLIB_EXT "> . " ":ui3 a lv2ui:GtkUI ; lv2ui:binary <ui3" SHLIB_EXT "> . " - ":ui4 a lv2ui:GtkUI ; lv2ui:binary <ui4" SHLIB_EXT "> . ")) + ":ui4 a lv2ui:GtkUI ; lv2ui:binary <ui4" SHLIB_EXT "> . ")) { return 0; + } init_uris(); const LilvPlugins* plugins = lilv_world_get_all_plugins(world); @@ -1893,8 +1910,9 @@ test_bad_port_symbol(void) " a lv2:ControlPort ; a lv2:InputPort ; " " lv2:index 0 ; lv2:symbol \"0invalid\" ;" " lv2:name \"Invalid\" ; " - "] .")) + "] .")) { return 0; + } init_uris(); @@ -1924,8 +1942,9 @@ test_bad_port_index(void) " a lv2:ControlPort ; a lv2:InputPort ; " " lv2:index \"notaninteger\" ; lv2:symbol \"invalid\" ;" " lv2:name \"Invalid\" ; " - "] .")) + "] .")) { return 0; + } init_uris(); diff --git a/utils/lv2info.c b/utils/lv2info.c index 52c5aac..75a093f 100644 --- a/utils/lv2info.c +++ b/utils/lv2info.c @@ -84,8 +84,9 @@ print_port(const LilvPlugin* p, } LilvScalePoints* points = lilv_port_get_scale_points(p, port); - if (points) + if (points) { printf("\n\t\tScale Points:\n"); + } LILV_FOREACH(scale_points, i, points) { const LilvScalePoint* point = lilv_scale_points_get(points, i); printf("\t\t\t%s = \"%s\"\n", @@ -116,17 +117,21 @@ print_port(const LilvPlugin* p, lilv_nodes_free(designations); if (lilv_port_is_a(p, port, control_class)) { - if (!isnan(mins[index])) + if (!isnan(mins[index])) { printf("\t\tMinimum: %f\n", mins[index]); - if (!isnan(maxes[index])) + } + if (!isnan(maxes[index])) { printf("\t\tMaximum: %f\n", maxes[index]); - if (!isnan(defaults[index])) + } + if (!isnan(defaults[index])) { printf("\t\tDefault: %f\n", defaults[index]); + } } LilvNodes* properties = lilv_port_get_properties(p, port); - if (lilv_nodes_size(properties) > 0) + if (lilv_nodes_size(properties) > 0) { printf("\t\tProperties: "); + } first = true; LILV_FOREACH(nodes, i, properties) { if (!first) { @@ -135,8 +140,9 @@ print_port(const LilvPlugin* p, printf("%s\n", lilv_node_as_uri(lilv_nodes_get(properties, i))); first = false; } - if (lilv_nodes_size(properties) > 0) + if (lilv_nodes_size(properties) > 0) { printf("\n"); + } lilv_nodes_free(properties); } @@ -209,8 +215,9 @@ print_plugin(LilvWorld* world, lilv_node_as_uri(lilv_nodes_get(types, t))); } - if (binary) + if (binary) { printf("\t\t\tBinary: %s\n", binary); + } printf("\t\t\tBundle: %s\n", lilv_node_as_uri(lilv_ui_get_bundle_uri(ui))); @@ -233,8 +240,9 @@ print_plugin(LilvWorld* world, /* Required Features */ LilvNodes* features = lilv_plugin_get_required_features(p); - if (features) + if (features) { printf("\tRequired Features: "); + } first = true; LILV_FOREACH(nodes, i, features) { if (!first) { @@ -243,15 +251,17 @@ print_plugin(LilvWorld* world, printf("%s", lilv_node_as_uri(lilv_nodes_get(features, i))); first = false; } - if (features) + if (features) { printf("\n"); + } lilv_nodes_free(features); /* Optional Features */ features = lilv_plugin_get_optional_features(p); - if (features) + if (features) { printf("\tOptional Features: "); + } first = true; LILV_FOREACH(nodes, i, features) { if (!first) { @@ -260,15 +270,17 @@ print_plugin(LilvWorld* world, printf("%s", lilv_node_as_uri(lilv_nodes_get(features, i))); first = false; } - if (features) + if (features) { printf("\n"); + } lilv_nodes_free(features); /* Extension Data */ LilvNodes* data = lilv_plugin_get_extension_data(p); - if (data) + if (data) { printf("\tExtension Data: "); + } first = true; LILV_FOREACH(nodes, i, data) { if (!first) { @@ -277,15 +289,17 @@ print_plugin(LilvWorld* world, printf("%s", lilv_node_as_uri(lilv_nodes_get(data, i))); first = false; } - if (data) + if (data) { printf("\n"); + } lilv_nodes_free(data); /* Presets */ LilvNodes* presets = lilv_plugin_get_related(p, preset_class); - if (presets) + if (presets) { printf("\tPresets: \n"); + } LILV_FOREACH(nodes, i, presets) { const LilvNode* preset = lilv_nodes_get(presets, i); lilv_world_load_resource(world, preset); @@ -310,8 +324,9 @@ print_plugin(LilvWorld* world, float* defaults = (float*)calloc(num_ports, sizeof(float)); lilv_plugin_get_port_ranges_float(p, mins, maxes, defaults); - for (uint32_t i = 0; i < num_ports; ++i) + for (uint32_t i = 0; i < num_ports; ++i) { print_port(p, i, mins, maxes, defaults); + } free(mins); free(maxes); |