From fbb494fba31e1e8ff5eb866de7addf1787b0bb1e Mon Sep 17 00:00:00 2001 From: Rusty Russell Date: Mon, 8 Apr 2019 09:26:30 +0930 Subject: [PATCH] devtools/create-gossipstore: clean up enough to pass check-source. Signed-off-by: Rusty Russell --- devtools/create-gossipstore.c | 11 ++++------- devtools/create-gossipstore.h | 4 +++- tools/check-includes.sh | 2 +- 3 files changed, 8 insertions(+), 9 deletions(-) diff --git a/devtools/create-gossipstore.c b/devtools/create-gossipstore.c index f6861e570..b2a939055 100644 --- a/devtools/create-gossipstore.c +++ b/devtools/create-gossipstore.c @@ -9,8 +9,6 @@ #include #include #include -#include -#include #include #include #include @@ -26,7 +24,7 @@ struct scidsat * load_scid_file(FILE * scidfd) fscanf(scidfd, "%s\n", title); struct scidsat * scids = calloc(n, sizeof(scidsat)); int i = 0; - while(fscanf(scidfd, "%s ,%ld\n", scids[i].scid, &scids[i].sat.satoshis) == 2 ) { + while(fscanf(scidfd, "%s ,%ld\n", scids[i].scid, &scids[i].sat.satoshis) == 2 ) { /* Raw: read from file */ i++; } return scids; @@ -41,7 +39,7 @@ int main(int argc, char *argv[]) char *infile = NULL, *outfile = NULL, *scidfile = NULL, *csat = NULL; int infd, outfd; FILE * scidfd; - struct scidsat * scids; + struct scidsat * scids = NULL; unsigned max = -1U; setup_locale(); @@ -113,7 +111,7 @@ int main(int argc, char *argv[]) switch (fromwire_peektype(inmsg)) { case WIRE_CHANNEL_ANNOUNCEMENT: - if (scidfile) { + if (scids) { sat = scids[scidi].sat; scidi += 1; } @@ -151,7 +149,6 @@ int main(int argc, char *argv[]) break; } fprintf(stderr, "channels %d, updates %d, nodes %d\n", channels, updates, nodes); - if (scidfile) - free(scids); + free(scids); return 0; } diff --git a/devtools/create-gossipstore.h b/devtools/create-gossipstore.h index d6a715048..b2b165f5b 100644 --- a/devtools/create-gossipstore.h +++ b/devtools/create-gossipstore.h @@ -1,3 +1,5 @@ +#ifndef LIGHTNING_DEVTOOLS_CREATE_GOSSIPSTORE_H +#define LIGHTNING_DEVTOOLS_CREATE_GOSSIPSTORE_H #include #include #include @@ -8,4 +10,4 @@ struct scidsat { } scidsat; struct scidsat * load_scid_file(FILE * scidfd); - +#endif /* LIGHTNING_DEVTOOLS_CREATE_GOSSIPSTORE_H */ diff --git a/tools/check-includes.sh b/tools/check-includes.sh index 9be58bd21..18c9f2e17 100755 --- a/tools/check-includes.sh +++ b/tools/check-includes.sh @@ -9,7 +9,7 @@ HEADER_ID_SUFFIX="_H" REGEXP_EXCLUDE_FILES_WITH_PREFIX="ccan/" for HEADER_FILE in $(git ls-files -- "*.h" | grep -vE "^${REGEXP_EXCLUDE_FILES_WITH_PREFIX}") do - HEADER_ID_BASE=$(tr / _ <<< "${HEADER_FILE/%.h/}" | tr "[:lower:]" "[:upper:]") + HEADER_ID_BASE=$(tr /- _ <<< "${HEADER_FILE/%.h/}" | tr "[:lower:]" "[:upper:]") HEADER_ID="${HEADER_ID_PREFIX}${HEADER_ID_BASE}${HEADER_ID_SUFFIX}" if [[ $(grep -cE "^#((ifndef|define) ${HEADER_ID}|endif /\\* ${HEADER_ID} \\*/)$" "${HEADER_FILE}") != 3 ]]; then echo "${HEADER_FILE} seems to be missing the expected include guard:"