wsd: reduce directives for unused variable supression
We use [[maybe_unused]] to reduce explicit supression especially under compile-time directives. Change-Id: Ic5f3f3227a80efe52097cb35520d05b9cdaacb42 Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>pull/8503/head
parent
4a3e10e4a9
commit
d57baeb906
|
@ -15,14 +15,8 @@
|
||||||
|
|
||||||
#include <common/TraceEvent.hpp>
|
#include <common/TraceEvent.hpp>
|
||||||
|
|
||||||
void TraceEvent::emitOneRecordingIfEnabled(const std::string &recording)
|
void TraceEvent::emitOneRecordingIfEnabled([[maybe_unused]] const std::string& recording) {}
|
||||||
{
|
|
||||||
(void) recording;
|
|
||||||
}
|
|
||||||
|
|
||||||
void TraceEvent::emitOneRecording(const std::string &recording)
|
void TraceEvent::emitOneRecording([[maybe_unused]] const std::string& recording) {}
|
||||||
{
|
|
||||||
(void) recording;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|
||||||
|
|
|
@ -72,18 +72,14 @@ namespace RenderTiles
|
||||||
return nextId;
|
return nextId;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool doRender(std::shared_ptr<lok::Document> document,
|
bool doRender(
|
||||||
DeltaGenerator &deltaGen,
|
std::shared_ptr<lok::Document> document, DeltaGenerator& deltaGen,
|
||||||
TileCombined &tileCombined,
|
TileCombined& tileCombined, ThreadPool& pngPool,
|
||||||
ThreadPool &pngPool,
|
const std::function<void(unsigned char* data, int offsetX, int offsetY, size_t pixmapWidth,
|
||||||
const std::function<void (unsigned char *data,
|
size_t pixmapHeight, int pixelWidth, int pixelHeight,
|
||||||
int offsetX, int offsetY,
|
LibreOfficeKitTileMode mode)>& blendWatermark,
|
||||||
size_t pixmapWidth, size_t pixmapHeight,
|
const std::function<void(const char* buffer, size_t length)>& outputMessage,
|
||||||
int pixelWidth, int pixelHeight,
|
[[maybe_unused]] unsigned mobileAppDocId, int canonicalViewId, bool dumpTiles)
|
||||||
LibreOfficeKitTileMode mode)>& blendWatermark,
|
|
||||||
const std::function<void (const char *buffer, size_t length)>& outputMessage,
|
|
||||||
unsigned mobileAppDocId,
|
|
||||||
int canonicalViewId, bool dumpTiles)
|
|
||||||
{
|
{
|
||||||
const auto& tiles = tileCombined.getTiles();
|
const auto& tiles = tileCombined.getTiles();
|
||||||
|
|
||||||
|
@ -145,8 +141,6 @@ namespace RenderTiles
|
||||||
<< renderArea.getWidth() << ", " << renderArea.getHeight() << ") "
|
<< renderArea.getWidth() << ", " << renderArea.getHeight() << ") "
|
||||||
<< " took " << elapsedUs << " (" << area / elapsedUs.count() << " MP/s).");
|
<< " took " << elapsedUs << " (" << area / elapsedUs.count() << " MP/s).");
|
||||||
|
|
||||||
(void) mobileAppDocId;
|
|
||||||
|
|
||||||
const auto mode = static_cast<LibreOfficeKitTileMode>(document->getTileMode());
|
const auto mode = static_cast<LibreOfficeKitTileMode>(document->getTileMode());
|
||||||
|
|
||||||
const size_t pixmapSize = 4 * pixmapWidth * pixmapHeight;
|
const size_t pixmapSize = 4 * pixmapWidth * pixmapHeight;
|
||||||
|
|
|
@ -102,10 +102,8 @@ static void handleSysSignal(int /* signal */,
|
||||||
|
|
||||||
namespace Seccomp {
|
namespace Seccomp {
|
||||||
|
|
||||||
bool lockdown(Type type)
|
bool lockdown([[maybe_unused]] Type type)
|
||||||
{
|
{
|
||||||
(void)type; // so far just the kit.
|
|
||||||
|
|
||||||
#if DISABLE_SECCOMP == 0
|
#if DISABLE_SECCOMP == 0
|
||||||
#define ACCEPT_SYSCALL(name) \
|
#define ACCEPT_SYSCALL(name) \
|
||||||
BPF_JUMP(BPF_JMP+BPF_JEQ+BPF_K, __NR_##name, 0, 1), \
|
BPF_JUMP(BPF_JMP+BPF_JEQ+BPF_K, __NR_##name, 0, 1), \
|
||||||
|
|
|
@ -105,7 +105,7 @@ void requestShutdown()
|
||||||
#endif
|
#endif
|
||||||
#endif // !IOS
|
#endif // !IOS
|
||||||
|
|
||||||
void checkDumpGlobalState(GlobalDumpStateFn dumpState)
|
void checkDumpGlobalState([[maybe_unused]] GlobalDumpStateFn dumpState)
|
||||||
{
|
{
|
||||||
#if !MOBILEAPP
|
#if !MOBILEAPP
|
||||||
assert(dumpState && "Invalid callback for checkDumpGlobalState");
|
assert(dumpState && "Invalid callback for checkDumpGlobalState");
|
||||||
|
@ -114,12 +114,10 @@ void requestShutdown()
|
||||||
DumpGlobalState = false;
|
DumpGlobalState = false;
|
||||||
dumpState();
|
dumpState();
|
||||||
}
|
}
|
||||||
#else
|
|
||||||
(void) dumpState;
|
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
void checkForwardSigUsr2(ForwardSigUsr2Fn forwardSigUsr2)
|
void checkForwardSigUsr2([[maybe_unused]] ForwardSigUsr2Fn forwardSigUsr2)
|
||||||
{
|
{
|
||||||
#if !MOBILEAPP
|
#if !MOBILEAPP
|
||||||
assert(forwardSigUsr2 && "Invalid callback for checkForwardSigUsr2");
|
assert(forwardSigUsr2 && "Invalid callback for checkForwardSigUsr2");
|
||||||
|
@ -128,8 +126,6 @@ void requestShutdown()
|
||||||
ForwardSigUsr2Flag = false;
|
ForwardSigUsr2Flag = false;
|
||||||
forwardSigUsr2();
|
forwardSigUsr2();
|
||||||
}
|
}
|
||||||
#else
|
|
||||||
(void) forwardSigUsr2;
|
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -54,7 +54,8 @@ std::condition_variable TimeoutConditionVariable;
|
||||||
/// Controls whether experimental features/behavior is enabled or not.
|
/// Controls whether experimental features/behavior is enabled or not.
|
||||||
bool EnableExperimental = false;
|
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
|
#if !MOBILEAPP
|
||||||
DlHandle = dlopen(unitLibPath.c_str(), RTLD_GLOBAL|RTLD_NOW);
|
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 };
|
return new UnitBase* [2] { hooks, nullptr };
|
||||||
|
|
||||||
LOG_ERR("No wsd unit-tests found in " << unitLibPath);
|
LOG_ERR("No wsd unit-tests found in " << unitLibPath);
|
||||||
#else
|
|
||||||
(void) type;
|
|
||||||
(void) unitLibPath;
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
return nullptr;
|
return nullptr;
|
||||||
|
|
|
@ -227,21 +227,16 @@ namespace Util
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/// Assert that a lock is already taken.
|
/// Assert that a lock is already taken.
|
||||||
template <typename T>
|
template <typename T> void assertIsLocked([[maybe_unused]] const T& lock)
|
||||||
void assertIsLocked(const T& lock)
|
|
||||||
{
|
{
|
||||||
#ifdef NDEBUG
|
#ifndef NDEBUG
|
||||||
(void) lock;
|
|
||||||
#else
|
|
||||||
assert(lock.owns_lock());
|
assert(lock.owns_lock());
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
inline void assertIsLocked(std::mutex& mtx)
|
inline void assertIsLocked([[maybe_unused]] std::mutex& mtx)
|
||||||
{
|
{
|
||||||
#ifdef NDEBUG
|
#ifndef NDEBUG
|
||||||
(void) mtx;
|
|
||||||
#else
|
|
||||||
assert(!mtx.try_lock());
|
assert(!mtx.try_lock());
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
|
@ -62,10 +62,9 @@ inline int isInContainer()
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline int hasCorrectUID(const char *appName)
|
inline int hasCorrectUID([[maybe_unused]] const char* appName)
|
||||||
{
|
{
|
||||||
#if ENABLE_DEBUG
|
#if ENABLE_DEBUG
|
||||||
(void)appName;
|
|
||||||
return 1; // insecure but easy to use.
|
return 1; // insecure but easy to use.
|
||||||
#else
|
#else
|
||||||
if (hasUID(COOL_USER_ID))
|
if (hasUID(COOL_USER_ID))
|
||||||
|
|
|
@ -325,24 +325,21 @@ class DeltaGenerator {
|
||||||
DeltaData(const DeltaData&) = delete;
|
DeltaData(const DeltaData&) = delete;
|
||||||
DeltaData& operator=(const DeltaData&) = delete;
|
DeltaData& operator=(const DeltaData&) = delete;
|
||||||
|
|
||||||
DeltaData (TileWireId wid,
|
DeltaData(TileWireId wid, unsigned char* pixmap, size_t startX, size_t startY, int width,
|
||||||
unsigned char* pixmap, size_t startX, size_t startY,
|
int height, const TileLocation& loc, int bufferWidth,
|
||||||
int width, int height,
|
[[maybe_unused]] int bufferHeight)
|
||||||
const TileLocation &loc, int bufferWidth, int bufferHeight
|
: _loc(loc)
|
||||||
) :
|
, _inUse(false)
|
||||||
_loc(loc),
|
, _wid(wid)
|
||||||
_inUse(false),
|
,
|
||||||
_wid(wid),
|
|
||||||
// in Pixels
|
// in Pixels
|
||||||
_width(width),
|
_width(width)
|
||||||
_height(height),
|
, _height(height)
|
||||||
_rows(new DeltaBitmapRow[height])
|
, _rows(new DeltaBitmapRow[height])
|
||||||
{
|
{
|
||||||
assert (startX + width <= (size_t)bufferWidth);
|
assert (startX + width <= (size_t)bufferWidth);
|
||||||
assert (startY + height <= (size_t)bufferHeight);
|
assert (startY + height <= (size_t)bufferHeight);
|
||||||
|
|
||||||
(void)bufferHeight;
|
|
||||||
|
|
||||||
LOG_TRC("Converting pixel data to delta data of size "
|
LOG_TRC("Converting pixel data to delta data of size "
|
||||||
<< (width * height * 4) << " width " << width
|
<< (width * height * 4) << " width " << width
|
||||||
<< " height " << height);
|
<< " height " << height);
|
||||||
|
|
|
@ -222,7 +222,7 @@ namespace
|
||||||
unsigned linkOrCopyFileCount = 0; // Track to help quantify the link-or-copy performance.
|
unsigned linkOrCopyFileCount = 0; // Track to help quantify the link-or-copy performance.
|
||||||
constexpr unsigned SlowLinkOrCopyLimitInSecs = 2; // After this many seconds, start spamming the logs.
|
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__
|
#ifdef __linux__
|
||||||
#ifndef OVERLAYFS_SUPER_MAGIC
|
#ifndef OVERLAYFS_SUPER_MAGIC
|
||||||
|
@ -243,7 +243,6 @@ namespace
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
(void)directory;
|
|
||||||
return false;
|
return false;
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
|
@ -61,7 +61,7 @@ std::atomic<bool> Socket::InhibitThreadChecks(false);
|
||||||
|
|
||||||
#define SOCKET_ABSTRACT_UNIX_NAME "0coolwsd-"
|
#define SOCKET_ABSTRACT_UNIX_NAME "0coolwsd-"
|
||||||
|
|
||||||
int Socket::createSocket(Socket::Type type)
|
int Socket::createSocket([[maybe_unused]] Socket::Type type)
|
||||||
{
|
{
|
||||||
#if !MOBILEAPP
|
#if !MOBILEAPP
|
||||||
int domain = AF_UNSPEC;
|
int domain = AF_UNSPEC;
|
||||||
|
@ -76,7 +76,6 @@ int Socket::createSocket(Socket::Type type)
|
||||||
|
|
||||||
return socket(domain, SOCK_STREAM | SOCK_NONBLOCK | SOCK_CLOEXEC, 0);
|
return socket(domain, SOCK_STREAM | SOCK_NONBLOCK | SOCK_CLOEXEC, 0);
|
||||||
#else
|
#else
|
||||||
(void) type;
|
|
||||||
return fakeSocketSocket();
|
return fakeSocketSocket();
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
@ -819,7 +818,7 @@ void SocketPoll::dumpState(std::ostream& os) const
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Returns true on success only.
|
/// 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
|
#if !MOBILEAPP
|
||||||
// Enable address reuse to avoid stalling after
|
// Enable address reuse to avoid stalling after
|
||||||
|
@ -873,9 +872,6 @@ bool ServerSocket::bind(Type type, int port)
|
||||||
|
|
||||||
return rc == 0;
|
return rc == 0;
|
||||||
#else
|
#else
|
||||||
(void) type;
|
|
||||||
(void) port;
|
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
|
@ -67,7 +67,7 @@ public:
|
||||||
/// isClient: the instance should behave like a client (true) or like a server (false)
|
/// isClient: the instance should behave like a client (true) or like a server (false)
|
||||||
/// (from websocket perspective)
|
/// (from websocket perspective)
|
||||||
/// isMasking: a client should mask (true) or not (false) outgoing frames
|
/// 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
|
#if !MOBILEAPP
|
||||||
_lastPingSentTime(std::chrono::steady_clock::now() -
|
_lastPingSentTime(std::chrono::steady_clock::now() -
|
||||||
|
@ -84,9 +84,6 @@ public:
|
||||||
, _isClient(isClient)
|
, _isClient(isClient)
|
||||||
, _unit(UnitBase::isUnitTesting() ? &UnitBase::get() : nullptr)
|
, _unit(UnitBase::isUnitTesting() ? &UnitBase::get() : nullptr)
|
||||||
{
|
{
|
||||||
#if MOBILEAPP
|
|
||||||
(void) isMasking;
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Upgrades itself to a websocket directly.
|
/// Upgrades itself to a websocket directly.
|
||||||
|
@ -550,8 +547,8 @@ protected:
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int getPollEvents(std::chrono::steady_clock::time_point now,
|
int getPollEvents([[maybe_unused]] std::chrono::steady_clock::time_point now,
|
||||||
int64_t & timeoutMaxMicroS) override
|
[[maybe_unused]] int64_t& timeoutMaxMicroS) override
|
||||||
{
|
{
|
||||||
#if !MOBILEAPP
|
#if !MOBILEAPP
|
||||||
if (!_isClient)
|
if (!_isClient)
|
||||||
|
@ -561,9 +558,6 @@ protected:
|
||||||
timeoutMaxMicroS
|
timeoutMaxMicroS
|
||||||
= std::min(timeoutMaxMicroS, (int64_t)(PingFrequencyMicroS - timeSincePingMicroS).count());
|
= std::min(timeoutMaxMicroS, (int64_t)(PingFrequencyMicroS - timeSincePingMicroS).count());
|
||||||
}
|
}
|
||||||
#else
|
|
||||||
(void) now;
|
|
||||||
(void) timeoutMaxMicroS;
|
|
||||||
#endif
|
#endif
|
||||||
int events = POLLIN;
|
int events = POLLIN;
|
||||||
if (_msgHandler && _msgHandler->hasQueuedMessages())
|
if (_msgHandler && _msgHandler->hasQueuedMessages())
|
||||||
|
@ -612,7 +606,7 @@ public:
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/// Do we need to handle a timeout ?
|
/// 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 !MOBILEAPP
|
||||||
if (_isClient)
|
if (_isClient)
|
||||||
|
@ -626,8 +620,6 @@ public:
|
||||||
if (socket)
|
if (socket)
|
||||||
sendPing(now, socket);
|
sendPing(now, socket);
|
||||||
}
|
}
|
||||||
#else
|
|
||||||
(void) now;
|
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -759,9 +751,8 @@ protected:
|
||||||
/// Sends a WebSocket frame given the data, length, and flags.
|
/// Sends a WebSocket frame given the data, length, and flags.
|
||||||
/// Returns the number of bytes written (including frame overhead) on success,
|
/// Returns the number of bytes written (including frame overhead) on success,
|
||||||
/// 0 for closed/invalid socket, and -1 for other errors.
|
/// 0 for closed/invalid socket, and -1 for other errors.
|
||||||
int sendFrame(const std::shared_ptr<StreamSocket>& socket,
|
int sendFrame(const std::shared_ptr<StreamSocket>& socket, const char* data, const uint64_t len,
|
||||||
const char* data, const uint64_t len,
|
[[maybe_unused]] unsigned char flags, bool flush = true) const
|
||||||
unsigned char flags, bool flush = true) const
|
|
||||||
{
|
{
|
||||||
if (!socket || data == nullptr || len == 0)
|
if (!socket || data == nullptr || len == 0)
|
||||||
return -1;
|
return -1;
|
||||||
|
@ -827,8 +818,6 @@ protected:
|
||||||
// Return the number of bytes we wrote to the *buffer*.
|
// Return the number of bytes we wrote to the *buffer*.
|
||||||
const size_t size = out.size() - oldSize;
|
const size_t size = out.size() - oldSize;
|
||||||
#else
|
#else
|
||||||
(void) flags;
|
|
||||||
|
|
||||||
// We ignore the flush parameter and always flush in the MOBILEAPP case because there is no
|
// 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.
|
// WebSocket framing, we put the messages as such into the FakeSocket queue.
|
||||||
flush = true;
|
flush = true;
|
||||||
|
@ -933,7 +922,8 @@ protected:
|
||||||
|
|
||||||
/// Upgrade the http(s) connection to a websocket.
|
/// Upgrade the http(s) connection to a websocket.
|
||||||
template <typename T>
|
template <typename T>
|
||||||
void upgradeToWebSocket(const std::shared_ptr<StreamSocket>& socket, const T& req)
|
void upgradeToWebSocket(const std::shared_ptr<StreamSocket>& socket,
|
||||||
|
[[maybe_unused]] const T& req)
|
||||||
{
|
{
|
||||||
assert(socket && "Must have a valid socket");
|
assert(socket && "Must have a valid socket");
|
||||||
LOG_TRC("Upgrading to WebSocket");
|
LOG_TRC("Upgrading to WebSocket");
|
||||||
|
@ -960,8 +950,6 @@ protected:
|
||||||
httpResponse.set("Sec-WebSocket-Accept", computeAccept(wsKey));
|
httpResponse.set("Sec-WebSocket-Accept", computeAccept(wsKey));
|
||||||
LOG_TRC("Sending WS Upgrade response: " << httpResponse.header().toString());
|
LOG_TRC("Sending WS Upgrade response: " << httpResponse.header().toString());
|
||||||
socket->send(httpResponse);
|
socket->send(httpResponse);
|
||||||
#else
|
|
||||||
(void) req;
|
|
||||||
#endif
|
#endif
|
||||||
setWebSocket(socket);
|
setWebSocket(socket);
|
||||||
}
|
}
|
||||||
|
|
|
@ -495,18 +495,16 @@ class LocalStorage : public StorageBase
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
LocalStorage(const Poco::URI& uri, const std::string& localStorePath,
|
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)
|
: StorageBase(uri, localStorePath, jailPath)
|
||||||
#if !MOBILEAPP
|
#if !MOBILEAPP
|
||||||
, _isTemporaryFile(isTemporaryFile)
|
, _isTemporaryFile(isTemporaryFile)
|
||||||
#endif
|
#endif
|
||||||
, _isCopy(false)
|
, _isCopy(false)
|
||||||
{
|
{
|
||||||
LOG_INF("LocalStorage ctor with localStorePath: [" << localStorePath <<
|
LOG_INF("LocalStorage ctor with localStorePath: ["
|
||||||
"], jailPath: [" << jailPath << "], uri: [" << COOLWSD::anonymizeUrl(uri.toString()) << "].");
|
<< localStorePath << "], jailPath: [" << jailPath << "], uri: ["
|
||||||
#if MOBILEAPP
|
<< COOLWSD::anonymizeUrl(uri.toString()) << "].");
|
||||||
(void) isTemporaryFile;
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
class LocalFileInfo
|
class LocalFileInfo
|
||||||
|
|
Loading…
Reference in New Issue