diff options
author | Ed Tanous <ed@tanous.net> | 2024-03-28 02:31:46 +0300 |
---|---|---|
committer | Ed Tanous <ed@tanous.net> | 2024-04-07 21:09:42 +0300 |
commit | 8cb2c024c4625e2fe2f0b107a865faffcd4bb770 (patch) | |
tree | 252d85214747ab3b9ae784b08b0f07ec31ea0c13 /http | |
parent | dce4d230c52978fc258ee3bc31117389d9c25388 (diff) | |
download | bmcweb-8cb2c024c4625e2fe2f0b107a865faffcd4bb770.tar.xz |
Fix moves/forward
Clang has new checks for std::move/std::forward correctness, which
catches quite a few "wrong" things where we were making copies of
callback handlers.
Unfortunately, the lambda syntax of
callback{std::forward<Callback>(callback)}
in a capture confuses it, so change usages to
callback = std::forward<Callback>(callback)
to be consistent.
Tested: Redfish service validator passes.
Change-Id: I7a111ec00cf78ecb7d5f5b102c786c1c14d74384
Signed-off-by: Ed Tanous <ed@tanous.net>
Diffstat (limited to 'http')
-rw-r--r-- | http/app.hpp | 2 | ||||
-rw-r--r-- | http/logging.hpp | 2 | ||||
-rw-r--r-- | http/routing.hpp | 2 | ||||
-rw-r--r-- | http/websocket.hpp | 18 |
4 files changed, 3 insertions, 21 deletions
diff --git a/http/app.hpp b/http/app.hpp index 1a7af83241..eeb331ea96 100644 --- a/http/app.hpp +++ b/http/app.hpp @@ -63,7 +63,7 @@ class App router.handle(req, asyncResp); } - DynamicRule& routeDynamic(std::string&& rule) + DynamicRule& routeDynamic(const std::string& rule) { return router.newRuleDynamic(rule); } diff --git a/http/logging.hpp b/http/logging.hpp index 0ed47771c4..49a9cbaaf0 100644 --- a/http/logging.hpp +++ b/http/logging.hpp @@ -182,7 +182,7 @@ const void* logPtr(T p) } template <LogLevel level> -inline void vlog(const FormatString& format, std::format_args&& args) +inline void vlog(const FormatString& format, const std::format_args& args) { if constexpr (bmcwebCurrentLoggingLevel < level) { diff --git a/http/routing.hpp b/http/routing.hpp index 921bfe8dc0..7872b76cb5 100644 --- a/http/routing.hpp +++ b/http/routing.hpp @@ -605,7 +605,7 @@ class Router // appear to work with the std::move on adaptor. validatePrivilege( req, asyncResp, rule, - [&rule, asyncResp, adaptor(std::forward<Adaptor>(adaptor))]( + [&rule, asyncResp, adaptor = std::forward<Adaptor>(adaptor)]( Request& thisReq) mutable { rule.handleUpgrade(thisReq, asyncResp, std::move(adaptor)); }); diff --git a/http/websocket.hpp b/http/websocket.hpp index 2ef8412886..4262c70a5c 100644 --- a/http/websocket.hpp +++ b/http/websocket.hpp @@ -36,11 +36,9 @@ struct Connection : std::enable_shared_from_this<Connection> Connection& operator=(const Connection&&) = delete; virtual void sendBinary(std::string_view msg) = 0; - virtual void sendBinary(std::string&& msg) = 0; virtual void sendEx(MessageType type, std::string_view msg, std::function<void()>&& onDone) = 0; virtual void sendText(std::string_view msg) = 0; - virtual void sendText(std::string&& msg) = 0; virtual void close(std::string_view msg = "quit") = 0; virtual void deferRead() = 0; virtual void resumeRead() = 0; @@ -181,14 +179,6 @@ class ConnectionImpl : public Connection }); } - void sendBinary(std::string&& msg) override - { - ws.binary(true); - outBuffer.commit(boost::asio::buffer_copy(outBuffer.prepare(msg.size()), - boost::asio::buffer(msg))); - doWrite(); - } - void sendText(std::string_view msg) override { ws.text(true); @@ -197,14 +187,6 @@ class ConnectionImpl : public Connection doWrite(); } - void sendText(std::string&& msg) override - { - ws.text(true); - outBuffer.commit(boost::asio::buffer_copy(outBuffer.prepare(msg.size()), - boost::asio::buffer(msg))); - doWrite(); - } - void close(std::string_view msg) override { ws.async_close( |