diff options
-rw-r--r-- | .clang-tidy | 1 | ||||
-rw-r--r-- | .gitlab-ci.yml | 2 | ||||
-rw-r--r-- | include/lv2/atom/atom.h | 4 | ||||
-rw-r--r-- | include/lv2/atom/util.h | 2 | ||||
-rw-r--r-- | include/lv2/event/event-helpers.h | 3 | ||||
-rw-r--r-- | include/lv2/ui/ui.h | 2 | ||||
-rw-r--r-- | meson_options.txt | 6 | ||||
-rw-r--r-- | plugins/eg-amp.lv2/amp.c | 2 | ||||
-rw-r--r-- | plugins/eg-fifths.lv2/fifths.c | 4 | ||||
-rw-r--r-- | plugins/eg-params.lv2/params.c | 2 | ||||
-rw-r--r-- | plugins/eg-sampler.lv2/sampler.c | 8 | ||||
-rw-r--r-- | plugins/eg-sampler.lv2/sampler_ui.c | 2 | ||||
-rw-r--r-- | plugins/eg-sampler.lv2/uris.h | 2 | ||||
-rw-r--r-- | plugins/eg-scope.lv2/examploscope.c | 10 | ||||
-rw-r--r-- | plugins/eg-scope.lv2/examploscope_ui.c | 16 | ||||
-rw-r--r-- | test/atom_test_utils.c | 10 | ||||
-rw-r--r-- | test/headers/.clang-tidy | 1 | ||||
-rw-r--r-- | test/test_atom.c | 10 |
18 files changed, 46 insertions, 41 deletions
diff --git a/.clang-tidy b/.clang-tidy index 5279051..4033a55 100644 --- a/.clang-tidy +++ b/.clang-tidy @@ -7,7 +7,6 @@ Checks: > -*-magic-numbers, -altera-*, -bugprone-assignment-in-if-condition, - -bugprone-casting-through-void, -bugprone-easily-swappable-parameters, -bugprone-macro-parentheses, -clang-diagnostic-unused-function, diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index f4f6be7..a67a043 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -138,4 +138,4 @@ pages: paths: - public only: - - master + - main diff --git a/include/lv2/atom/atom.h b/include/lv2/atom/atom.h index ca607d3..41af21a 100644 --- a/include/lv2/atom/atom.h +++ b/include/lv2/atom/atom.h @@ -68,13 +68,13 @@ extern "C" { @param type The type of the atom, for example LV2_Atom_String. @param atom A variable-sized atom. */ -#define LV2_ATOM_CONTENTS(type, atom) ((void*)((uint8_t*)(atom) + sizeof(type))) +#define LV2_ATOM_CONTENTS(type, atom) ((void*)((type*)(atom) + 1U)) /** Const version of LV2_ATOM_CONTENTS. */ #define LV2_ATOM_CONTENTS_CONST(type, atom) \ - ((const void*)((const uint8_t*)(atom) + sizeof(type))) + ((const void*)((const type*)(atom) + 1U)) /** Return a pointer to the body of an Atom. The "body" of an atom is the diff --git a/include/lv2/atom/util.h b/include/lv2/atom/util.h index a2369da..b8bb295 100644 --- a/include/lv2/atom/util.h +++ b/include/lv2/atom/util.h @@ -182,7 +182,7 @@ lv2_atom_sequence_append_event(LV2_Atom_Sequence* seq, static inline LV2_Atom* lv2_atom_tuple_begin(const LV2_Atom_Tuple* tup) { - return (LV2_Atom*)(LV2_ATOM_BODY(tup)); + return (LV2_Atom*)tup + 1U; } /** Return true iff `i` has reached the end of `body`. */ diff --git a/include/lv2/event/event-helpers.h b/include/lv2/event/event-helpers.h index a9eb423..5ec9a84 100644 --- a/include/lv2/event/event-helpers.h +++ b/include/lv2/event/event-helpers.h @@ -107,7 +107,8 @@ lv2_event_increment(LV2_Event_Iterator* iter) return false; } - LV2_Event* const ev = (LV2_Event*)(iter->buf->data + iter->offset); + const LV2_Event* const ev = + (const LV2_Event*)(iter->buf->data + iter->offset); iter->offset += lv2_event_pad_size((uint16_t)((uint16_t)sizeof(LV2_Event) + ev->size)); diff --git a/include/lv2/ui/ui.h b/include/lv2/ui/ui.h index d825d76..d17edcb 100644 --- a/include/lv2/ui/ui.h +++ b/include/lv2/ui/ui.h @@ -69,7 +69,7 @@ /** The index returned by LV2UI_Port_Map::port_index() for unknown ports. */ -#define LV2UI_INVALID_PORT_INDEX ((uint32_t)-1) +#define LV2UI_INVALID_PORT_INDEX ((uint32_t)(-1)) #ifdef __cplusplus extern "C" { diff --git a/meson_options.txt b/meson_options.txt index 0a8c145..2661999 100644 --- a/meson_options.txt +++ b/meson_options.txt @@ -1,7 +1,7 @@ # Copyright 2021-2022 David Robillard <d@drobilla.net> # SPDX-License-Identifier: 0BSD OR ISC -option('docs', type: 'feature', value: 'auto', yield: true, +option('docs', type: 'feature', yield: true, description: 'Build documentation') option('lint', type: 'boolean', value: false, yield: true, @@ -16,10 +16,10 @@ option('old_headers', type: 'boolean', value: true, yield: true, option('online_docs', type: 'boolean', value: false, yield: true, description: 'Build documentation for online hosting') -option('plugins', type: 'feature', value: 'auto', yield: true, +option('plugins', type: 'feature', yield: true, description: 'Build example plugins') -option('tests', type: 'feature', value: 'auto', yield: true, +option('tests', type: 'feature', yield: true, description: 'Build tests') option('title', type: 'string', value: 'LV2', diff --git a/plugins/eg-amp.lv2/amp.c b/plugins/eg-amp.lv2/amp.c index 90a5769..9c22049 100644 --- a/plugins/eg-amp.lv2/amp.c +++ b/plugins/eg-amp.lv2/amp.c @@ -105,7 +105,7 @@ activate(LV2_Handle instance) {} /** Define a macro for converting a gain in dB to a coefficient. */ -#define DB_CO(g) ((g) > -90.0f ? powf(10.0f, (g)*0.05f) : 0.0f) +#define DB_CO(g) ((g) > -90.0f ? powf(10.0f, (g) * 0.05f) : 0.0f) /** The `run()` method is the main process function of the plugin. It processes diff --git a/plugins/eg-fifths.lv2/fifths.c b/plugins/eg-fifths.lv2/fifths.c index 9f6a388..d2400b4 100644 --- a/plugins/eg-fifths.lv2/fifths.c +++ b/plugins/eg-fifths.lv2/fifths.c @@ -90,8 +90,8 @@ cleanup(LV2_Handle instance) static void run(LV2_Handle instance, uint32_t sample_count) { - Fifths* self = (Fifths*)instance; - FifthsURIs* uris = &self->uris; + Fifths* self = (Fifths*)instance; + const FifthsURIs* uris = &self->uris; // Struct for a 3 byte MIDI event, used for writing notes typedef struct { diff --git a/plugins/eg-params.lv2/params.c b/plugins/eg-params.lv2/params.c index af96fc8..742c48b 100644 --- a/plugins/eg-params.lv2/params.c +++ b/plugins/eg-params.lv2/params.c @@ -320,7 +320,7 @@ save(LV2_Handle instance, LV2_State_Status st = LV2_STATE_SUCCESS; for (unsigned i = 0; i < N_PROPS; ++i) { - StateMapItem* prop = &self->props[i]; + const StateMapItem* prop = &self->props[i]; store_prop(self, map_path, &st, store, handle, prop->urid, prop->value); } diff --git a/plugins/eg-sampler.lv2/sampler.c b/plugins/eg-sampler.lv2/sampler.c index d870a07..4c5a92a 100644 --- a/plugins/eg-sampler.lv2/sampler.c +++ b/plugins/eg-sampler.lv2/sampler.c @@ -249,9 +249,9 @@ work(LV2_Handle instance, static LV2_Worker_Status work_response(LV2_Handle instance, uint32_t size, const void* data) { - Sampler* self = (Sampler*)instance; - Sample* old_sample = self->sample; - Sample* new_sample = *(Sample* const*)data; + Sampler* self = (Sampler*)instance; + Sample* old_sample = self->sample; + const Sample* new_sample = *(Sample* const*)data; // Install the new sample self->sample = *(Sample* const*)data; @@ -353,7 +353,7 @@ deactivate(LV2_Handle instance) } /** Define a macro for converting a gain in dB to a coefficient. */ -#define DB_CO(g) ((g) > -90.0f ? powf(10.0f, (g)*0.05f) : 0.0f) +#define DB_CO(g) ((g) > -90.0f ? powf(10.0f, (g) * 0.05f) : 0.0f) /** Handle an incoming event in the audio thread. diff --git a/plugins/eg-sampler.lv2/sampler_ui.c b/plugins/eg-sampler.lv2/sampler_ui.c index 16a8c71..fc879eb 100644 --- a/plugins/eg-sampler.lv2/sampler_ui.c +++ b/plugins/eg-sampler.lv2/sampler_ui.c @@ -421,7 +421,7 @@ ui_hide(LV2UI_Handle handle) static int ui_idle(LV2UI_Handle handle) { - SamplerUI* ui = (SamplerUI*)handle; + const SamplerUI* ui = (const SamplerUI*)handle; if (ui->window) { gtk_main_iteration_do(false); } diff --git a/plugins/eg-sampler.lv2/uris.h b/plugins/eg-sampler.lv2/uris.h index f934390..3d3ac10 100644 --- a/plugins/eg-sampler.lv2/uris.h +++ b/plugins/eg-sampler.lv2/uris.h @@ -164,7 +164,7 @@ read_set_file(const SamplerURIs* uris, const LV2_Atom_Object* obj) return NULL; } - return (const char*)LV2_ATOM_BODY_CONST(value); + return (const char*)&value[1]; } #endif /* SAMPLER_URIS_H */ diff --git a/plugins/eg-scope.lv2/examploscope.c b/plugins/eg-scope.lv2/examploscope.c index e3bb53b..918fca2 100644 --- a/plugins/eg-scope.lv2/examploscope.c +++ b/plugins/eg-scope.lv2/examploscope.c @@ -169,11 +169,11 @@ connect_port(LV2_Handle handle, uint32_t port, void* data) http://lv2plug.in/ns/ext/atom#Float[Float]. */ static void -tx_rawaudio(LV2_Atom_Forge* forge, - ScoLV2URIs* uris, - const int32_t channel, - const size_t n_samples, - const float* data) +tx_rawaudio(LV2_Atom_Forge* forge, + const ScoLV2URIs* uris, + const int32_t channel, + const size_t n_samples, + const float* data) { LV2_Atom_Forge_Frame frame; diff --git a/plugins/eg-scope.lv2/examploscope_ui.c b/plugins/eg-scope.lv2/examploscope_ui.c index 1c82d44..7b49967 100644 --- a/plugins/eg-scope.lv2/examploscope_ui.c +++ b/plugins/eg-scope.lv2/examploscope_ui.c @@ -167,7 +167,7 @@ send_ui_enable(LV2UI_Handle handle) static gboolean on_cfg_changed(GtkWidget* widget, gpointer data) { - EgScopeUI* ui = (EgScopeUI*)data; + const EgScopeUI* ui = (const EgScopeUI*)data; if (!ui->updating) { // Only send UI state if the change is from user interaction send_ui_state(data); @@ -222,7 +222,7 @@ on_expose_event(GtkWidget* widget, GdkEventExpose* ev, gpointer data) const float chn_y_offset = DAHEIGHT * c + DAHEIGHT * 0.5f - 0.5f; const float chn_y_scale = DAHEIGHT * 0.5f * gain; -#define CYPOS(VAL) (chn_y_offset - (VAL)*chn_y_scale) +#define CYPOS(VAL) (chn_y_offset - (VAL) * chn_y_scale) cairo_save(cr); @@ -327,12 +327,12 @@ on_expose_event(GtkWidget* widget, GdkEventExpose* ev, gpointer data) and https://github.com/x42/sisco.lv2 */ static int -process_channel(EgScopeUI* ui, - ScoChan* chn, - const size_t n_elem, - float const* data, - uint32_t* idx_start, - uint32_t* idx_end) +process_channel(const EgScopeUI* ui, + ScoChan* chn, + const size_t n_elem, + float const* data, + uint32_t* idx_start, + uint32_t* idx_end) { int overflow = 0; *idx_start = chn->idx; diff --git a/test/atom_test_utils.c b/test/atom_test_utils.c index e7d45d0..bffa2ea 100644 --- a/test/atom_test_utils.c +++ b/test/atom_test_utils.c @@ -1,12 +1,15 @@ // Copyright 2012-2018 David Robillard <d@drobilla.net> // SPDX-License-Identifier: ISC +#undef NDEBUG + #include "lv2/atom/atom.h" #include "lv2/atom/forge.h" #include "lv2/atom/util.h" #include "lv2/log/log.h" #include "lv2/urid/urid.h" +#include <assert.h> #include <stdarg.h> #include <stdio.h> #include <stdlib.h> @@ -32,8 +35,11 @@ urid_map(LV2_URID_Map_Handle handle, const char* uri) } } - uris = (char**)realloc(uris, ++n_uris * sizeof(char*)); - uris[n_uris - 1] = copy_string(uri); + char** const new_uris = (char**)realloc(uris, (n_uris + 1) * sizeof(char*)); + assert(new_uris); + + uris = new_uris; + uris[n_uris++] = copy_string(uri); return n_uris; } diff --git a/test/headers/.clang-tidy b/test/headers/.clang-tidy index 26d6f6f..bf971cc 100644 --- a/test/headers/.clang-tidy +++ b/test/headers/.clang-tidy @@ -7,7 +7,6 @@ Checks: > -*-magic-numbers, -altera-*, -bugprone-assignment-in-if-condition, - -bugprone-casting-through-void, -bugprone-easily-swappable-parameters, -bugprone-macro-parentheses, -llvmlibc-restrict-system-libc-headers, diff --git a/test/test_atom.c b/test/test_atom.c index beac05c..ffe73a1 100644 --- a/test/test_atom.c +++ b/test/test_atom.c @@ -101,7 +101,7 @@ main(void) lv2_atom_forge_key(&forge, eg_path); LV2_Atom_String* path = (LV2_Atom_String*)lv2_atom_forge_deref( &forge, lv2_atom_forge_uri(&forge, pstr, pstr_len)); - char* pbody = (char*)LV2_ATOM_BODY(path); + char* pbody = (char*)&path[1]; if (!!strcmp(pbody, pstr)) { return test_fail("%s != \"%s\"\n", pbody, pstr); } @@ -112,7 +112,7 @@ main(void) lv2_atom_forge_key(&forge, eg_uri); LV2_Atom_String* uri = (LV2_Atom_String*)lv2_atom_forge_deref( &forge, lv2_atom_forge_uri(&forge, ustr, ustr_len)); - char* ubody = (char*)LV2_ATOM_BODY(uri); + char* ubody = (char*)&uri[1]; if (!!strcmp(ubody, ustr)) { return test_fail("%s != \"%s\"\n", ubody, ustr); } @@ -130,7 +130,7 @@ main(void) lv2_atom_forge_key(&forge, eg_string); LV2_Atom_String* string = (LV2_Atom_String*)lv2_atom_forge_deref( &forge, lv2_atom_forge_string(&forge, "hello", strlen("hello"))); - char* sbody = (char*)LV2_ATOM_BODY(string); + char* sbody = (char*)&string[1]; if (!!strcmp(sbody, "hello")) { return test_fail("%s != \"hello\"\n", sbody); } @@ -144,7 +144,7 @@ main(void) strlen("bonjour"), 0, urid_map(NULL, "http://lexvo.org/id/term/fr"))); - char* lbody = (char*)LV2_ATOM_CONTENTS(LV2_Atom_Literal, literal); + char* lbody = (char*)&literal[1]; if (!!strcmp(lbody, "bonjour")) { return test_fail("%s != \"bonjour\"\n", lbody); } @@ -186,7 +186,7 @@ main(void) LV2_Atom_Vector* vector = (LV2_Atom_Vector*)lv2_atom_forge_deref( &forge, lv2_atom_forge_vector(&forge, sizeof(int32_t), forge.Int, 4, elems)); - void* vec_body = LV2_ATOM_CONTENTS(LV2_Atom_Vector, vector); + const void* vec_body = LV2_ATOM_CONTENTS_CONST(LV2_Atom_Vector, vector); if (!!memcmp(elems, vec_body, sizeof(elems))) { return test_fail("Corrupt vector\n"); } |