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>
diff --git a/http/app.hpp b/http/app.hpp
index 1a7af83..eeb331e 100644
--- a/http/app.hpp
+++ b/http/app.hpp
@@ -63,7 +63,7 @@
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 0ed4777..49a9cba 100644
--- a/http/logging.hpp
+++ b/http/logging.hpp
@@ -182,7 +182,7 @@
}
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 921bfe8..7872b76 100644
--- a/http/routing.hpp
+++ b/http/routing.hpp
@@ -605,7 +605,7 @@
// 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 2ef8412..4262c70 100644
--- a/http/websocket.hpp
+++ b/http/websocket.hpp
@@ -36,11 +36,9 @@
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 @@
});
}
- 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 @@
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(