From 3c9ca5d3e190ee5689c1941dfa932424938ddaba Mon Sep 17 00:00:00 2001 From: Rusty Russell Date: Sun, 22 Sep 2019 11:34:43 +0930 Subject: [PATCH] openingd: ensure that revents fields are initialized. Valgrind error file: valgrind-errors.112365 ==112365== Conditional jump or move depends on uninitialised value(s) ==112365== at 0x1105E0: main (openingd.c:1504) ==112365== ==112365== Conditional jump or move depends on uninitialised value(s) ==112365== at 0x110604: main (openingd.c:1507) ==112365== ==112365== Conditional jump or move depends on uninitialised value(s) ==112365== at 0x110628: main (openingd.c:1510) ==112365== Signed-off-by: Rusty Russell --- openingd/openingd.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/openingd/openingd.c b/openingd/openingd.c index d871cef03..8526e39e4 100644 --- a/openingd/openingd.c +++ b/openingd/openingd.c @@ -1497,6 +1497,12 @@ int main(int argc, char *argv[]) t = time_to_msec(trel); else t = -1; + + /*~ If we get a signal which aborts the poll() call, valgrind + * complains about revents being uninitialized. I'm not sure + * that's correct, but it's easy to be sure. */ + pollfd[0].revents = pollfd[1].revents = pollfd[2].revents = 0; + poll(pollfd, ARRAY_SIZE(pollfd), t); /* Subtle: handle_master_in can do its own poll loop, so * don't try to service more than one fd per loop. */