summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorEd Tanous <ed@tanous.net>2024-04-06 23:48:50 +0300
committerEd Tanous <ed@tanous.net>2024-04-11 19:38:16 +0300
commit44106f346d79f6d740d4f756fe55ece78bb7feed (patch)
treea83d6c7f3fe6d8606c291a17fd92a6eb265c5b77 /include
parent4a7fbefdff330f06d5698a1e60ce893225cd389e (diff)
downloadbmcweb-44106f346d79f6d740d4f756fe55ece78bb7feed.tar.xz
Fix buffer_copy
boost::asio::buffer_copy returns an integer of the number of values copied. Some static analysis tools mark that value as nodiscard, although it should never fail. Audit all uses of buffer_copy, and make sure that they're using the return value. In theory this should have no change on the behavior. Change-Id: I6af39b5347954c2932cf3d4e48e96ff9ae01583a Signed-off-by: Ed Tanous <ed@tanous.net>
Diffstat (limited to 'include')
-rw-r--r--include/kvm_websocket.hpp8
-rw-r--r--include/nbd_proxy.hpp6
-rw-r--r--include/vm_websocket.hpp7
3 files changed, 11 insertions, 10 deletions
diff --git a/include/kvm_websocket.hpp b/include/kvm_websocket.hpp
index 0089ae375b..df13a67461 100644
--- a/include/kvm_websocket.hpp
+++ b/include/kvm_websocket.hpp
@@ -52,11 +52,11 @@ class KvmSession : public std::enable_shared_from_this<KvmSession>
BMCWEB_LOG_DEBUG("conn:{}, Read {} bytes from websocket", logPtr(&conn),
data.size());
- boost::asio::buffer_copy(inputBuffer.prepare(data.size()),
- boost::asio::buffer(data));
+ size_t copied = boost::asio::buffer_copy(
+ inputBuffer.prepare(data.size()), boost::asio::buffer(data));
BMCWEB_LOG_DEBUG("conn:{}, Committing {} bytes from websocket",
- logPtr(&conn), data.size());
- inputBuffer.commit(data.size());
+ logPtr(&conn), copied);
+ inputBuffer.commit(copied);
BMCWEB_LOG_DEBUG("conn:{}, inputbuffer size {}", logPtr(&conn),
inputBuffer.size());
diff --git a/include/nbd_proxy.hpp b/include/nbd_proxy.hpp
index 17d57b4c15..838e7a1d2c 100644
--- a/include/nbd_proxy.hpp
+++ b/include/nbd_proxy.hpp
@@ -125,9 +125,9 @@ struct NbdProxyServer : std::enable_shared_from_this<NbdProxyServer>
void send(std::string_view buffer, std::function<void()>&& onDone)
{
- boost::asio::buffer_copy(ws2uxBuf.prepare(buffer.size()),
- boost::asio::buffer(buffer));
- ws2uxBuf.commit(buffer.size());
+ size_t copied = boost::asio::buffer_copy(
+ ws2uxBuf.prepare(buffer.size()), boost::asio::buffer(buffer));
+ ws2uxBuf.commit(copied);
doWrite(std::move(onDone));
}
diff --git a/include/vm_websocket.hpp b/include/vm_websocket.hpp
index 13bbdc6b23..19054a6d97 100644
--- a/include/vm_websocket.hpp
+++ b/include/vm_websocket.hpp
@@ -215,9 +215,10 @@ inline void requestRoutes(App& app)
return;
}
- boost::asio::buffer_copy(handler->inputBuffer->prepare(data.size()),
- boost::asio::buffer(data));
- handler->inputBuffer->commit(data.size());
+ size_t copied =
+ boost::asio::buffer_copy(handler->inputBuffer->prepare(data.size()),
+ boost::asio::buffer(data));
+ handler->inputBuffer->commit(copied);
handler->doWrite();
});
}