From c076e93136799096da613950eb14e7d5fbe9375a Mon Sep 17 00:00:00 2001 From: David Robillard Date: Fri, 12 May 2023 09:58:30 -0400 Subject: Fix const correctness --- .clang-tidy | 1 - include/ingen/QueuedInterface.hpp | 4 ++-- include/ingen/Tee.hpp | 2 +- include/ingen/client/SocketClient.hpp | 2 +- include/ingen/fmt.hpp | 8 +++++--- src/server/Broadcaster.hpp | 2 +- 6 files changed, 10 insertions(+), 9 deletions(-) diff --git a/.clang-tidy b/.clang-tidy index 0ea68c8e..c25e1c7b 100644 --- a/.clang-tidy +++ b/.clang-tidy @@ -17,7 +17,6 @@ Checks: > -hicpp-explicit-conversions, -hicpp-signed-bitwise, -llvmlibc-*, - -misc-const-correctness, -misc-unused-parameters, -modernize-use-nodiscard, -modernize-use-trailing-return-type, diff --git a/include/ingen/QueuedInterface.hpp b/include/ingen/QueuedInterface.hpp index fc3e539c..4bb6baea 100644 --- a/include/ingen/QueuedInterface.hpp +++ b/include/ingen/QueuedInterface.hpp @@ -42,14 +42,14 @@ public: URI uri() const override { return URI("ingen:/QueuedInterface"); } void message(const Message& message) override { - std::lock_guard lock(_mutex); + const std::lock_guard lock{_mutex}; _messages.emplace_back(message); } void emit() { std::vector messages; { - std::lock_guard lock(_mutex); + const std::lock_guard lock{_mutex}; _messages.swap(messages); } diff --git a/include/ingen/Tee.hpp b/include/ingen/Tee.hpp index 2158190f..562ff298 100644 --- a/include/ingen/Tee.hpp +++ b/include/ingen/Tee.hpp @@ -46,7 +46,7 @@ public: } void message(const Message& message) override { - std::lock_guard lock(_sinks_mutex); + const std::lock_guard lock{_sinks_mutex}; for (const auto& s : _sinks) { s->message(message); } diff --git a/include/ingen/client/SocketClient.hpp b/include/ingen/client/SocketClient.hpp index 3dc00d6f..7434da90 100644 --- a/include/ingen/client/SocketClient.hpp +++ b/include/ingen/client/SocketClient.hpp @@ -66,7 +66,7 @@ public: ? raul::Socket::Type::UNIX : raul::Socket::Type::TCP); - std::shared_ptr sock(new raul::Socket(type)); + const std::shared_ptr sock{new raul::Socket(type)}; if (!sock->connect(uri)) { world.log().error("Failed to connect <%1%> (%2%)\n", sock->uri(), strerror(errno)); diff --git a/include/ingen/fmt.hpp b/include/ingen/fmt.hpp index b2924d29..7ca5de9f 100644 --- a/include/ingen/fmt.hpp +++ b/include/ingen/fmt.hpp @@ -1,6 +1,6 @@ /* This file is part of Ingen. - Copyright 2007-2016 David Robillard + Copyright 2007-2023 David Robillard Ingen is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free @@ -27,8 +27,10 @@ template std::string fmt(const char* fmt, Args&&... args) { - boost::format f(fmt); - std::initializer_list l{(static_cast(f % args), char{})...}; + boost::format f{fmt}; // NOLINT(misc-const-correctness) + const std::initializer_list l{ + (static_cast(f % args), char{})...}; + (void)l; return boost::str(f); } diff --git a/src/server/Broadcaster.hpp b/src/server/Broadcaster.hpp index e4034155..9bae44b1 100644 --- a/src/server/Broadcaster.hpp +++ b/src/server/Broadcaster.hpp @@ -97,7 +97,7 @@ public: send_plugins_to(Interface*, const BlockFactory::Plugins& plugins); void message(const Message& msg) override { - std::lock_guard lock(_clients_mutex); + const std::lock_guard lock{_clients_mutex}; for (const auto& c : _clients) { if (c != _ignore_client) { c->message(msg); -- cgit v1.2.1