cppcheck cleanup.

This commit is contained in:
Eric S. Raymond 2022-04-18 10:24:11 -04:00
parent d9d58ea168
commit f7d6884ded
2 changed files with 3 additions and 3 deletions

View file

@ -136,7 +136,7 @@ debug: CCFLAGS += -fsanitize=address
debug: CCFLAGS += -fsanitize=undefined debug: CCFLAGS += -fsanitize=undefined
debug: linty debug: linty
PYSUPPRESSIONS = --suppress=missingIncludeSystem --suppress=invalidscanf CSUPPRESSIONS = --suppress=missingIncludeSystem --suppress=invalidscanf
cppcheck: cppcheck:
cppcheck -I. --template gcc --enable=all $(CSUPPRESSIONS) *.[ch] cppcheck -I. --template gcc --enable=all $(CSUPPRESSIONS) *.[ch]

4
main.c
View file

@ -147,7 +147,7 @@ char *myreadline(const char *prompt)
if (settings.argc == 0) if (settings.argc == 0)
return readline(prompt); return readline(prompt);
char *buf = malloc(BUFSIZ); char *buf = malloc(LINESIZE+1);
for (;;) { for (;;) {
if (settings.scriptfp == NULL || feof(settings.scriptfp)) { if (settings.scriptfp == NULL || feof(settings.scriptfp)) {
if (settings.optind >= settings.argc) { if (settings.optind >= settings.argc) {
@ -169,7 +169,7 @@ char *myreadline(const char *prompt)
free(buf); // LCOV_EXCL_LINE free(buf); // LCOV_EXCL_LINE
return readline(prompt); // LCOV_EXCL_LINE return readline(prompt); // LCOV_EXCL_LINE
} else { } else {
char *ln = fgets(buf, BUFSIZ-1, settings.scriptfp); char *ln = fgets(buf, LINESIZE, settings.scriptfp);
if (ln != NULL) { if (ln != NULL) {
fputs(PROMPT, stdout); fputs(PROMPT, stdout);
fputs(ln, stdout); fputs(ln, stdout);