diff --git a/common/DummyTraceEventEmitter.cpp b/common/DummyTraceEventEmitter.cpp index 0e36bb9b1e..ea2d010b39 100644 --- a/common/DummyTraceEventEmitter.cpp +++ b/common/DummyTraceEventEmitter.cpp @@ -15,14 +15,8 @@ #include -void TraceEvent::emitOneRecordingIfEnabled(const std::string &recording) -{ - (void) recording; -} +void TraceEvent::emitOneRecordingIfEnabled([[maybe_unused]] const std::string& recording) {} -void TraceEvent::emitOneRecording(const std::string &recording) -{ - (void) recording; -} +void TraceEvent::emitOneRecording([[maybe_unused]] const std::string& recording) {} /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/common/RenderTiles.hpp b/common/RenderTiles.hpp index 388feae3b0..8277517601 100644 --- a/common/RenderTiles.hpp +++ b/common/RenderTiles.hpp @@ -72,18 +72,14 @@ namespace RenderTiles return nextId; } - bool doRender(std::shared_ptr document, - DeltaGenerator &deltaGen, - TileCombined &tileCombined, - ThreadPool &pngPool, - const std::function& blendWatermark, - const std::function& outputMessage, - unsigned mobileAppDocId, - int canonicalViewId, bool dumpTiles) + bool doRender( + std::shared_ptr document, DeltaGenerator& deltaGen, + TileCombined& tileCombined, ThreadPool& pngPool, + const std::function& blendWatermark, + const std::function& outputMessage, + [[maybe_unused]] unsigned mobileAppDocId, int canonicalViewId, bool dumpTiles) { const auto& tiles = tileCombined.getTiles(); @@ -145,8 +141,6 @@ namespace RenderTiles << renderArea.getWidth() << ", " << renderArea.getHeight() << ") " << " took " << elapsedUs << " (" << area / elapsedUs.count() << " MP/s)."); - (void) mobileAppDocId; - const auto mode = static_cast(document->getTileMode()); const size_t pixmapSize = 4 * pixmapWidth * pixmapHeight; diff --git a/common/Seccomp.cpp b/common/Seccomp.cpp index 90d4fcab2a..9308efe90b 100644 --- a/common/Seccomp.cpp +++ b/common/Seccomp.cpp @@ -102,10 +102,8 @@ static void handleSysSignal(int /* signal */, namespace Seccomp { -bool lockdown(Type type) +bool lockdown([[maybe_unused]] Type type) { - (void)type; // so far just the kit. - #if DISABLE_SECCOMP == 0 #define ACCEPT_SYSCALL(name) \ BPF_JUMP(BPF_JMP+BPF_JEQ+BPF_K, __NR_##name, 0, 1), \ diff --git a/common/SigUtil.cpp b/common/SigUtil.cpp index 80da04a314..697f8d3724 100644 --- a/common/SigUtil.cpp +++ b/common/SigUtil.cpp @@ -105,7 +105,7 @@ void requestShutdown() #endif #endif // !IOS - void checkDumpGlobalState(GlobalDumpStateFn dumpState) + void checkDumpGlobalState([[maybe_unused]] GlobalDumpStateFn dumpState) { #if !MOBILEAPP assert(dumpState && "Invalid callback for checkDumpGlobalState"); @@ -114,12 +114,10 @@ void requestShutdown() DumpGlobalState = false; dumpState(); } -#else - (void) dumpState; #endif } - void checkForwardSigUsr2(ForwardSigUsr2Fn forwardSigUsr2) + void checkForwardSigUsr2([[maybe_unused]] ForwardSigUsr2Fn forwardSigUsr2) { #if !MOBILEAPP assert(forwardSigUsr2 && "Invalid callback for checkForwardSigUsr2"); @@ -128,8 +126,6 @@ void requestShutdown() ForwardSigUsr2Flag = false; forwardSigUsr2(); } -#else - (void) forwardSigUsr2; #endif } diff --git a/common/Unit.cpp b/common/Unit.cpp index f545ec7929..de2b27a0fa 100644 --- a/common/Unit.cpp +++ b/common/Unit.cpp @@ -54,7 +54,8 @@ std::condition_variable TimeoutConditionVariable; /// Controls whether experimental features/behavior is enabled or not. bool EnableExperimental = false; -UnitBase** UnitBase::linkAndCreateUnit(UnitType type, const std::string& unitLibPath) +UnitBase** UnitBase::linkAndCreateUnit([[maybe_unused]] UnitType type, + [[maybe_unused]] const std::string& unitLibPath) { #if !MOBILEAPP DlHandle = dlopen(unitLibPath.c_str(), RTLD_GLOBAL|RTLD_NOW); @@ -124,9 +125,6 @@ UnitBase** UnitBase::linkAndCreateUnit(UnitType type, const std::string& unitLib return new UnitBase* [2] { hooks, nullptr }; LOG_ERR("No wsd unit-tests found in " << unitLibPath); -#else - (void) type; - (void) unitLibPath; #endif return nullptr; diff --git a/common/Util.hpp b/common/Util.hpp index c10673bca4..a57ae2796d 100644 --- a/common/Util.hpp +++ b/common/Util.hpp @@ -227,21 +227,16 @@ namespace Util #endif /// Assert that a lock is already taken. - template - void assertIsLocked(const T& lock) + template void assertIsLocked([[maybe_unused]] const T& lock) { -#ifdef NDEBUG - (void) lock; -#else +#ifndef NDEBUG assert(lock.owns_lock()); #endif } - inline void assertIsLocked(std::mutex& mtx) + inline void assertIsLocked([[maybe_unused]] std::mutex& mtx) { -#ifdef NDEBUG - (void) mtx; -#else +#ifndef NDEBUG assert(!mtx.try_lock()); #endif } diff --git a/common/security.h b/common/security.h index ba7846199d..097cd79e84 100644 --- a/common/security.h +++ b/common/security.h @@ -62,10 +62,9 @@ inline int isInContainer() return 0; } -inline int hasCorrectUID(const char *appName) +inline int hasCorrectUID([[maybe_unused]] const char* appName) { #if ENABLE_DEBUG - (void)appName; return 1; // insecure but easy to use. #else if (hasUID(COOL_USER_ID)) diff --git a/kit/Delta.hpp b/kit/Delta.hpp index 494cba9678..32a6cfb361 100644 --- a/kit/Delta.hpp +++ b/kit/Delta.hpp @@ -325,24 +325,21 @@ class DeltaGenerator { DeltaData(const DeltaData&) = delete; DeltaData& operator=(const DeltaData&) = delete; - DeltaData (TileWireId wid, - unsigned char* pixmap, size_t startX, size_t startY, - int width, int height, - const TileLocation &loc, int bufferWidth, int bufferHeight - ) : - _loc(loc), - _inUse(false), - _wid(wid), + DeltaData(TileWireId wid, unsigned char* pixmap, size_t startX, size_t startY, int width, + int height, const TileLocation& loc, int bufferWidth, + [[maybe_unused]] int bufferHeight) + : _loc(loc) + , _inUse(false) + , _wid(wid) + , // in Pixels - _width(width), - _height(height), - _rows(new DeltaBitmapRow[height]) + _width(width) + , _height(height) + , _rows(new DeltaBitmapRow[height]) { assert (startX + width <= (size_t)bufferWidth); assert (startY + height <= (size_t)bufferHeight); - (void)bufferHeight; - LOG_TRC("Converting pixel data to delta data of size " << (width * height * 4) << " width " << width << " height " << height); diff --git a/kit/Kit.cpp b/kit/Kit.cpp index 97577215fb..14650f6a19 100644 --- a/kit/Kit.cpp +++ b/kit/Kit.cpp @@ -222,7 +222,7 @@ namespace unsigned linkOrCopyFileCount = 0; // Track to help quantify the link-or-copy performance. constexpr unsigned SlowLinkOrCopyLimitInSecs = 2; // After this many seconds, start spamming the logs. - bool detectSlowStackingFileSystem(const std::string &directory) + bool detectSlowStackingFileSystem([[maybe_unused]] const std::string& directory) { #ifdef __linux__ #ifndef OVERLAYFS_SUPER_MAGIC @@ -243,7 +243,6 @@ namespace return false; } #else - (void)directory; return false; #endif } diff --git a/net/Socket.cpp b/net/Socket.cpp index 03892e5422..7331f07ef5 100644 --- a/net/Socket.cpp +++ b/net/Socket.cpp @@ -61,7 +61,7 @@ std::atomic Socket::InhibitThreadChecks(false); #define SOCKET_ABSTRACT_UNIX_NAME "0coolwsd-" -int Socket::createSocket(Socket::Type type) +int Socket::createSocket([[maybe_unused]] Socket::Type type) { #if !MOBILEAPP int domain = AF_UNSPEC; @@ -76,7 +76,6 @@ int Socket::createSocket(Socket::Type type) return socket(domain, SOCK_STREAM | SOCK_NONBLOCK | SOCK_CLOEXEC, 0); #else - (void) type; return fakeSocketSocket(); #endif } @@ -819,7 +818,7 @@ void SocketPoll::dumpState(std::ostream& os) const } /// Returns true on success only. -bool ServerSocket::bind(Type type, int port) +bool ServerSocket::bind([[maybe_unused]] Type type, [[maybe_unused]] int port) { #if !MOBILEAPP // Enable address reuse to avoid stalling after @@ -873,9 +872,6 @@ bool ServerSocket::bind(Type type, int port) return rc == 0; #else - (void) type; - (void) port; - return true; #endif } diff --git a/net/WebSocketHandler.hpp b/net/WebSocketHandler.hpp index 926236cbd7..3bf5b649a1 100644 --- a/net/WebSocketHandler.hpp +++ b/net/WebSocketHandler.hpp @@ -67,7 +67,7 @@ public: /// isClient: the instance should behave like a client (true) or like a server (false) /// (from websocket perspective) /// isMasking: a client should mask (true) or not (false) outgoing frames - WebSocketHandler(bool isClient, bool isMasking) + WebSocketHandler(bool isClient, [[maybe_unused]] bool isMasking) : #if !MOBILEAPP _lastPingSentTime(std::chrono::steady_clock::now() - @@ -84,9 +84,6 @@ public: , _isClient(isClient) , _unit(UnitBase::isUnitTesting() ? &UnitBase::get() : nullptr) { -#if MOBILEAPP - (void) isMasking; -#endif } /// Upgrades itself to a websocket directly. @@ -550,8 +547,8 @@ protected: } } - int getPollEvents(std::chrono::steady_clock::time_point now, - int64_t & timeoutMaxMicroS) override + int getPollEvents([[maybe_unused]] std::chrono::steady_clock::time_point now, + [[maybe_unused]] int64_t& timeoutMaxMicroS) override { #if !MOBILEAPP if (!_isClient) @@ -561,9 +558,6 @@ protected: timeoutMaxMicroS = std::min(timeoutMaxMicroS, (int64_t)(PingFrequencyMicroS - timeSincePingMicroS).count()); } -#else - (void) now; - (void) timeoutMaxMicroS; #endif int events = POLLIN; if (_msgHandler && _msgHandler->hasQueuedMessages()) @@ -612,7 +606,7 @@ public: #endif /// Do we need to handle a timeout ? - void checkTimeout(std::chrono::steady_clock::time_point now) override + void checkTimeout([[maybe_unused]] std::chrono::steady_clock::time_point now) override { #if !MOBILEAPP if (_isClient) @@ -626,8 +620,6 @@ public: if (socket) sendPing(now, socket); } -#else - (void) now; #endif } @@ -759,9 +751,8 @@ protected: /// Sends a WebSocket frame given the data, length, and flags. /// Returns the number of bytes written (including frame overhead) on success, /// 0 for closed/invalid socket, and -1 for other errors. - int sendFrame(const std::shared_ptr& socket, - const char* data, const uint64_t len, - unsigned char flags, bool flush = true) const + int sendFrame(const std::shared_ptr& socket, const char* data, const uint64_t len, + [[maybe_unused]] unsigned char flags, bool flush = true) const { if (!socket || data == nullptr || len == 0) return -1; @@ -827,8 +818,6 @@ protected: // Return the number of bytes we wrote to the *buffer*. const size_t size = out.size() - oldSize; #else - (void) flags; - // We ignore the flush parameter and always flush in the MOBILEAPP case because there is no // WebSocket framing, we put the messages as such into the FakeSocket queue. flush = true; @@ -933,7 +922,8 @@ protected: /// Upgrade the http(s) connection to a websocket. template - void upgradeToWebSocket(const std::shared_ptr& socket, const T& req) + void upgradeToWebSocket(const std::shared_ptr& socket, + [[maybe_unused]] const T& req) { assert(socket && "Must have a valid socket"); LOG_TRC("Upgrading to WebSocket"); @@ -960,8 +950,6 @@ protected: httpResponse.set("Sec-WebSocket-Accept", computeAccept(wsKey)); LOG_TRC("Sending WS Upgrade response: " << httpResponse.header().toString()); socket->send(httpResponse); -#else - (void) req; #endif setWebSocket(socket); } diff --git a/wsd/Storage.hpp b/wsd/Storage.hpp index c4608a49f3..785d58b484 100644 --- a/wsd/Storage.hpp +++ b/wsd/Storage.hpp @@ -495,18 +495,16 @@ class LocalStorage : public StorageBase { public: LocalStorage(const Poco::URI& uri, const std::string& localStorePath, - const std::string& jailPath, bool isTemporaryFile) + const std::string& jailPath, [[maybe_unused]] bool isTemporaryFile) : StorageBase(uri, localStorePath, jailPath) #if !MOBILEAPP , _isTemporaryFile(isTemporaryFile) #endif , _isCopy(false) { - LOG_INF("LocalStorage ctor with localStorePath: [" << localStorePath << - "], jailPath: [" << jailPath << "], uri: [" << COOLWSD::anonymizeUrl(uri.toString()) << "]."); -#if MOBILEAPP - (void) isTemporaryFile; -#endif + LOG_INF("LocalStorage ctor with localStorePath: [" + << localStorePath << "], jailPath: [" << jailPath << "], uri: [" + << COOLWSD::anonymizeUrl(uri.toString()) << "]."); } class LocalFileInfo