diff options
-rw-r--r-- | .clang-tidy | 7 | ||||
-rw-r--r-- | include/sratom/sratom.h | 1 | ||||
-rw-r--r-- | meson.build | 1 | ||||
-rw-r--r-- | src/dumper.c | 7 | ||||
-rw-r--r-- | src/loader.c | 21 | ||||
-rw-r--r-- | test/.clang-tidy | 3 |
6 files changed, 30 insertions, 10 deletions
diff --git a/.clang-tidy b/.clang-tidy index 449495e..a0f2132 100644 --- a/.clang-tidy +++ b/.clang-tidy @@ -2,6 +2,10 @@ Checks: > *, -*-magic-numbers, -*-uppercase-literal-suffix, + -altera-*, + -bugprone-easily-swappable-parameters, + -bugprone-implicit-widening-of-multiplication-result, + -bugprone-not-null-terminated-result, -bugprone-suspicious-string-compare, -cert-err34-c, -clang-analyzer-security.insecureAPI.DeprecatedOrUnsafeBufferHandling, @@ -11,6 +15,9 @@ Checks: > -llvmlibc-*, -misc-misplaced-const, -misc-no-recursion, + -narrowing-conversions, + -performance-no-int-to-ptr, + -readability-function-cognitive-complexity, WarningsAsErrors: '*' HeaderFilterRegex: '.*' FormatStyle: file diff --git a/include/sratom/sratom.h b/include/sratom/sratom.h index 6934fb8..29006f6 100644 --- a/include/sratom/sratom.h +++ b/include/sratom/sratom.h @@ -21,7 +21,6 @@ #include "lv2/atom/atom.h" #include "lv2/atom/forge.h" -#include "lv2/atom/util.h" #include "lv2/urid/urid.h" #include "serd/serd.h" diff --git a/meson.build b/meson.build index 57498a2..a8cbfc5 100644 --- a/meson.build +++ b/meson.build @@ -49,6 +49,7 @@ if get_option('strict') '-Wno-cast-align', '-Wno-cast-qual', '-Wno-conversion', + '-Wno-inline', '-Wno-padded', '-Wno-suggest-attribute=pure', '-Wno-unsuffixed-float-constants', diff --git a/src/dumper.c b/src/dumper.c index b577dff..49878d1 100644 --- a/src/dumper.c +++ b/src/dumper.c @@ -23,6 +23,7 @@ #include "lv2/urid/urid.h" #include "serd/serd.h" +#include <assert.h> #include <ctype.h> #include <stdbool.h> #include <stdint.h> @@ -30,6 +31,8 @@ #include <stdlib.h> #include <string.h> +// IWYU pragma: no_forward_declare SratomDumperImpl + #define NS_RDF "http://www.w3.org/1999/02/22-rdf-syntax-ns#" #define NS_XSD "http://www.w3.org/2001/XMLSchema#" @@ -321,7 +324,8 @@ write_atom(StreamContext* const ctx, char* const str = (char*)calloc(len + 1, 1); for (uint32_t i = 0; i < size; ++i) { snprintf(str + (2 * i), - size * 2 + 1, + size - (2 * i), + /* 3, */ "%02X", (unsigned)*((const uint8_t*)body + i)); } @@ -457,6 +461,7 @@ write_atom(StreamContext* const ctx, if (object) { if (!subject || !predicate) { const SerdNode* const blank = serd_world_get_blank(writer->world); + assert(writer->nodes.rdf_first); serd_sink_write(sink, ctx->sflags | SERD_LIST_S | SERD_TERSE_S, blank, diff --git a/src/loader.c b/src/loader.c index e23e9c5..eead3a2 100644 --- a/src/loader.c +++ b/src/loader.c @@ -23,11 +23,14 @@ #include "serd/serd.h" #include <assert.h> +#include <stdbool.h> #include <stdint.h> #include <stdio.h> #include <stdlib.h> #include <string.h> +// IWYU pragma: no_forward_declare SratomLoaderImpl + #define NS_RDF "http://www.w3.org/1999/02/22-rdf-syntax-ns#" #define NS_XSD "http://www.w3.org/2001/XMLSchema#" @@ -289,14 +292,16 @@ read_plain_literal(SratomLoader* const loader, { static const char* const prefix = "http://lexvo.org/id/iso639-3/"; - const char* const str = serd_node_string(node); - const size_t len = serd_node_length(node); - const char* lang_str = serd_node_string(language); - const size_t prefix_len = strlen(prefix); - const size_t lang_len = prefix_len + strlen(lang_str); - char* const lang_uri = (char*)calloc(lang_len + 1, 1); + const char* const str = serd_node_string(node); + const size_t len = serd_node_length(node); + const char* lang_str = serd_node_string(language); + const size_t lang_str_len = serd_node_length(language); + const size_t prefix_len = strlen(prefix); + const size_t lang_uri_len = prefix_len + lang_str_len; + char* const lang_uri = (char*)calloc(lang_uri_len + 1, 1); - snprintf(lang_uri, lang_len + 1, "%s%s", prefix, lang_str); + memcpy(lang_uri, prefix, prefix_len); + memcpy(lang_uri + prefix_len, lang_str, lang_str_len); const LV2_Atom_Forge_Ref ref = lv2_atom_forge_literal( forge, str, len, 0, loader->map->map(loader->map->handle, lang_uri)); @@ -549,7 +554,7 @@ sratom_forge_sink(const LV2_Atom_Forge_Sink_Handle handle, const uint32_t size) { SerdBuffer* const chunk = (SerdBuffer*)handle; - const LV2_Atom_Forge_Ref ref = chunk->len + 1; + const LV2_Atom_Forge_Ref ref = (LV2_Atom_Forge_Ref)(chunk->len + 1); serd_buffer_write(buf, 1, size, chunk); return ref; diff --git a/test/.clang-tidy b/test/.clang-tidy index 0b8f64b..1c1059f 100644 --- a/test/.clang-tidy +++ b/test/.clang-tidy @@ -2,11 +2,14 @@ Checks: > *, -*-magic-numbers, -*-uppercase-literal-suffix, + -altera-*, + -bugprone-implicit-widening-of-multiplication-result, -bugprone-suspicious-string-compare, -clang-analyzer-security.insecureAPI.DeprecatedOrUnsafeBufferHandling, -hicpp-signed-bitwise, -llvm-header-guard, -llvmlibc-*, + -performance-no-int-to-ptr, WarningsAsErrors: '*' HeaderFilterRegex: '.*' FormatStyle: file |