Browse Source

gossipstore: fix uninitialized input fd

Initialize infd to STDIN_FILENO if the input file argument is missing.

Caught with gcc version: 7.4.0

devtools/create-gossipstore.c: In function ‘main’:
devtools/create-gossipstore.c:130:9: error: ‘infd’ may be used
uninitialized in this function [-Werror=maybe-uninitialized]
  while (read_all(infd, &be_inlen, sizeof(be_inlen))) {

Suggested-by: @ZmnSCPxj <https://github.com/ElementsProject/lightning/pull/2674#issuecomment-495617253>
Signed-off-by: William Casarin <jb55@jb55.com>
htlc_accepted_hook
William Casarin 6 years ago
committed by Rusty Russell
parent
commit
6f635b46fd
  1. 2
      devtools/create-gossipstore.c

2
devtools/create-gossipstore.c

@ -115,6 +115,8 @@ int main(int argc, char *argv[])
if (infd < 0)
err(1, "opening %s", infile);
}
else
infd = STDIN_FILENO;
if (outfile) {
outfd = open(outfile, O_WRONLY|O_TRUNC|O_CREAT, 0666);

Loading…
Cancel
Save