Browse Source

[master] make sure 0-clear test buffer to suppress valgrind warnings

confirmed locally, and should be trivial, so I'm committing it directly.
JINMEI Tatuya 12 years ago
parent
commit
38a875a2d8
1 changed files with 4 additions and 1 deletions
  1. 4 1
      src/lib/asiolink/tests/local_socket_unittest.cc

+ 4 - 1
src/lib/asiolink/tests/local_socket_unittest.cc

@@ -22,6 +22,7 @@
 #include <boost/bind.hpp>
 
 #include <csignal>
+#include <cstring>
 #include <vector>
 
 #include <sys/socket.h>
@@ -185,8 +186,10 @@ TEST_F(LocalSocketTest, asyncPartialRead) {
     alarm(IO_TIMEOUT);
 
     // specify reading 4 bytes of data, and send 3 bytes.  It shouldn't cause
-    // callback.
+    // callback.  while we actually don't use the buffer, we'll initialize it
+    // to make valgrind happy.
     char recv_buf[4];
+    std::memset(recv_buf, 0, sizeof(recv_buf));
     bool callback_called = false;
     LocalSocket sock(io_service_, sock_pair_[0].release());
     sock.asyncRead(boost::bind(&callback, _1, &io_service_, &callback_called,