diff --git a/report.c b/report.c index 5b9d9b006..11b4de21b 100644 --- a/report.c +++ b/report.c @@ -45,7 +45,7 @@ void set_verblevel(int level) verblevel = level; } -bool set_logfile(char *file_name) +bool set_logfile(const char *file_name) { logfile = fopen(file_name, "w"); return logfile != NULL; @@ -161,7 +161,7 @@ void report_noreturn(int level, char *fmt, ...) /* Functions denoting failures */ /* Need to be able to print without using malloc */ -static void fail_fun(char *format, char *msg) +static void fail_fun(const char *format, const char *msg) { snprintf(fail_buf, sizeof(fail_buf), format, msg); /* Tack on return */ @@ -209,7 +209,7 @@ static void check_exceed(size_t new_bytes) } /* Call malloc & exit if fails */ -void *malloc_or_fail(size_t bytes, char *fun_name) +void *malloc_or_fail(size_t bytes, const char *fun_name) { check_exceed(bytes); void *p = malloc(bytes); @@ -228,7 +228,7 @@ void *malloc_or_fail(size_t bytes, char *fun_name) } /* Call calloc returns NULL & exit if fails */ -void *calloc_or_fail(size_t cnt, size_t bytes, char *fun_name) +void *calloc_or_fail(size_t cnt, size_t bytes, const char *fun_name) { check_exceed(cnt * bytes); void *p = calloc(cnt, bytes); @@ -246,7 +246,7 @@ void *calloc_or_fail(size_t cnt, size_t bytes, char *fun_name) return p; } -char *strsave_or_fail(char *s, char *fun_name) +char *strsave_or_fail(const char *s, const char *fun_name) { if (!s) return NULL; diff --git a/report.h b/report.h index 7fabcdb6e..a68dd34fc 100644 --- a/report.h +++ b/report.h @@ -12,7 +12,7 @@ typedef enum { MSG_WARN, MSG_ERROR, MSG_FATAL, N_MSG } message_t; /* Buffer sizes */ #define MAX_CHAR 512 -bool set_logfile(char *file_name); +bool set_logfile(const char *file_name); extern int verblevel; void set_verblevel(int level); @@ -27,13 +27,13 @@ void report(int verblevel, char *fmt, ...); void report_noreturn(int verblevel, char *fmt, ...); /* Attempt to call malloc. Fail when returns NULL */ -void *malloc_or_fail(size_t bytes, char *fun_name); +void *malloc_or_fail(size_t bytes, const char *fun_name); /* Attempt to call calloc. Fail when returns NULL */ -void *calloc_or_fail(size_t cnt, size_t bytes, char *fun_name); +void *calloc_or_fail(size_t cnt, size_t bytes, const char *fun_name); /* Attempt to save string. Fail when malloc returns NULL */ -char *strsave_or_fail(char *s, char *fun_name); +char *strsave_or_fail(const char *s, const char *fun_name); /* Free block, as from malloc, or strsave */ void free_block(void *b, size_t len); diff --git a/scripts/pre-commit.hook b/scripts/pre-commit.hook index c03ece1ff..b39b87bdf 100755 --- a/scripts/pre-commit.hook +++ b/scripts/pre-commit.hook @@ -13,7 +13,10 @@ CPPCHECK_suppresses="--inline-suppr harness.c \ --suppress=nullPointerRedundantCheck:report.c \ --suppress=nullPointerRedundantCheck:harness.c \ --suppress=nullPointer:queue.c \ ---suppress=nullPointer:qtest.c" +--suppress=nullPointer:qtest.c \ +--suppress=returnDanglingLifetime:report.c \ +--suppress=constParameterCallback:console.c \ +--suppress=constParameterPointer:console.c" CPPCHECK_OPTS="-I. --enable=all --error-exitcode=1 --force $CPPCHECK_suppresses $CPPCHECK_unmatched ." RETURN=0