From fc78d94e7f1b810b56d25fd25ae7ef6b076d6ab8 Mon Sep 17 00:00:00 2001 From: Paul Wilkinson Date: Sat, 10 May 2014 15:23:21 +0100 Subject: [PATCH] Silence valgrind memcheck error by memset()-ing pkt to 0 valgrind reports: Syscall param write(buf) points to uninitialised byte(s) In this case, it is a false positive, but adding this single memset at attach start-up means the program is now clean when run with "valgrind --trace-children=yes dtach -c ...", which can make future debugging easier. --- attach.c | 1 + 1 file changed, 1 insertion(+) diff --git a/attach.c b/attach.c index 059b510..8137130 100644 --- a/attach.c +++ b/attach.c @@ -190,6 +190,7 @@ attach_main(int noerror) write(1, "\33[H\33[J", 6); /* Tell the master that we want to attach. */ + memset(&pkt, 0, sizeof(struct packet)); pkt.type = MSG_ATTACH; write(s, &pkt, sizeof(struct packet));