diff options
-rw-r--r-- | .clang-tidy | 6 | ||||
-rw-r--r-- | NEWS | 3 | ||||
-rw-r--r-- | include/lilv/lilvmm.hpp | 101 | ||||
-rw-r--r-- | meson/suppressions/meson.build | 3 | ||||
-rw-r--r-- | src/.clang-tidy | 5 | ||||
-rw-r--r-- | src/state.c | 7 | ||||
-rw-r--r-- | test/.clang-tidy | 3 | ||||
-rw-r--r-- | test/lilv_test_utils.h | 2 | ||||
-rw-r--r-- | test/test_plugin.lv2/meson.build | 2 | ||||
-rw-r--r-- | test/test_plugin.lv2/test_plugin.c | 50 | ||||
-rw-r--r-- | test/test_string.c | 4 |
11 files changed, 73 insertions, 113 deletions
diff --git a/.clang-tidy b/.clang-tidy index aa54c19..b695c4f 100644 --- a/.clang-tidy +++ b/.clang-tidy @@ -1,18 +1,20 @@ -# Copyright 2020-2023 David Robillard <d@drobilla.net> +# Copyright 2020-2024 David Robillard <d@drobilla.net> # SPDX-License-Identifier: 0BSD OR ISC Checks: > *, + -*-macro-to-enum, -*-vararg, -altera-*, -bugprone-assignment-in-if-condition, -bugprone-easily-swappable-parameters, -bugprone-macro-parentheses, + -bugprone-multi-level-implicit-pointer-conversion, -bugprone-suspicious-realloc-usage, -clang-diagnostic-unused-function, -clang-diagnostic-unused-macros, -llvmlibc-*, - -modernize-macro-to-enum, + -misc-include-cleaner, -readability-identifier-length, CheckOptions: - key: hicpp-uppercase-literal-suffix.NewSuffixes @@ -2,8 +2,9 @@ lilv (0.24.25) unstable; urgency=medium * Fix C++ test build on MacOS * Fix library current_version on MacOS + * Fix test suite when TMPDIR has no trailing slash - -- David Robillard <d@drobilla.net> Fri, 15 Mar 2024 16:42:11 +0000 + -- David Robillard <d@drobilla.net> Sat, 16 Mar 2024 13:51:02 +0000 lilv (0.24.24) stable; urgency=medium diff --git a/include/lilv/lilvmm.hpp b/include/lilv/lilvmm.hpp index 6e270df..810187f 100644 --- a/include/lilv/lilvmm.hpp +++ b/include/lilv/lilvmm.hpp @@ -100,15 +100,15 @@ uri_to_path(const char* uri) #endif struct Node { - inline Node(const LilvNode* node) + Node(const LilvNode* node) : me(lilv_node_duplicate(node)) {} - inline Node(const Node& copy) + Node(const Node& copy) : me(lilv_node_duplicate(copy.me)) {} - inline Node& operator=(const Node& rhs) + Node& operator=(const Node& rhs) { if (&rhs != this) { lilv_node_free(me); @@ -117,13 +117,13 @@ struct Node { return *this; } - inline Node(Node&& other) noexcept + Node(Node&& other) noexcept : me(other.me) { other.me = nullptr; } - inline Node& operator=(Node&& rhs) noexcept + Node& operator=(Node&& rhs) noexcept { if (&rhs != this) { me = rhs.me; @@ -132,14 +132,14 @@ struct Node { return *this; } - inline ~Node() { lilv_node_free(me); } + ~Node() { lilv_node_free(me); } - inline bool equals(const Node& other) const + bool equals(const Node& other) const { return lilv_node_equals(me, other.me); } - inline bool operator==(const Node& other) const { return equals(other); } + bool operator==(const Node& other) const { return equals(other); } LILV_WRAP_CONVERSION(LilvNode) @@ -162,7 +162,7 @@ struct Node { }; struct ScalePoint { - inline ScalePoint(const LilvScalePoint* c_obj) + ScalePoint(const LilvScalePoint* c_obj) : me(c_obj) {} @@ -175,7 +175,7 @@ struct ScalePoint { }; struct PluginClass { - inline PluginClass(const LilvPluginClass* c_obj) + PluginClass(const LilvPluginClass* c_obj) : me(c_obj) {} @@ -217,7 +217,7 @@ struct Nodes { }; struct UI { - inline UI(const LilvUI* c_obj) + UI(const LilvUI* c_obj) : me(c_obj) {} @@ -241,24 +241,18 @@ struct UIs { }; struct Port { - inline Port(const LilvPlugin* p, const LilvPort* c_obj) + Port(const LilvPlugin* p, const LilvPort* c_obj) : parent(p) , me(c_obj) {} LILV_WRAP_CONVERSION(const LilvPort) -#define LILV_PORT_WRAP0(RT, name) \ - inline RT name() \ - { \ - return lilv_port_##name(parent, me); \ - } +#define LILV_PORT_WRAP0(RT, name) \ + inline RT name() { return lilv_port_##name(parent, me); } -#define LILV_PORT_WRAP1(RT, name, T1, a1) \ - inline RT name(T1 a1) \ - { \ - return lilv_port_##name(parent, me, a1); \ - } +#define LILV_PORT_WRAP1(RT, name, T1, a1) \ + inline RT name(T1 a1) { return lilv_port_##name(parent, me, a1); } LILV_PORT_WRAP1(LilvNodes*, get_value, LilvNode*, predicate) LILV_PORT_WRAP0(LilvNodes*, get_properties) @@ -277,7 +271,7 @@ struct Port { }; struct Plugin { - inline Plugin(const LilvPlugin* c_obj) + Plugin(const LilvPlugin* c_obj) : me(c_obj) {} @@ -306,25 +300,24 @@ struct Plugin { LILV_WRAP0(UIs, plugin, get_uis) LILV_WRAP1(Nodes, plugin, get_related, const Node&, type) - inline Port get_port_by_index(unsigned index) const + Port get_port_by_index(unsigned index) const { return Port(me, lilv_plugin_get_port_by_index(me, index)); } - inline Port get_port_by_symbol(LilvNode* symbol) const + Port get_port_by_symbol(LilvNode* symbol) const { return Port(me, lilv_plugin_get_port_by_symbol(me, symbol)); } - inline void get_port_ranges_float(float* min_values, - float* max_values, - float* def_values) const + void get_port_ranges_float(float* min_values, + float* max_values, + float* def_values) const { - return lilv_plugin_get_port_ranges_float( - me, min_values, max_values, def_values); + lilv_plugin_get_port_ranges_float(me, min_values, max_values, def_values); } - inline unsigned get_num_ports_of_class(LilvNode* class_1, ...) const + unsigned get_num_ports_of_class(LilvNode* class_1, ...) const { va_list args; // NOLINT(cppcoreguidelines-init-variables) va_start(args, class_1); @@ -345,25 +338,23 @@ struct Plugins { }; struct Instance { - inline Instance(LilvInstance* instance) + Instance(LilvInstance* instance) : me(instance) {} LILV_DEPRECATED - inline Instance(Plugin plugin, double sample_rate) + Instance(Plugin plugin, double sample_rate) : me(lilv_plugin_instantiate(plugin, sample_rate, nullptr)) {} LILV_DEPRECATED - inline Instance(Plugin plugin, - double sample_rate, - LV2_Feature* const* features) + Instance(Plugin plugin, double sample_rate, LV2_Feature* const* features) : me(lilv_plugin_instantiate(plugin, sample_rate, features)) {} - static inline Instance* create(Plugin plugin, - double sample_rate, - LV2_Feature* const* features) + static Instance* create(Plugin plugin, + double sample_rate, + LV2_Feature* const* features) { LilvInstance* me = lilv_plugin_instantiate(plugin, sample_rate, features); @@ -383,27 +374,27 @@ struct Instance { LILV_WRAP1_VOID(instance, run, unsigned, sample_count) LILV_WRAP0_VOID(instance, deactivate) - inline const void* get_extension_data(const char* uri) const + const void* get_extension_data(const char* uri) const { return lilv_instance_get_extension_data(me, uri); } - inline const LV2_Descriptor* get_descriptor() const + const LV2_Descriptor* get_descriptor() const { return lilv_instance_get_descriptor(me); } - inline LV2_Handle get_handle() const { return lilv_instance_get_handle(me); } + LV2_Handle get_handle() const { return lilv_instance_get_handle(me); } LilvInstance* me; }; struct World { - inline World() + World() : me(lilv_world_new()) {} - inline ~World() { lilv_world_free(me); } + ~World() { lilv_world_free(me); } World(const World&) = delete; World& operator=(const World&) = delete; @@ -411,28 +402,22 @@ struct World { World(World&&) = delete; World& operator=(World&&) = delete; - inline LilvNode* new_uri(const char* uri) const - { - return lilv_new_uri(me, uri); - } + LilvNode* new_uri(const char* uri) const { return lilv_new_uri(me, uri); } - inline LilvNode* new_string(const char* str) const + LilvNode* new_string(const char* str) const { return lilv_new_string(me, str); } - inline LilvNode* new_int(int val) const { return lilv_new_int(me, val); } + LilvNode* new_int(int val) const { return lilv_new_int(me, val); } - inline LilvNode* new_float(float val) const - { - return lilv_new_float(me, val); - } + LilvNode* new_float(float val) const { return lilv_new_float(me, val); } - inline LilvNode* new_bool(bool val) const { return lilv_new_bool(me, val); } + LilvNode* new_bool(bool val) const { return lilv_new_bool(me, val); } - inline Nodes find_nodes(const LilvNode* subject, - const LilvNode* predicate, - const LilvNode* object) const + Nodes find_nodes(const LilvNode* subject, + const LilvNode* predicate, + const LilvNode* object) const { return lilv_world_find_nodes(me, subject, predicate, object); } diff --git a/meson/suppressions/meson.build b/meson/suppressions/meson.build index d05af9e..2f19537 100644 --- a/meson/suppressions/meson.build +++ b/meson/suppressions/meson.build @@ -1,4 +1,4 @@ -# Copyright 2020-2023 David Robillard <d@drobilla.net> +# Copyright 2020-2024 David Robillard <d@drobilla.net> # SPDX-License-Identifier: 0BSD OR ISC # Project-specific warning suppressions @@ -28,6 +28,7 @@ if cc.get_id() in ['clang', 'emscripten'] '-Wno-reserved-id-macro', '-Wno-shorten-64-to-32', '-Wno-sign-conversion', + '-Wno-switch-default', '-Wno-switch-enum', '-Wno-unsafe-buffer-usage', '-Wno-vla', diff --git a/src/.clang-tidy b/src/.clang-tidy index 0673649..6fc648d 100644 --- a/src/.clang-tidy +++ b/src/.clang-tidy @@ -1,4 +1,4 @@ -# Copyright 2020-2022 David Robillard <d@drobilla.net> +# Copyright 2020-2024 David Robillard <d@drobilla.net> # SPDX-License-Identifier: 0BSD OR ISC Checks: > @@ -7,6 +7,7 @@ Checks: > -bugprone-narrowing-conversions, -cert-err33-c, -cert-err34-c, + -clang-analyzer-optin.core.EnumCastOutOfRange, -clang-analyzer-security.insecureAPI.DeprecatedOrUnsafeBufferHandling, -clang-analyzer-valist.Uninitialized, -concurrency-mt-unsafe, @@ -16,6 +17,8 @@ Checks: > -hicpp-signed-bitwise, -llvm-header-guard, -performance-no-int-to-ptr, + -readability-avoid-nested-conditional-operator, -readability-function-cognitive-complexity, + -readability-redundant-casting, -readability-suspicious-call-argument, InheritParentConfig: true diff --git a/src/state.c b/src/state.c index 0ed5715..ddede30 100644 --- a/src/state.c +++ b/src/state.c @@ -781,15 +781,16 @@ lilv_state_new_from_file(LilvWorld* world, (subject) ? subject->node : sord_node_from_serd_node(world->world, env, &node, NULL, NULL); - const ZixStringView dirname = zix_path_parent_path(path); - char* const real_path = zix_canonical_path(NULL, dirname.data); - char* const dir_path = zix_path_join(NULL, real_path, NULL); + char* const dirname = zix_string_view_copy(NULL, zix_path_parent_path(path)); + char* const real_path = zix_canonical_path(NULL, dirname); + char* const dir_path = zix_path_join(NULL, real_path, NULL); LilvState* const state = new_state_from_model(world, map, model, subject_node, dir_path); zix_free(NULL, dir_path); zix_free(NULL, real_path); + zix_free(NULL, dirname); serd_node_free(&node); zix_free(NULL, abs_path); diff --git a/test/.clang-tidy b/test/.clang-tidy index f6f74ab..729db52 100644 --- a/test/.clang-tidy +++ b/test/.clang-tidy @@ -1,9 +1,10 @@ -# Copyright 2020-2022 David Robillard <d@drobilla.net> +# Copyright 2020-2024 David Robillard <d@drobilla.net> # SPDX-License-Identifier: 0BSD OR ISC Checks: > -*-magic-numbers, -android-cloexec-fopen, + -bugprone-assert-side-effect, -bugprone-branch-clone, -bugprone-narrowing-conversions, -cert-err33-c, diff --git a/test/lilv_test_utils.h b/test/lilv_test_utils.h index f01b5b4..73ee2ba 100644 --- a/test/lilv_test_utils.h +++ b/test/lilv_test_utils.h @@ -5,6 +5,7 @@ #define LILV_TEST_UTILS_H #include "lilv/lilv.h" +#include "zix/attributes.h" #define MANIFEST_PREFIXES \ "\ @@ -80,6 +81,7 @@ void set_env(const char* name, const char* value); // Create a unique temporary directory +ZIX_MALLOC_FUNC char* lilv_create_temporary_directory(const char* pattern); diff --git a/test/test_plugin.lv2/meson.build b/test/test_plugin.lv2/meson.build index 9b74245..e6c54cf 100644 --- a/test/test_plugin.lv2/meson.build +++ b/test/test_plugin.lv2/meson.build @@ -5,7 +5,7 @@ module = shared_module( 'test_plugin', files('test_plugin.c'), c_args: c_suppressions, - dependencies: lv2_dep, + dependencies: [lv2_dep, zix_dep], gnu_symbol_visibility: 'hidden', name_prefix: '', ) diff --git a/test/test_plugin.lv2/test_plugin.c b/test/test_plugin.lv2/test_plugin.c index cb89136..124f64c 100644 --- a/test/test_plugin.lv2/test_plugin.c +++ b/test/test_plugin.lv2/test_plugin.c @@ -5,11 +5,8 @@ #include "lv2/core/lv2.h" #include "lv2/state/state.h" #include "lv2/urid/urid.h" - -#ifdef _WIN32 -# define WIN32_LEAN_AND_MEAN -# include <windows.h> -#endif +#include "zix/filesystem.h" +#include "zix/path.h" #include <stdint.h> #include <stdio.h> @@ -37,35 +34,6 @@ typedef struct { unsigned num_runs; } Test; -static char* -temp_directory_path(void) -{ -#ifdef _WIN32 - const DWORD len = GetTempPath(0, NULL); - char* const buf = (char*)calloc(len, 1); - if (GetTempPath(len, buf) == 0) { - free(buf); - return NULL; - } - - return buf; -#else - const char* const tmpdir = getenv("TMPDIR"); - if (tmpdir) { - const size_t tmpdir_len = strlen(tmpdir); - char* const result = (char*)calloc(tmpdir_len + 1, 1); - - memcpy(result, tmpdir, tmpdir_len + 1); - return result; - } - - char* const result = (char*)calloc(6, 1); - - memcpy(result, "/tmp/", 6); - return result; -#endif -} - static void cleanup(LV2_Handle instance) { @@ -116,7 +84,7 @@ instantiate(const LV2_Descriptor* descriptor, return NULL; } - test->tmp_dir_path = temp_directory_path(); + test->tmp_dir_path = zix_temp_directory_path(NULL); LV2_State_Make_Path* make_path = NULL; @@ -284,14 +252,10 @@ save(LV2_Handle instance, LV2_STATE_IS_POD | LV2_STATE_IS_PORTABLE); if (map_path) { - const char* const file_name = "temp_file.txt"; - const size_t file_name_len = strlen(file_name); - const size_t dir_path_len = strlen(plugin->tmp_dir_path); - char* const tmp_file_path = - (char*)calloc(dir_path_len + file_name_len + 1, 1); - - memcpy(tmp_file_path, plugin->tmp_dir_path, dir_path_len); - memcpy(tmp_file_path + dir_path_len, file_name, file_name_len + 1); + const char* const file_name = "temp_file.txt"; + + char* const tmp_file_path = + zix_path_join(NULL, plugin->tmp_dir_path, file_name); FILE* file = fopen(tmp_file_path, "w"); if (!file) { diff --git a/test/test_string.c b/test/test_string.c index 48021ed..028b7da 100644 --- a/test/test_string.c +++ b/test/test_string.c @@ -21,10 +21,10 @@ main(void) #ifndef _WIN32 char* s = NULL; - const char* const home = getenv("HOME"); - setenv("LILV_TEST_1", "test", 1); + const char* const home = getenv("HOME"); + assert(!strcmp((s = lilv_expand("$LILV_TEST_1")), "test")); free(s); if (home) { |