diff options
author | David Robillard <d@drobilla.net> | 2022-03-12 18:42:45 -0500 |
---|---|---|
committer | David Robillard <d@drobilla.net> | 2022-03-12 18:42:45 -0500 |
commit | 14864d01399daa6b76e443b3ffddd90a6c5f678d (patch) | |
tree | b6df026125d7651eaf525420168ffb07440cfef3 /src | |
parent | b590c510015db3b3ff8201c557c51c38d26c9982 (diff) | |
download | lilv-14864d01399daa6b76e443b3ffddd90a6c5f678d.tar.gz lilv-14864d01399daa6b76e443b3ffddd90a6c5f678d.tar.bz2 lilv-14864d01399daa6b76e443b3ffddd90a6c5f678d.zip |
fixup! WIP: Port to serd1
Diffstat (limited to 'src')
-rw-r--r-- | src/.clang-tidy | 33 | ||||
-rw-r--r-- | src/filesystem.c | 2 | ||||
-rw-r--r-- | src/plugin.c | 9 | ||||
-rw-r--r-- | src/query.c | 2 | ||||
-rw-r--r-- | src/state.c | 7 | ||||
-rw-r--r-- | src/util.c | 3 | ||||
-rw-r--r-- | src/world.c | 21 |
7 files changed, 54 insertions, 23 deletions
diff --git a/src/.clang-tidy b/src/.clang-tidy new file mode 100644 index 0000000..c9df96c --- /dev/null +++ b/src/.clang-tidy @@ -0,0 +1,33 @@ +Checks: > + *, + -*-else-after-return, + -*-magic-numbers, + -*-narrowing-conversions, + -*-uppercase-literal-suffix, + -altera-*, + -android-cloexec-fopen, + -bugprone-branch-clone, + -bugprone-easily-swappable-parameters, + -bugprone-macro-parentheses, + -bugprone-not-null-terminated-result, + -bugprone-reserved-identifier, + -bugprone-suspicious-string-compare, + -cert-dcl37-c, + -cert-dcl51-cpp, + -cert-err34-c, + -clang-analyzer-valist.Uninitialized, + -concurrency-mt-unsafe, + -cppcoreguidelines-init-variables, + -google-readability-todo, + -hicpp-multiway-paths-covered, + -hicpp-signed-bitwise, + -llvm-header-guard, + -llvmlibc-*, + -misc-no-recursion, + -performance-no-int-to-ptr, + -readability-function-cognitive-complexity, + -readability-inconsistent-declaration-parameter-name, + -readability-suspicious-call-argument, +WarningsAsErrors: '*' +HeaderFilterRegex: '.*' +FormatStyle: file diff --git a/src/filesystem.c b/src/filesystem.c index 2b383a7..f6e6961 100644 --- a/src/filesystem.c +++ b/src/filesystem.c @@ -40,8 +40,6 @@ #endif #if USE_FLOCK && USE_FILENO -# include <sys/types.h> -# # include <sys/file.h> #endif diff --git a/src/plugin.c b/src/plugin.c index 8e2f923..15dc097 100644 --- a/src/plugin.c +++ b/src/plugin.c @@ -171,10 +171,11 @@ lilv_plugin_load(LilvPlugin* plugin) SerdModel* skel = serd_model_new(plugin->world->world, SERD_ORDER_SPO, 0u); SerdCursor* iter = serd_model_begin(prots); - for (; !serd_cursor_is_end(iter); serd_cursor_advance(iter)) { - const SerdStatement* statement = serd_cursor_get(iter); - const SerdNode* t = serd_statement_object(statement); - LilvNode* prototype = serd_node_copy(NULL, t); + for (const SerdStatement* statement = NULL; + (statement = serd_cursor_get(iter)); + serd_cursor_advance(iter)) { + const SerdNode* t = serd_statement_object(statement); + LilvNode* prototype = serd_node_copy(NULL, t); lilv_world_load_resource(plugin->world, prototype); diff --git a/src/query.c b/src/query.c index 77a9d8c..bda23c1 100644 --- a/src/query.c +++ b/src/query.c @@ -63,7 +63,7 @@ lilv_nodes_from_range_i18n(LilvWorld* world, SerdCursor* range, SerdField field) char* syslang = lilv_get_lang(); FOREACH_MATCH (s, range) { const SerdNode* value = serd_statement_node(s, field); - if (serd_node_type(value) == SERD_LITERAL) { + if (value && serd_node_type(value) == SERD_LITERAL) { const SerdNode* lang = serd_node_language(value); LilvLangMatch lm = LILV_LANG_MATCH_NONE; if (lang) { diff --git a/src/state.c b/src/state.c index 4d1b84c..4b3fa06 100644 --- a/src/state.c +++ b/src/state.c @@ -23,7 +23,6 @@ #include "zix/tree.h" #include "lv2/atom/atom.h" -#include "lv2/atom/forge.h" #include "lv2/core/lv2.h" #include "lv2/presets/presets.h" #include "lv2/state/state.h" @@ -749,9 +748,9 @@ lilv_state_new_from_world(LilvWorld* world, LV2_URID_Map* map, const LilvNode* node) { - if (!lilv_node_is_uri(node) && !lilv_node_is_blank(node)) { + if (!node || (!lilv_node_is_uri(node) && !lilv_node_is_blank(node))) { LILV_ERRORF("Subject `%s' is not a URI or blank node.\n", - lilv_node_as_string(node)); + node ? lilv_node_as_string(node) : "(null)"); return NULL; } @@ -1435,7 +1434,7 @@ lilv_state_delete(LilvWorld* world, const LilvState* state) } } else { // Still something in the manifest, update and reload bundle - SerdEnv* env = serd_env_new(NULL, serd_node_string_view(manifest)); + SerdEnv* env = serd_env_new(world->world, serd_node_string_view(manifest)); if (write_manifest(world, env, model, manifest)) { return 1; @@ -18,10 +18,8 @@ #include "lilv_internal.h" #include "lilv/lilv.h" -#include "serd/serd.h" #include <sys/stat.h> -#include <sys/types.h> #include <ctype.h> #include <errno.h> @@ -30,6 +28,7 @@ #include <stdio.h> #include <stdlib.h> #include <string.h> +#include <time.h> void lilv_free(void* ptr) diff --git a/src/world.c b/src/world.c index 9083845..19522ae 100644 --- a/src/world.c +++ b/src/world.c @@ -264,12 +264,13 @@ lilv_world_filter_model(LilvWorld* world, const SerdNode* graph) { SerdModel* results = serd_model_new(world->world, SERD_ORDER_SPO, 0u); - SerdCursor* r = serd_model_find(model, subject, predicate, object, graph); - for (; !serd_cursor_is_end(r); serd_cursor_advance(r)) { - serd_model_insert(results, serd_cursor_get(r)); + SerdCursor* i = serd_model_find(model, subject, predicate, object, graph); + for (const SerdStatement* s; (s = serd_cursor_get(i)); + serd_cursor_advance(i)) { + serd_model_insert(results, s); } - serd_cursor_free(r); + serd_cursor_free(i); return results; } @@ -727,6 +728,7 @@ lilv_world_load_bundle(LilvWorld* world, const LilvNode* bundle_uri) } // Compare versions + // FIXME: Transaction? SerdModel* this_model = load_plugin_model(world, bundle_uri, plugin_uri); LilvVersion this_version = get_version(world, this_model, plugin_uri); SerdModel* last_model = load_plugin_model(world, last_bundle, plugin_uri); @@ -1116,17 +1118,16 @@ lilv_world_unload_resource(LilvWorld* world, const LilvNode* resource) SerdCursor* f = serd_model_begin(files); int n_dropped = 0; - for (; !serd_cursor_is_end(f); serd_cursor_advance(f)) { - const SerdNode* file = serd_statement_object(serd_cursor_get(f)); - LilvNode* file_node = serd_node_copy(NULL, file); + for (const SerdStatement* link = NULL; (link = serd_cursor_get(f)); + serd_cursor_advance(f)) { + const SerdNode* const file = serd_statement_object(link); if (serd_node_type(file) != SERD_URI) { LILV_ERRORF("rdfs:seeAlso node `%s' is not a URI\n", serd_node_string(file)); - } else if (!lilv_world_drop_graph(world, file_node)) { - lilv_world_unload_file(world, file_node); + } else if (!lilv_world_drop_graph(world, file)) { + lilv_world_unload_file(world, file); ++n_dropped; } - lilv_node_free(file_node); } serd_cursor_free(f); |