From: Lennart Poettering Date: Fri, 12 Apr 2013 00:19:26 +0000 (+0200) Subject: bus: make the kdbus code valgrind clean X-Git-Tag: v202~134 X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?p=elogind.git;a=commitdiff_plain;h=7211f918ba2b86e0041413b47d51d7593e73cf5d bus: make the kdbus code valgrind clean --- diff --git a/configure.ac b/configure.ac index 5820b3042..33b0ca958 100644 --- a/configure.ac +++ b/configure.ac @@ -693,6 +693,8 @@ AC_DEFINE_UNQUOTED(TELINIT, ["$TELINIT"], [Path to telinit]) AC_SUBST(TELINIT) +AC_CHECK_HEADERS_ONCE([valgrind/memcheck.h]) + # ------------------------------------------------------------------------------ have_myhostname=no AC_ARG_ENABLE(myhostname, AS_HELP_STRING([--disable-myhostname], [disable nss-myhostname support])) diff --git a/src/libsystemd-bus/bus-kernel.c b/src/libsystemd-bus/bus-kernel.c index 1b2297fbb..ed4e189c3 100644 --- a/src/libsystemd-bus/bus-kernel.c +++ b/src/libsystemd-bus/bus-kernel.c @@ -19,6 +19,10 @@ along with systemd; If not, see . ***/ +#ifdef HAVE_VALGRIND_MEMCHECK_H +#include +#endif + #include #include "util.h" @@ -32,8 +36,6 @@ (uint8_t*) (d) < (uint8_t*) (k) + (k)->size; \ (d) = (struct kdbus_msg_data*) ((uint8_t*) (d) + ALIGN8((d)->size))) - - static int parse_unique_name(const char *s, uint64_t *id) { int r; @@ -353,6 +355,11 @@ int bus_kernel_read_message(sd_bus *bus, sd_bus_message **m) { k = bus->rbuffer = q; k->size = sz; + /* Let's tell valgrind that there's really no need to + * initialize this fully. This should be removed again + * when valgrind learned the kdbus ioctls natively. */ + VALGRIND_MAKE_MEM_DEFINED(k, sz); + r = ioctl(bus->input_fd, KDBUS_CMD_MSG_RECV, bus->rbuffer); if (r >= 0) break;