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>
diff --git a/http/server_sent_event.hpp b/http/server_sent_event.hpp
index 0e1cd62..1b644fc 100644
--- a/http/server_sent_event.hpp
+++ b/http/server_sent_event.hpp
@@ -228,9 +228,9 @@
         }
         rawData += "\n\n";
 
-        boost::asio::buffer_copy(inputBuffer.prepare(rawData.size()),
-                                 boost::asio::buffer(rawData));
-        inputBuffer.commit(rawData.size());
+        size_t copied = boost::asio::buffer_copy(
+            inputBuffer.prepare(rawData.size()), boost::asio::buffer(rawData));
+        inputBuffer.commit(copied);
     }
 
     void startTimeout()
diff --git a/include/kvm_websocket.hpp b/include/kvm_websocket.hpp
index 0089ae3..df13a67 100644
--- a/include/kvm_websocket.hpp
+++ b/include/kvm_websocket.hpp
@@ -52,11 +52,11 @@
 
         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 17d57b4..838e7a1 100644
--- a/include/nbd_proxy.hpp
+++ b/include/nbd_proxy.hpp
@@ -125,9 +125,9 @@
 
     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 13bbdc6..19054a6 100644
--- a/include/vm_websocket.hpp
+++ b/include/vm_websocket.hpp
@@ -215,9 +215,10 @@
             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();
     });
 }