From 76e4307c2f57df359651dab61184fd521ffb1fbf Mon Sep 17 00:00:00 2001 From: David Robillard Date: Fri, 27 Nov 2020 17:58:01 +0100 Subject: Fix unused parameter warnings --- .clang-format | 3 +-- .clang-tidy | 2 +- src/AlsaDriver.cpp | 9 ++++---- src/AlsaDriver.hpp | 3 +-- src/JackDbusDriver.cpp | 58 +++++++++++++++++++++++++------------------------- src/JackDbusDriver.hpp | 2 +- src/Patchage.cpp | 17 ++++++++------- src/PatchageCanvas.cpp | 3 +++ src/PatchageCanvas.hpp | 3 +++ src/PatchageModule.hpp | 3 +++ src/PatchagePort.hpp | 3 +++ src/PortID.hpp | 2 +- src/warnings.hpp | 43 +++++++++++++++++++++++++++++++++++++ wscript | 2 -- 14 files changed, 102 insertions(+), 51 deletions(-) create mode 100644 src/warnings.hpp diff --git a/.clang-format b/.clang-format index 1da0c6e..9bd416e 100644 --- a/.clang-format +++ b/.clang-format @@ -119,8 +119,7 @@ SpacesInParentheses: false SpacesInSquareBrackets: false Standard: Cpp11 StatementMacros: - - Q_UNUSED - - QT_REQUIRE_VERSION + - _Pragma TabWidth: 4 UseTab: ForIndentation ... diff --git a/.clang-tidy b/.clang-tidy index f6b1de1..1dd6c2c 100644 --- a/.clang-tidy +++ b/.clang-tidy @@ -2,6 +2,7 @@ Checks: > *, -*-c-arrays, -*-magic-numbers, + -*-named-parameter, -*-narrowing-conversions, -*-no-malloc, -*-non-private-member-variables-in-classes, @@ -35,7 +36,6 @@ Checks: > -hicpp-signed-bitwise, -llvm-header-guard, -llvmlibc-*, - -misc-unused-parameters, -modernize-use-trailing-return-type, -readability-convert-member-functions-to-static, -readability-implicit-bool-conversion, diff --git a/src/AlsaDriver.cpp b/src/AlsaDriver.cpp index 9f7b93b..09367cb 100644 --- a/src/AlsaDriver.cpp +++ b/src/AlsaDriver.cpp @@ -133,7 +133,7 @@ AlsaDriver::refresh() continue; } - create_port_view_internal(_app, addr, parent, port); + create_port_view_internal(addr, parent, port); } } @@ -178,11 +178,11 @@ AlsaDriver::refresh() } PatchagePort* -AlsaDriver::create_port_view(Patchage* patchage, const PortID& id) +AlsaDriver::create_port_view(Patchage*, const PortID& id) { PatchageModule* parent = nullptr; PatchagePort* port = nullptr; - create_port_view_internal(patchage, id.id.alsa_addr, parent, port); + create_port_view_internal(id.id.alsa_addr, parent, port); return port; } @@ -228,8 +228,7 @@ AlsaDriver::find_or_create_module(Patchage* patchage, } void -AlsaDriver::create_port_view_internal(Patchage* patchage, - snd_seq_addr_t addr, +AlsaDriver::create_port_view_internal(snd_seq_addr_t addr, PatchageModule*& parent, PatchagePort*& port) { diff --git a/src/AlsaDriver.hpp b/src/AlsaDriver.hpp index 299829f..a07eeff 100644 --- a/src/AlsaDriver.hpp +++ b/src/AlsaDriver.hpp @@ -70,8 +70,7 @@ private: const std::string& client_name, ModuleType type); - void create_port_view_internal(Patchage* patchage, - snd_seq_addr_t addr, + void create_port_view_internal(snd_seq_addr_t addr, PatchageModule*& parent, PatchagePort*& port); diff --git a/src/JackDbusDriver.cpp b/src/JackDbusDriver.cpp index d225c8a..daba095 100644 --- a/src/JackDbusDriver.cpp +++ b/src/JackDbusDriver.cpp @@ -138,9 +138,9 @@ JackDriver::on_jack_disappeared() /** Handle signals we have subscribed for in attach(). */ DBusHandlerResult -JackDriver::dbus_message_hook(DBusConnection* connection, - DBusMessage* message, - void* jack_driver) +JackDriver::dbus_message_hook(DBusConnection* /*connection*/, + DBusMessage* message, + void* jack_driver) { const char* client2_name; const char* client_name; @@ -599,9 +599,9 @@ JackDriver::add_port(PatchageModule* module, } void -JackDriver::add_port(dbus_uint64_t client_id, - const char* client_name, - dbus_uint64_t port_id, +JackDriver::add_port(dbus_uint64_t /*client_id*/, + const char* client_name, + dbus_uint64_t /*port_id*/, const char* port_name, dbus_uint32_t port_flags, dbus_uint32_t port_type) @@ -639,10 +639,10 @@ JackDriver::add_port(dbus_uint64_t client_id, } void -JackDriver::remove_port(dbus_uint64_t client_id, - const char* client_name, - dbus_uint64_t port_id, - const char* port_name) +JackDriver::remove_port(dbus_uint64_t /*client_id*/, + const char* client_name, + dbus_uint64_t /*port_id*/, + const char* port_name) { PatchagePort* port = _app->canvas()->find_port_by_name(client_name, port_name); @@ -684,15 +684,15 @@ JackDriver::find_or_create_module(ModuleType type, const std::string& name) } void -JackDriver::connect_ports(dbus_uint64_t connection_id, - dbus_uint64_t client1_id, - const char* client1_name, - dbus_uint64_t port1_id, - const char* port1_name, - dbus_uint64_t client2_id, - const char* client2_name, - dbus_uint64_t port2_id, - const char* port2_name) +JackDriver::connect_ports(dbus_uint64_t /*connection_id*/, + dbus_uint64_t /*client1_id*/, + const char* client1_name, + dbus_uint64_t /*port1_id*/, + const char* port1_name, + dbus_uint64_t /*client2_id*/, + const char* client2_name, + dbus_uint64_t /*port2_id*/, + const char* port2_name) { PatchagePort* port1 = _app->canvas()->find_port_by_name(client1_name, port1_name); @@ -714,15 +714,15 @@ JackDriver::connect_ports(dbus_uint64_t connection_id, } void -JackDriver::disconnect_ports(dbus_uint64_t connection_id, - dbus_uint64_t client1_id, - const char* client1_name, - dbus_uint64_t port1_id, - const char* port1_name, - dbus_uint64_t client2_id, - const char* client2_name, - dbus_uint64_t port2_id, - const char* port2_name) +JackDriver::disconnect_ports(dbus_uint64_t /*connection_id*/, + dbus_uint64_t /*client1_id*/, + const char* client1_name, + dbus_uint64_t /*port1_id*/, + const char* port1_name, + dbus_uint64_t /*client2_id*/, + const char* client2_name, + dbus_uint64_t /*port2_id*/, + const char* port2_name) { PatchagePort* port1 = _app->canvas()->find_port_by_name(client1_name, port1_name); @@ -1180,7 +1180,7 @@ JackDriver::reset_max_dsp_load() } PatchagePort* -JackDriver::create_port_view(Patchage* patchage, const PortID& id) +JackDriver::create_port_view(Patchage*, const PortID&) { assert(false); // we dont use events at all return nullptr; diff --git a/src/JackDbusDriver.hpp b/src/JackDbusDriver.hpp index 8504f68..1812298 100644 --- a/src/JackDbusDriver.hpp +++ b/src/JackDbusDriver.hpp @@ -61,7 +61,7 @@ public: jack_nframes_t buffer_size(); bool set_buffer_size(jack_nframes_t size); - void process_events(Patchage* app) {} + void process_events(Patchage*) {} PatchagePort* create_port_view(Patchage* patchage, const PortID& ref); diff --git a/src/Patchage.cpp b/src/Patchage.cpp index f02e22e..aca3a54 100644 --- a/src/Patchage.cpp +++ b/src/Patchage.cpp @@ -22,6 +22,7 @@ #include "PatchageEvent.hpp" #include "UIFile.hpp" #include "patchage_config.h" +#include "warnings.hpp" #if defined(HAVE_JACK_DBUS) # include "JackDbusDriver.hpp" @@ -38,8 +39,10 @@ # include "AlsaDriver.hpp" #endif +PATCHAGE_DISABLE_GANV_WARNINGS #include "ganv/Edge.hpp" #include "ganv/Module.hpp" +PATCHAGE_RESTORE_WARNINGS #include #include @@ -78,14 +81,14 @@ terminate_cb(GtkosxApplication* app, gpointer data) #endif static bool -configure_cb(GtkWindow* parentWindow, GdkEvent* event, gpointer data) +configure_cb(GtkWindow*, GdkEvent*, gpointer data) { static_cast(data)->store_window_location(); return FALSE; } static int -port_order(const GanvPort* a, const GanvPort* b, void* data) +port_order(const GanvPort* a, const GanvPort* b, void*) { const auto* pa = dynamic_cast(Glib::wrap(a)); const auto* pb = dynamic_cast(Glib::wrap(b)); @@ -615,7 +618,7 @@ Patchage::warning_msg(const std::string& msg) } static void -load_module_location(GanvNode* node, void* data) +load_module_location(GanvNode* node, void*) { if (GANV_IS_MODULE(node)) { Ganv::Module* gmod = Glib::wrap(GANV_MODULE(node)); @@ -962,9 +965,7 @@ update_edge_color(GanvEdge* edge, void* data) } void -Patchage::on_legend_color_change(PortType id, - const std::string& label, - uint32_t rgba) +Patchage::on_legend_color_change(PortType id, const std::string&, uint32_t rgba) { _conf->set_port_color(id, rgba); _canvas->for_each_node(update_port_colors, this); @@ -972,7 +973,7 @@ Patchage::on_legend_color_change(PortType id, } void -Patchage::on_messages_resized(Gtk::Allocation& alloc) +Patchage::on_messages_resized(Gtk::Allocation&) { const int max_pos = _main_paned->get_allocation().get_height(); _conf->set_messages_height(max_pos - _main_paned->get_position()); @@ -1088,7 +1089,7 @@ Patchage::on_view_toolbar() } bool -Patchage::on_scroll(GdkEventScroll* ev) +Patchage::on_scroll(GdkEventScroll*) { return false; } diff --git a/src/PatchageCanvas.cpp b/src/PatchageCanvas.cpp index 0408ccd..214c158 100644 --- a/src/PatchageCanvas.cpp +++ b/src/PatchageCanvas.cpp @@ -21,6 +21,7 @@ #include "Patchage.hpp" #include "PatchageModule.hpp" #include "PatchagePort.hpp" +#include "warnings.hpp" #if defined(HAVE_JACK_DBUS) # include "JackDbusDriver.hpp" @@ -31,7 +32,9 @@ # include "AlsaDriver.hpp" #endif +PATCHAGE_DISABLE_GANV_WARNINGS #include "ganv/Edge.hpp" +PATCHAGE_RESTORE_WARNINGS #include diff --git a/src/PatchageCanvas.hpp b/src/PatchageCanvas.hpp index 0b200f4..a94b9c7 100644 --- a/src/PatchageCanvas.hpp +++ b/src/PatchageCanvas.hpp @@ -22,8 +22,11 @@ #include "PatchageEvent.hpp" #include "PatchageModule.hpp" #include "PortID.hpp" +#include "warnings.hpp" +PATCHAGE_DISABLE_GANV_WARNINGS #include "ganv/Canvas.hpp" +PATCHAGE_RESTORE_WARNINGS #ifdef HAVE_ALSA # include diff --git a/src/PatchageModule.hpp b/src/PatchageModule.hpp index 526e739..80cdf04 100644 --- a/src/PatchageModule.hpp +++ b/src/PatchageModule.hpp @@ -18,9 +18,12 @@ #define PATCHAGE_PATCHAGEMODULE_HPP #include "Configuration.hpp" +#include "warnings.hpp" +PATCHAGE_DISABLE_GANV_WARNINGS #include "ganv/Module.hpp" #include "ganv/Port.hpp" +PATCHAGE_RESTORE_WARNINGS #include diff --git a/src/PatchagePort.hpp b/src/PatchagePort.hpp index f351bae..5bbcd13 100644 --- a/src/PatchagePort.hpp +++ b/src/PatchagePort.hpp @@ -23,9 +23,12 @@ #include "PatchageCanvas.hpp" #include "PatchageModule.hpp" #include "PortID.hpp" +#include "warnings.hpp" +PATCHAGE_DISABLE_GANV_WARNINGS #include "ganv/Module.hpp" #include "ganv/Port.hpp" +PATCHAGE_RESTORE_WARNINGS #include #include diff --git a/src/PortID.hpp b/src/PortID.hpp index 5b3ec8b..054008f 100644 --- a/src/PortID.hpp +++ b/src/PortID.hpp @@ -49,7 +49,7 @@ struct PortID } #ifdef PATCHAGE_LIBJACK - explicit PortID(jack_port_id_t jack_id, bool ign = false) + explicit PortID(jack_port_id_t jack_id, bool = false) : type(Type::jack_id) { id.jack_id = jack_id; diff --git a/src/warnings.hpp b/src/warnings.hpp new file mode 100644 index 0000000..14dbbe0 --- /dev/null +++ b/src/warnings.hpp @@ -0,0 +1,43 @@ +/* This file is part of Patchage. + * Copyright 2020 David Robillard + * + * Patchage is free software: you can redistribute it and/or modify it under + * the terms of the GNU General Public License as published by the Free + * Software Foundation, either version 3 of the License, or (at your option) + * any later version. + * + * Patchage is distributed in the hope that it will be useful, but WITHOUT ANY + * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS + * FOR A PARTICULAR PURPOSE. See the GNU General Public License for details. + * + * You should have received a copy of the GNU General Public License + * along with Patchage. If not, see . + */ + +#ifndef PATCHAGE_WARNINGS_HPP +#define PATCHAGE_WARNINGS_HPP + +#if defined(__clang__) + +# define PATCHAGE_DISABLE_GANV_WARNINGS \ + _Pragma("clang diagnostic push") \ + _Pragma("clang diagnostic ignored \"-Wunused-parameter\"") + +# define PATCHAGE_RESTORE_WARNINGS _Pragma("clang diagnostic pop") + +#elif defined(__GNUC__) + +# define PATCHAGE_DISABLE_GANV_WARNINGS \ + _Pragma("GCC diagnostic push") \ + _Pragma("GCC diagnostic ignored \"-Wunused-parameter\"") + +# define PATCHAGE_RESTORE_WARNINGS _Pragma("GCC diagnostic pop") + +#else + +# define PATCHAGE_DISABLE_GANV_WARNINGS +# define PATCHAGE_RESTORE_WARNINGS + +#endif + +#endif // PATCHAGE_WARNINGS_HPP diff --git a/wscript b/wscript index f6db1dd..b970239 100644 --- a/wscript +++ b/wscript @@ -73,7 +73,6 @@ def configure(conf): '-Wno-shorten-64-to-32', '-Wno-sign-conversion', '-Wno-stack-protector', - '-Wno-unused-parameter', '-Wno-suggest-override', '-Wno-suggest-destructor-override', ], @@ -86,7 +85,6 @@ def configure(conf): '-Wno-shadow', '-Wno-stack-protector', '-Wno-suggest-attribute=noreturn', - '-Wno-unused-parameter', ], }) -- cgit v1.2.1