diff options
author | Ashod Nakashian <ashod.nakashian@collabora.co.uk> | 2022-04-03 20:11:36 -0400 |
---|---|---|
committer | Andras Timar <andras.timar@collabora.com> | 2022-04-21 11:34:59 +0200 |
commit | a115c07c241f15492039adedea607f9fae77d3d0 (patch) | |
tree | 81321ab067d79892447376ecb20eb9d09cc8b314 | |
parent | wsd: fallback only when COOLStatusCode is missing (diff) | |
download | online-a115c07c241f15492039adedea607f9fae77d3d0.tar.gz online-a115c07c241f15492039adedea607f9fae77d3d0.zip |
wsd: minor cleanup of send-frame members
Change-Id: Ic2268780ea815611bf978c0c779ef737facc73fb
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
-rw-r--r-- | common/Session.hpp | 15 |
1 files changed, 12 insertions, 3 deletions
diff --git a/common/Session.hpp b/common/Session.hpp index 0b9f7f7674..63e47d1246 100644 --- a/common/Session.hpp +++ b/common/Session.hpp @@ -120,12 +120,21 @@ public: template <std::size_t N> bool sendTextFrame(const char (&buffer)[N]) { - return (buffer != nullptr && N > 0 ? sendTextFrame(buffer, N) : false); + static_assert(N > 0, "Cannot have string literal with size zero"); + return sendTextFrame(buffer, N - 1); } bool sendTextFrame(const char* buffer) { - return (buffer != nullptr ? sendTextFrame(buffer, std::strlen(buffer)) : false); + return buffer != nullptr && sendTextFrame(buffer, std::strlen(buffer)); + } + + template <std::size_t N> + bool sendTextFrameAndLogError(const char (&buffer)[N]) + { + static_assert(N > 0, "Cannot have string literal with size zero"); + LOG_ERR(buffer); + return sendTextFrame(buffer, N - 1); } bool sendTextFrameAndLogError(const std::string& text) @@ -137,7 +146,7 @@ public: bool sendTextFrameAndLogError(const char* buffer) { LOG_ERR(buffer); - return (buffer != nullptr ? sendTextFrame(buffer, std::strlen(buffer)) : false); + return buffer != nullptr && sendTextFrame(buffer, std::strlen(buffer)); } virtual void handleMessage(const std::vector<char> &data) override; |