From 52650784331844f8a92c5e9c4ba443a468743867 Mon Sep 17 00:00:00 2001 From: David Robillard Date: Thu, 26 May 2022 13:27:22 -0400 Subject: Suppress new warnings in clang-tidy 13 --- .clang-tidy | 3 +++ lv2/atom/forge.h | 2 +- lv2/midi/midi.h | 4 ++-- lv2/state/state.h | 6 +++--- plugins/eg-metro.lv2/metro.c | 4 ++-- plugins/eg-params.lv2/state_map.h | 2 +- plugins/eg-sampler.lv2/sampler_ui.c | 8 ++++++-- plugins/eg-scope.lv2/examploscope.c | 5 +++-- 8 files changed, 21 insertions(+), 13 deletions(-) diff --git a/.clang-tidy b/.clang-tidy index 66a8005..7cb42c6 100644 --- a/.clang-tidy +++ b/.clang-tidy @@ -3,6 +3,7 @@ Checks: > -*-else-after-return, -*-magic-numbers, -*-uppercase-literal-suffix, + -altera-*, -bugprone-macro-parentheses, -bugprone-suspicious-include, -bugprone-suspicious-string-compare, @@ -16,6 +17,8 @@ Checks: > -misc-unused-parameters, -modernize-redundant-void-arg, -modernize-use-trailing-return-type, + -performance-no-int-to-ptr, + -readability-function-cognitive-complexity, WarningsAsErrors: '*' HeaderFilterRegex: '.*' FormatStyle: file diff --git a/lv2/atom/forge.h b/lv2/atom/forge.h index 5cf3551..d17643f 100644 --- a/lv2/atom/forge.h +++ b/lv2/atom/forge.h @@ -497,7 +497,7 @@ lv2_atom_forge_vector(LV2_Atom_Forge* forge, const void* elems) { const LV2_Atom_Vector a = { - {(uint32_t)(sizeof(LV2_Atom_Vector_Body) + n_elems * child_size), + {(uint32_t)sizeof(LV2_Atom_Vector_Body) + n_elems * child_size, forge->Vector}, {child_size, child_type}}; LV2_Atom_Forge_Ref out = lv2_atom_forge_write(forge, &a, sizeof(a)); diff --git a/lv2/midi/midi.h b/lv2/midi/midi.h index 2c70f0c..f7e0500 100644 --- a/lv2/midi/midi.h +++ b/lv2/midi/midi.h @@ -215,7 +215,7 @@ lv2_midi_is_system_message(const uint8_t* msg) case 0xFD: return false; default: - return (msg[0] & 0xF0) == 0xF0; + return (msg[0] & 0xF0u) == 0xF0u; } } @@ -227,7 +227,7 @@ static inline LV2_Midi_Message_Type lv2_midi_message_type(const uint8_t* msg) { if (lv2_midi_is_voice_message(msg)) { - return (LV2_Midi_Message_Type)(msg[0] & 0xF0); + return (LV2_Midi_Message_Type)(msg[0] & 0xF0u); } if (lv2_midi_is_system_message(msg)) { diff --git a/lv2/state/state.h b/lv2/state/state.h index e526d85..01ec598 100644 --- a/lv2/state/state.h +++ b/lv2/state/state.h @@ -82,7 +82,7 @@ typedef enum { Implementations MUST NOT attempt to copy or serialise a non-POD value if they do not understand its type (and thus know how to correctly do so). */ - LV2_STATE_IS_POD = 1, + LV2_STATE_IS_POD = 1u << 0u, /** Portable (architecture independent) data. @@ -93,7 +93,7 @@ typedef enum { values MUST NOT depend on architecture-specific properties like endianness or alignment. Portable values MUST NOT contain filenames. */ - LV2_STATE_IS_PORTABLE = 1 << 1, + LV2_STATE_IS_PORTABLE = 1u << 1u, /** Native data. @@ -104,7 +104,7 @@ typedef enum { most efficient representation possible and not worry about serialisation and portability. */ - LV2_STATE_IS_NATIVE = 1 << 2 + LV2_STATE_IS_NATIVE = 1u << 2u } LV2_State_Flags; /** A status code for state functions. */ diff --git a/plugins/eg-metro.lv2/metro.c b/plugins/eg-metro.lv2/metro.c index 7ffea24..264f2c7 100644 --- a/plugins/eg-metro.lv2/metro.c +++ b/plugins/eg-metro.lv2/metro.c @@ -212,7 +212,7 @@ static void play(Metro* self, uint32_t begin, uint32_t end) { float* const output = self->ports.output; - const uint32_t frames_per_beat = 60.0f / self->bpm * self->rate; + const uint32_t frames_per_beat = (uint32_t)(60.0f / self->bpm * self->rate); if (self->speed == 0.0f) { memset(output, 0, (end - begin) * sizeof(float)); @@ -289,7 +289,7 @@ update_position(Metro* self, const LV2_Atom_Object* obj) const float frames_per_beat = (float)(60.0 / self->bpm * self->rate); const float bar_beats = ((LV2_Atom_Float*)beat)->body; const float beat_beats = bar_beats - floorf(bar_beats); - self->elapsed_len = beat_beats * frames_per_beat; + self->elapsed_len = (uint32_t)(beat_beats * frames_per_beat); if (self->elapsed_len < self->attack_len) { self->state = STATE_ATTACK; } else if (self->elapsed_len < self->attack_len + self->decay_len) { diff --git a/plugins/eg-params.lv2/state_map.h b/plugins/eg-params.lv2/state_map.h index f534f60..4a00d2f 100644 --- a/plugins/eg-params.lv2/state_map.h +++ b/plugins/eg-params.lv2/state_map.h @@ -48,7 +48,7 @@ state_map_cmp(const void* a, const void* b) /** Helper macro for terse state map initialisation. */ #define STATE_MAP_INIT(type, ptr) \ - (LV2_ATOM__##type), (sizeof(*ptr) - sizeof(LV2_Atom)), (ptr) + (LV2_ATOM__##type), (sizeof(*(ptr)) - sizeof(LV2_Atom)), (ptr) /** Initialise a state map. diff --git a/plugins/eg-sampler.lv2/sampler_ui.c b/plugins/eg-sampler.lv2/sampler_ui.c index 533e720..630fc22 100644 --- a/plugins/eg-sampler.lv2/sampler_ui.c +++ b/plugins/eg-sampler.lv2/sampler_ui.c @@ -365,7 +365,7 @@ port_event(LV2UI_Handle handle, const LV2_Atom_Object* obj = (const LV2_Atom_Object*)atom; if (obj->body.otype == ui->uris.patch_Set) { const char* path = read_set_file(&ui->uris, obj); - if (path && (!ui->filename || strcmp(path, ui->filename))) { + if (path && (!ui->filename || !!strcmp(path, ui->filename))) { g_free(ui->filename); ui->filename = g_strdup(path); gtk_file_chooser_set_filename(GTK_FILE_CHOOSER(ui->file_button), @@ -447,11 +447,15 @@ extension_data(const char* uri) { static const LV2UI_Show_Interface show = {ui_show, ui_hide}; static const LV2UI_Idle_Interface idle = {ui_idle}; + if (!strcmp(uri, LV2_UI__showInterface)) { return &show; - } else if (!strcmp(uri, LV2_UI__idleInterface)) { + } + + if (!strcmp(uri, LV2_UI__idleInterface)) { return &idle; } + return NULL; } diff --git a/plugins/eg-scope.lv2/examploscope.c b/plugins/eg-scope.lv2/examploscope.c index ec013a1..8bc4ca1 100644 --- a/plugins/eg-scope.lv2/examploscope.c +++ b/plugins/eg-scope.lv2/examploscope.c @@ -249,7 +249,7 @@ run(LV2_Handle handle, uint32_t n_samples) // Add UI state as properties lv2_atom_forge_key(&self->forge, self->uris.ui_spp); - lv2_atom_forge_int(&self->forge, self->ui_spp); + lv2_atom_forge_int(&self->forge, (int32_t)self->ui_spp); lv2_atom_forge_key(&self->forge, self->uris.ui_amp); lv2_atom_forge_float(&self->forge, self->ui_amp); lv2_atom_forge_key(&self->forge, self->uris.param_sampleRate); @@ -295,7 +295,8 @@ run(LV2_Handle handle, uint32_t n_samples) for (uint32_t c = 0; c < self->n_channels; ++c) { if (self->ui_active) { // If UI is active, send raw audio data to UI - tx_rawaudio(&self->forge, &self->uris, c, n_samples, self->input[c]); + tx_rawaudio( + &self->forge, &self->uris, (int32_t)c, n_samples, self->input[c]); } // If not processing audio in-place, forward audio if (self->input[c] != self->output[c]) { -- cgit v1.2.1