chiark / gitweb /
bus: make the kdbus code valgrind clean
[elogind.git] / src / libsystemd-bus / bus-kernel.c
index 1b2297fbb4dceae5d2d49aa71263d9928f24a217..ed4e189c3ea92a249889c69cd3a0e832ce42a4a1 100644 (file)
   along with systemd; If not, see <http://www.gnu.org/licenses/>.
 ***/
 
+#ifdef HAVE_VALGRIND_MEMCHECK_H
+#include <valgrind/memcheck.h>
+#endif
+
 #include <fcntl.h>
 
 #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;