Permalink
Browse files

pillowfight.cc: initialize data blob with pattern

To avoid valgrind warnings like this

==19854== Syscall param sendmsg(msg.msg_iov[0]) points to uninitialised byte(s)
==19854==    at 0x5AD7A90: __sendmsg_nocancel (syscall-template.S:82)
==19854==    by 0x618727D: lcb_io_sendv (plugin-libevent.c:177)
==19854==    by 0x4E3577A: do_send_data (event.c:281)
==19854==    by 0x4E358B0: lcb_server_event_handler (event.c:325)
==19854== Memcheck, a memory error detector
==19854== Copyright (C) 2002-2012, and GNU GPL'd, by Julian Seward et al.
==19854== Using Valgrind-3.8.1 and LibVEX; rerun with -h for copyright info
==19854== Command: /home/avsej/code/couchbase-sdk/lcb/example/pillowfight/.libs/lt-pillowfight -t1 -Q1 -I1

Change-Id: I1a444ab568e9451c22fa19f2f5184d15c563ad88
Reviewed-on: http://review.couchbase.org/25081
Tested-by: Sergey Avseyev <sergey.avseyev@gmail.com>
Reviewed-by: Trond Norbye <trond.norbye@gmail.com>
  • Loading branch information...
avsej authored and trondn committed Mar 11, 2013
1 parent 362a994 commit 1e953720464b68b93702ed110f4275c3e40930da
Showing with 11 additions and 0 deletions.
  1. +11 −0 example/pillowfight/pillowfight.cc
@@ -48,6 +48,17 @@ class Configuration
loop(false),
randomSeed(0) {
data = static_cast<void *>(new char[maxSize]);
+ /* fill data array with pattern */
+ uint32_t *iptr = static_cast<uint32_t *>(data);
+ for (uint32_t ii = 0; ii < maxSize / sizeof(uint32_t); ++ii) {
+ iptr[ii] = 0xdeadbeef;
+ }
+ /* pad rest bytes with zeros */
+ size_t rest = maxSize % sizeof(uint32_t);
+ if (rest > 0) {
+ char *cptr = static_cast<char *>(data) + (maxSize / sizeof(uint32_t));
+ memset(cptr, 0, rest);
+ }
}
~Configuration() {

0 comments on commit 1e95372

Please sign in to comment.