From: Eric S. Raymond Date: Mon, 18 Apr 2022 14:24:11 +0000 (-0400) Subject: cppcheck cleanup. X-Git-Tag: 1.12~25 X-Git-Url: https://jxself.org/git/?a=commitdiff_plain;h=f7d6884dedabaa237056164ec6d90335de8025cb;p=open-adventure.git cppcheck cleanup. --- diff --git a/Makefile b/Makefile index 84039b4..92e97da 100644 --- a/Makefile +++ b/Makefile @@ -136,7 +136,7 @@ debug: CCFLAGS += -fsanitize=address debug: CCFLAGS += -fsanitize=undefined debug: linty -PYSUPPRESSIONS = --suppress=missingIncludeSystem --suppress=invalidscanf +CSUPPRESSIONS = --suppress=missingIncludeSystem --suppress=invalidscanf cppcheck: cppcheck -I. --template gcc --enable=all $(CSUPPRESSIONS) *.[ch] diff --git a/main.c b/main.c index 0bc737b..514ae59 100644 --- a/main.c +++ b/main.c @@ -147,7 +147,7 @@ char *myreadline(const char *prompt) if (settings.argc == 0) return readline(prompt); - char *buf = malloc(BUFSIZ); + char *buf = malloc(LINESIZE+1); for (;;) { if (settings.scriptfp == NULL || feof(settings.scriptfp)) { if (settings.optind >= settings.argc) { @@ -169,7 +169,7 @@ char *myreadline(const char *prompt) free(buf); // LCOV_EXCL_LINE return readline(prompt); // LCOV_EXCL_LINE } else { - char *ln = fgets(buf, BUFSIZ-1, settings.scriptfp); + char *ln = fgets(buf, LINESIZE, settings.scriptfp); if (ln != NULL) { fputs(PROMPT, stdout); fputs(ln, stdout);