Browse Source

build: handle possible fscanf errors

on gcc (GCC) 7.4.0

devtools/create-gossipstore.c: In function ‘load_scid_file’:
devtools/create-gossipstore.c:22:9: error: ignoring return value of ‘fscanf’ ...
         fscanf(scidfd, "%d\n", &n);
         ^~~~~~~~~~~~~~~~~~~~~~~~~~
devtools/create-gossipstore.c:24:9: error: ignoring return value of ‘fscanf’ ...
         fscanf(scidfd, "%s\n", title);
         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
cc1: all warnings being treated as errors
make: *** [<builtin>: devtools/create-gossipstore.o] Error 1

Signed-off-by: William Casarin <jb55@jb55.com>
pr-2587
William Casarin 6 years ago
committed by Christian Decker
parent
commit
6b49b17d6e
  1. 10
      devtools/create-gossipstore.c

10
devtools/create-gossipstore.c

@ -18,10 +18,14 @@
struct scidsat * load_scid_file(FILE * scidfd)
{
int n;
fscanf(scidfd, "%d\n", &n);
int n, ok;
ok = fscanf(scidfd, "%d\n", &n);
if (ok == EOF)
return NULL;
char title[16];
fscanf(scidfd, "%s\n", title);
ok = fscanf(scidfd, "%s\n", title);
if (ok == EOF)
return NULL;
struct scidsat * scids = calloc(n, sizeof(scidsat));
int i = 0;
while(fscanf(scidfd, "%s ,%ld\n", scids[i].scid, &scids[i].sat.satoshis) == 2 ) { /* Raw: read from file */

Loading…
Cancel
Save