mirror of
https://github.com/aljazceru/lightning.git
synced 2025-12-19 15:14:23 +01:00
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>
This commit is contained in:
committed by
Rusty Russell
parent
3f035cb3cc
commit
6f635b46fd
@@ -115,6 +115,8 @@ int main(int argc, char *argv[])
|
|||||||
if (infd < 0)
|
if (infd < 0)
|
||||||
err(1, "opening %s", infile);
|
err(1, "opening %s", infile);
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
infd = STDIN_FILENO;
|
||||||
|
|
||||||
if (outfile) {
|
if (outfile) {
|
||||||
outfd = open(outfile, O_WRONLY|O_TRUNC|O_CREAT, 0666);
|
outfd = open(outfile, O_WRONLY|O_TRUNC|O_CREAT, 0666);
|
||||||
|
|||||||
Reference in New Issue
Block a user