From 5eddd0b3f8956757bbc7435121bcc61362f4725f Mon Sep 17 00:00:00 2001 From: Simon Marchi Date: Fri, 4 Oct 2019 12:44:05 -0400 Subject: [PATCH] tests: constify format strings in tap.h Format strings are typically read-only data (literal strings), and they are not modified by the functions receiving them, so it makes no sense for them not to be const. This helps avoid some "passing value to function foo discards const qualifier" kind of warnings. Change-Id: Ibaaaf5690bed21e1d541f1b676627dfd70541219 Signed-off-by: Simon Marchi Reviewed-on: https://review.lttng.org/c/babeltrace/+/2130 Reviewed-by: Francis Deslauriers Reviewed-by: Philippe Proulx Tested-by: jenkins --- tests/utils/tap/tap.c | 12 ++++++------ tests/utils/tap/tap.h | 10 +++++----- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/tests/utils/tap/tap.c b/tests/utils/tap/tap.c index 5699f387..a5c3a810 100644 --- a/tests/utils/tap/tap.c +++ b/tests/utils/tap/tap.c @@ -82,8 +82,8 @@ void funlockfile(FILE * filehandle) { * test_comment -- a comment to print afterwards, may be NULL */ unsigned int -_gen_result(int ok, const char *func, char *file, unsigned int line, - char *test_name, ...) +_gen_result(int ok, const char *func, const char *file, unsigned int line, + const char *test_name, ...) { va_list ap; char *local_test_name = NULL; @@ -228,7 +228,7 @@ plan_no_plan(void) * Note that the plan is to skip all tests */ int -plan_skip_all(char *reason) +plan_skip_all(const char *reason) { LOCK; @@ -284,7 +284,7 @@ plan_tests(unsigned int tests) } unsigned int -diag(char *fmt, ...) +diag(const char *fmt, ...) { va_list ap; @@ -330,7 +330,7 @@ _expected_tests(unsigned int tests) } int -skip(unsigned int n, char *fmt, ...) +skip(unsigned int n, const char *fmt, ...) { va_list ap; char *skip_msg = NULL; @@ -358,7 +358,7 @@ skip(unsigned int n, char *fmt, ...) } void -todo_start(char *fmt, ...) +todo_start(const char *fmt, ...) { va_list ap; diff --git a/tests/utils/tap/tap.h b/tests/utils/tap/tap.h index 08e4f415..764f75da 100644 --- a/tests/utils/tap/tap.h +++ b/tests/utils/tap/tap.h @@ -75,21 +75,21 @@ #define skip_end() } while(0); __attribute__((format(printf, 5, 6))) -unsigned int _gen_result(int, const char *, char *, unsigned int, char *, ...); +unsigned int _gen_result(int, const char *, const char *, unsigned int, const char *, ...); int plan_no_plan(void); -int plan_skip_all(char *); +int plan_skip_all(const char *); int plan_tests(unsigned int); __attribute__((format(printf, 1, 2))) -unsigned int diag(char *, ...); +unsigned int diag(const char *, ...); void diag_multiline(const char *); __attribute__((format(printf, 2, 3))) -int skip(unsigned int, char *, ...); +int skip(unsigned int, const char *, ...); __attribute__((format(printf, 1, 2))) -void todo_start(char *, ...); +void todo_start(const char *, ...); void todo_end(void); int exit_status(void); -- 2.34.1