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.
This commit is contained in:
Paul Wilkinson 2014-05-10 15:23:21 +01:00 committed by Ned T. Crigler
parent c7b68ae3fa
commit fc78d94e7f
1 changed files with 1 additions and 0 deletions

View File

@ -190,6 +190,7 @@ attach_main(int noerror)
write(1, "\33[H\33[J", 6); write(1, "\33[H\33[J", 6);
/* Tell the master that we want to attach. */ /* Tell the master that we want to attach. */
memset(&pkt, 0, sizeof(struct packet));
pkt.type = MSG_ATTACH; pkt.type = MSG_ATTACH;
write(s, &pkt, sizeof(struct packet)); write(s, &pkt, sizeof(struct packet));