From c5e1f7d0268cfbc9593b7c858f62535bf13cb77c Mon Sep 17 00:00:00 2001 From: JP Cimalando Date: Wed, 9 Jan 2019 21:47:35 +0100 Subject: [PATCH] Fix some warnings emitted by GCC 8 and Clang 7 --- distrho/DistrhoPlugin.hpp | 26 ++++++++++++++++++++++++ distrho/src/DistrhoPluginLADSPA+DSSI.cpp | 4 ++-- distrho/src/DistrhoPluginLV2.cpp | 2 +- distrho/src/lv2/atom-util.h | 8 ++++---- examples/Meters/ExampleUIMeters.cpp | 2 +- 5 files changed, 34 insertions(+), 8 deletions(-) diff --git a/distrho/DistrhoPlugin.hpp b/distrho/DistrhoPlugin.hpp index 527fcbe9..1da2bdb6 100644 --- a/distrho/DistrhoPlugin.hpp +++ b/distrho/DistrhoPlugin.hpp @@ -590,6 +590,22 @@ struct TimePosition { beatType(0.0f), ticksPerBeat(0.0), beatsPerMinute(0.0) {} + + /** + Reinitialize this position using the default null initialization. + */ + void clear() noexcept + { + valid = false; + bar = 0; + beat = 0; + tick = 0; + barStartTick = 0.0; + beatsPerBar = 0.0f; + beatType = 0.0f; + ticksPerBeat = 0.0; + beatsPerMinute = 0.0; + } } bbt; /** @@ -599,6 +615,16 @@ struct TimePosition { : playing(false), frame(0), bbt() {} + + /** + Reinitialize this position using the default null initialization. + */ + void clear() noexcept + { + playing = false; + frame = 0; + bbt.clear(); + } }; /** @} */ diff --git a/distrho/src/DistrhoPluginLADSPA+DSSI.cpp b/distrho/src/DistrhoPluginLADSPA+DSSI.cpp index 6f45decd..79dcf402 100644 --- a/distrho/src/DistrhoPluginLADSPA+DSSI.cpp +++ b/distrho/src/DistrhoPluginLADSPA+DSSI.cpp @@ -286,9 +286,9 @@ public: # if DISTRHO_PLUGIN_WANT_STATE char* dssi_configure(const char* const key, const char* const value) { - if (std::strncmp(key, DSSI_RESERVED_CONFIGURE_PREFIX, std::strlen(DSSI_RESERVED_CONFIGURE_PREFIX) == 0)) + if (std::strncmp(key, DSSI_RESERVED_CONFIGURE_PREFIX, std::strlen(DSSI_RESERVED_CONFIGURE_PREFIX)) == 0) return nullptr; - if (std::strncmp(key, DSSI_GLOBAL_CONFIGURE_PREFIX, std::strlen(DSSI_GLOBAL_CONFIGURE_PREFIX) == 0)) + if (std::strncmp(key, DSSI_GLOBAL_CONFIGURE_PREFIX, std::strlen(DSSI_GLOBAL_CONFIGURE_PREFIX)) == 0) return nullptr; fPlugin.setState(key, value); diff --git a/distrho/src/DistrhoPluginLV2.cpp b/distrho/src/DistrhoPluginLV2.cpp index b01df4eb..e66ec1d0 100644 --- a/distrho/src/DistrhoPluginLV2.cpp +++ b/distrho/src/DistrhoPluginLV2.cpp @@ -169,7 +169,7 @@ public: void lv2_activate() { #if DISTRHO_PLUGIN_WANT_TIMEPOS - std::memset(&fTimePosition, 0, sizeof(TimePosition)); + fTimePosition.clear(); // hosts may not send all values, resulting on some invalid data fTimePosition.bbt.bar = 1; diff --git a/distrho/src/lv2/atom-util.h b/distrho/src/lv2/atom-util.h index 13536872..cad90f89 100644 --- a/distrho/src/lv2/atom-util.h +++ b/distrho/src/lv2/atom-util.h @@ -117,13 +117,13 @@ lv2_atom_sequence_next(const LV2_Atom_Event* i) @endcode */ #define LV2_ATOM_SEQUENCE_FOREACH(seq, iter) \ - for (const LV2_Atom_Event* (iter) = lv2_atom_sequence_begin(&(seq)->body); \ + for (const LV2_Atom_Event* iter = lv2_atom_sequence_begin(&(seq)->body); \ !lv2_atom_sequence_is_end(&(seq)->body, (seq)->atom.size, (iter)); \ (iter) = lv2_atom_sequence_next(iter)) /** Like LV2_ATOM_SEQUENCE_FOREACH but for a headerless sequence body. */ #define LV2_ATOM_SEQUENCE_BODY_FOREACH(body, size, iter) \ - for (const LV2_Atom_Event* (iter) = lv2_atom_sequence_begin(body); \ + for (const LV2_Atom_Event* iter = lv2_atom_sequence_begin(body); \ !lv2_atom_sequence_is_end(body, size, (iter)); \ (iter) = lv2_atom_sequence_next(iter)) @@ -214,13 +214,13 @@ lv2_atom_tuple_next(const LV2_Atom* i) @endcode */ #define LV2_ATOM_TUPLE_FOREACH(tuple, iter) \ - for (const LV2_Atom* (iter) = lv2_atom_tuple_begin(tuple); \ + for (const LV2_Atom* iter = lv2_atom_tuple_begin(tuple); \ !lv2_atom_tuple_is_end(LV2_ATOM_BODY_CONST(tuple), (tuple)->size, (iter)); \ (iter) = lv2_atom_tuple_next(iter)) /** Like LV2_ATOM_TUPLE_FOREACH but for a headerless tuple body. */ #define LV2_ATOM_TUPLE_BODY_FOREACH(body, size, iter) \ - for (const LV2_Atom* (iter) = (const LV2_Atom*)body; \ + for (const LV2_Atom* iter = (const LV2_Atom*)body; \ !lv2_atom_tuple_is_end(body, size, (iter)); \ (iter) = lv2_atom_tuple_next(iter)) diff --git a/examples/Meters/ExampleUIMeters.cpp b/examples/Meters/ExampleUIMeters.cpp index d57c461f..3aa952fe 100644 --- a/examples/Meters/ExampleUIMeters.cpp +++ b/examples/Meters/ExampleUIMeters.cpp @@ -93,7 +93,7 @@ protected: A state has changed on the plugin side. This is called by the host to inform the UI about state changes. */ - void stateChanged(const char*, const char*) + void stateChanged(const char*, const char*) override { // nothing here }