From 95f3345fc62ad8e81b18cdbf50929f5801868fac Mon Sep 17 00:00:00 2001 From: David Robillard Date: Sat, 14 Jan 2012 22:34:35 +0000 Subject: Lint. git-svn-id: http://svn.drobilla.net/lad/trunk/lilv@3948 a436a847-0d15-0410-975c-d299462d15a1 --- src/instance.c | 4 ++-- src/node.c | 6 ++++-- src/plugin.c | 29 +++++++++++++++++------------ src/query.c | 4 +++- src/state.c | 44 ++++++++++++++++++++++++-------------------- src/util.c | 4 ++-- src/world.c | 16 +++++++++------- 7 files changed, 61 insertions(+), 46 deletions(-) (limited to 'src') diff --git a/src/instance.c b/src/instance.c index 4823f59..9685a08 100644 --- a/src/instance.c +++ b/src/instance.c @@ -55,7 +55,7 @@ lilv_plugin_instantiate(const LilvPlugin* plugin, lilv_dlfunc(lib, "lv2_descriptor"); if (!df) { - LILV_ERRORF("Failed to find symbol 'lv2_descriptor' in %s\n", lib_path); + LILV_ERRORF("No `lv2_descriptor' in %s\n", lib_path); dlclose(lib); return NULL; } else { @@ -67,7 +67,7 @@ lilv_plugin_instantiate(const LilvPlugin* plugin, for (uint32_t i = 0; true; ++i) { const LV2_Descriptor* ld = df(i); if (!ld) { - LILV_ERRORF("Failed to find plugin <%s> in %s\n", + LILV_ERRORF("No plugin <%s> in %s\n", lilv_node_as_uri(lilv_plugin_get_uri(plugin)), lib_path); dlclose(lib); diff --git a/src/node.c b/src/node.c index 8f73df6..169afa1 100644 --- a/src/node.c +++ b/src/node.c @@ -111,7 +111,8 @@ lilv_node_new_from_node(LilvWorld* world, const SordNode* node) type = LILV_VALUE_FLOAT; 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 LILV_ERRORF("Unknown datatype `%s'\n", @@ -168,7 +169,8 @@ LILV_API LilvNode* lilv_new_bool(LilvWorld* world, bool val) { - LilvNode* ret = lilv_node_new(world, LILV_VALUE_BOOL, val ? "true" : "false"); + LilvNode* ret = lilv_node_new(world, LILV_VALUE_BOOL, + val ? "true" : "false"); ret->val.bool_val = val; return ret; } diff --git a/src/plugin.c b/src/plugin.c index b3763cb..ca1723a 100644 --- a/src/plugin.c +++ b/src/plugin.c @@ -160,8 +160,8 @@ lilv_plugin_load(LilvPlugin* p) GetDataFunc get_data_func = (GetDataFunc)lilv_dlfunc( p->dynmanifest->lib, "lv2_dyn_manifest_get_data"); if (get_data_func) { - serd_env_set_base_uri( - env, sord_node_to_serd_node(p->dynmanifest->bundle->val.uri_val)); + const SordNode* bundle = p->dynmanifest->bundle->val.uri_val; + serd_env_set_base_uri(env, sord_node_to_serd_node(bundle)); FILE* fd = tmpfile(); get_data_func(p->dynmanifest->handle, fd, lilv_node_as_string(p->plugin_uri)); @@ -238,7 +238,8 @@ lilv_plugin_load_ports_if_necessary(const LilvPlugin* const_p) if (p->num_ports > this_index) { this_port = p->ports[this_index]; } else { - p->ports = realloc(p->ports, (this_index + 1) * sizeof(LilvPort*)); + p->ports = realloc(p->ports, + (this_index + 1) * sizeof(LilvPort*)); memset(p->ports + p->num_ports, '\0', (this_index - p->num_ports) * sizeof(LilvPort*)); p->num_ports = this_index + 1; @@ -372,11 +373,11 @@ lilv_plugin_get_class(const LilvPlugin* const_p) LilvNode* class = lilv_node_new_from_node(p->world, class_node); if (!lilv_node_equals(class, p->world->lv2_plugin_class->uri)) { - const LilvPluginClass* plugin_class = lilv_plugin_classes_get_by_uri( + const LilvPluginClass* pclass = lilv_plugin_classes_get_by_uri( p->world->plugin_classes, class); - if (plugin_class) { - ((LilvPlugin*)p)->plugin_class = plugin_class; + if (pclass) { + ((LilvPlugin*)p)->plugin_class = pclass; lilv_node_free(class); break; } @@ -626,7 +627,8 @@ lilv_plugin_has_feature(const LilvPlugin* p, { LilvNodes* features = lilv_plugin_get_supported_features(p); - const bool ret = features && feature && lilv_nodes_contains(features, feature); + const bool ret = (features && feature + && lilv_nodes_contains(features, feature)); lilv_nodes_free(features); return ret; @@ -657,14 +659,16 @@ LILV_API LilvNodes* lilv_plugin_get_optional_features(const LilvPlugin* p) { - return lilv_plugin_get_value_internal(p, p->world->uris.lv2_optionalFeature); + return lilv_plugin_get_value_internal( + p, p->world->uris.lv2_optionalFeature); } LILV_API LilvNodes* lilv_plugin_get_required_features(const LilvPlugin* p) { - return lilv_plugin_get_value_internal(p, p->world->uris.lv2_requiredFeature); + return lilv_plugin_get_value_internal( + p, p->world->uris.lv2_requiredFeature); } LILV_API @@ -814,9 +818,10 @@ lilv_plugin_get_uis(const LilvPlugin* p) NULL); FOREACH_MATCH(uis) { - const SordNode* ui = lilv_match_object(uis); - LilvNode* type = lilv_plugin_get_unique(p, ui, p->world->uris.rdf_a); - LilvNode* binary = lilv_plugin_get_unique(p, ui, ui_binary_node); + const SordNode* ui = lilv_match_object(uis); + + LilvNode* type = lilv_plugin_get_unique(p, ui, p->world->uris.rdf_a); + LilvNode* binary = lilv_plugin_get_unique(p, ui, ui_binary_node); if (sord_node_get_type(ui) != SORD_URI || !lilv_node_is_uri(type) diff --git a/src/query.c b/src/query.c index d8d4ea7..68c08b4 100644 --- a/src/query.c +++ b/src/query.c @@ -82,7 +82,9 @@ lilv_nodes_from_stream_objects_i18n(LilvWorld* world, partial = value; } } else { - zix_tree_insert(values, lilv_node_new_from_node(world, value), NULL); + zix_tree_insert(values, + lilv_node_new_from_node(world, value), + NULL); } } lilv_match_end(stream); diff --git a/src/state.c b/src/state.c index 0f5136b..500cd8e 100644 --- a/src/state.c +++ b/src/state.c @@ -209,7 +209,7 @@ abstract_path(LV2_State_Map_Path_Handle handle, lilv_copy_file(real_path, copy); } real_path = copy; - + // Refer to the latest copy in plugin state path = lilv_strdup(copy + file_dir_len + 1); } else { @@ -318,7 +318,8 @@ lilv_state_new_from_instance(const LilvPlugin* plugin, : NULL; if (iface) { - iface->save(instance->lv2_handle, store_callback, state, flags, features); + iface->save(instance->lv2_handle, store_callback, + state, flags, features); } #endif // HAVE_LV2_STATE @@ -339,9 +340,12 @@ lilv_state_restore(const LilvState* state, const LV2_Feature *const * features) { #ifdef HAVE_LV2_STATE - LV2_State_Map_Path map_path = { (LilvState*)state, abstract_path, absolute_path }; - LV2_Feature feature = { LV2_STATE_MAP_PATH_URI, &map_path }; - + LV2_State_Map_Path map_path = { (LilvState*)state, + abstract_path, + absolute_path }; + + LV2_Feature feature = { LV2_STATE_MAP_PATH_URI, &map_path }; + const LV2_Feature** local_features = add_feature(features, &feature); features = local_features; @@ -369,7 +373,7 @@ lilv_state_restore(const LilvState* state, } static SordNode* -get_one(SordModel* model, const SordNode* s, const SordNode* p) +get1(SordModel* model, const SordNode* s, const SordNode* p) { const SordQuad pat = { s, p, NULL, NULL }; SordIter* const i = sord_find(model, pat); @@ -474,9 +478,9 @@ new_state_from_model(LilvWorld* world, SordIter* ports = sord_find(model, ppat); FOREACH_MATCH(ports) { const SordNode* port = lilv_match_object(ports); - const SordNode* label = get_one(model, port, world->uris.rdfs_label); - const SordNode* symbol = get_one(model, port, world->uris.lv2_symbol); - const SordNode* value = get_one(model, port, world->uris.pset_value); + const SordNode* label = get1(model, port, world->uris.rdfs_label); + const SordNode* symbol = get1(model, port, world->uris.lv2_symbol); + const SordNode* value = get1(model, port, world->uris.pset_value); if (!symbol) { LILV_ERRORF("State `%s' port missing symbol.\n", sord_node_get_string(node)); @@ -504,7 +508,7 @@ new_state_from_model(LilvWorld* world, // Get properties SordNode* statep = sord_new_uri(world->world, USTR(NS_STATE "state")); - const SordNode* state_node = get_one(model, node, statep); + const SordNode* state_node = get1(model, node, statep); if (state_node) { const SordQuad spat = { state_node, NULL, NULL }; SordIter* props = sord_find(model, spat); @@ -521,14 +525,15 @@ new_state_from_model(LilvWorld* world, (const char*)sord_node_get_string(p)); if (sord_node_get_type(o) == SORD_BLANK) { - const SordNode* type = get_one(model, o, world->uris.rdf_a); - const SordNode* value = get_one(model, o, world->uris.rdf_value); + const SordNode* type = get1(model, o, world->uris.rdf_a); + const SordNode* value = get1(model, o, world->uris.rdf_value); if (type && value) { size_t len; - const uint8_t* b64 = sord_node_get_string_counted(value, &len); + const uint8_t* b64 = sord_node_get_string_counted( + value, &len); prop.value = serd_base64_decode(b64, len, &prop.size); - prop.type = map->map(map->handle, - (const char*)sord_node_get_string(type)); + prop.type = map->map( + map->handle, (const char*)sord_node_get_string(type)); } else { LILV_ERRORF("Unable to parse blank node property <%s>\n", sord_node_get_string(p)); @@ -553,7 +558,6 @@ new_state_from_model(LilvWorld* world, state->props, (++state->num_props) * sizeof(Property)); state->props[state->num_props - 1] = prop; } - } sord_iter_free(props); } @@ -921,7 +925,7 @@ lilv_state_save(LilvWorld* world, i != zix_tree_end(state->abs2rel); i = zix_tree_iter_next(i)) { const PathMap* pm = (const PathMap*)zix_tree_get(i); - + char* real_dir = lilv_strjoin(lilv_realpath(dir), "/", NULL); char* rel_path = lilv_path_join(dir, pm->rel); char* target_path = lilv_path_is_child(pm->abs, state->file_dir) @@ -943,7 +947,6 @@ lilv_state_save(LilvWorld* world, p = serd_node_from_string(SERD_URI, USTR(NS_STATE "state")); serd_writer_write_statement(writer, SERD_ANON_O_BEGIN, NULL, &subject, &p, &state_node, NULL, NULL); - } for (uint32_t i = 0; i < state->num_props; ++i) { Property* prop = &state->props[i]; @@ -973,7 +976,7 @@ lilv_state_save(LilvWorld* world, serd_writer_write_statement( writer, SERD_ANON_CONT, NULL, &state_node, &p, &o, &t, NULL); -#endif +#endif } else { char name[16]; snprintf(name, sizeof(name), "b%u", i); @@ -992,7 +995,8 @@ lilv_state_save(LilvWorld* world, &blank, &p, &o, NULL, NULL); // rdf:value "string"^^ - SerdNode blob = serd_node_new_blob(prop->value, prop->size, true); + SerdNode blob = serd_node_new_blob( + prop->value, prop->size, true); p = serd_node_from_string(SERD_URI, USTR(LILV_NS_RDF "value")); t = serd_node_from_string(SERD_URI, USTR(LILV_NS_XSD "base64Binary")); diff --git a/src/util.c b/src/util.c index 3857b9c..12821ff 100644 --- a/src/util.c +++ b/src/util.c @@ -309,8 +309,8 @@ update_latest(const char* path, const char* name, void* data) if (entry_path != latest->latest) { free(entry_path); } -} - +} + /** Return the latest copy of the file at @c path that is newer. */ char* lilv_get_latest_copy(const char* path) diff --git a/src/world.c b/src/world.c index 4909dac..0c8b734 100644 --- a/src/world.c +++ b/src/world.c @@ -319,7 +319,8 @@ lilv_world_add_plugin(LilvWorld* world, { LilvNode* plugin_uri = lilv_node_new_from_node(world, plugin_node); - const LilvPlugin* last = lilv_plugins_get_by_uri(world->plugins, plugin_uri); + const LilvPlugin* last = lilv_plugins_get_by_uri(world->plugins, + plugin_uri); if (last) { LILV_ERRORF("Duplicate plugin <%s>\n", lilv_node_as_uri(plugin_uri)); LILV_ERRORF("... found in %s\n", lilv_node_as_string( @@ -415,16 +416,17 @@ lilv_world_load_dyn_manifest(LilvWorld* world, // Open library void* lib = dlopen(lib_path, RTLD_LAZY); if (!lib) { - LILV_ERRORF("Failed to open dynamic manifest library `%s'\n", lib_path); + LILV_ERRORF("Failed to open dynmanifest library `%s'\n", lib_path); lilv_match_end(binaries); continue; } // Open dynamic manifest - typedef int (*OpenFunc)(LV2_Dyn_Manifest_Handle*, const LV2_Feature *const *); - OpenFunc open_func = (OpenFunc)lilv_dlfunc(lib, "lv2_dyn_manifest_open"); - if (!open_func || open_func(&handle, &dman_features)) { - LILV_ERRORF("Failed to find `lv2_dyn_manifest_open' in `%s'\n", lib_path); + typedef int (*OpenFunc)(LV2_Dyn_Manifest_Handle*, + const LV2_Feature *const *); + OpenFunc dmopen = (OpenFunc)lilv_dlfunc(lib, "lv2_dyn_manifest_open"); + if (!dmopen || dmopen(&handle, &dman_features)) { + LILV_ERRORF("No `lv2_dyn_manifest_open' in `%s'\n", lib_path); lilv_match_end(binaries); dlclose(lib); continue; @@ -435,7 +437,7 @@ lilv_world_load_dyn_manifest(LilvWorld* world, GetSubjectsFunc get_subjects_func = (GetSubjectsFunc)lilv_dlfunc( lib, "lv2_dyn_manifest_get_subjects"); if (!get_subjects_func) { - LILV_ERRORF("Failed to find `lv2_dyn_manifest_get_subjects' in `%s'\n", + LILV_ERRORF("No `lv2_dyn_manifest_get_subjects' in `%s'\n", lib_path); lilv_match_end(binaries); dlclose(lib); -- cgit v1.2.1