tests: constify format strings in tap.h
authorSimon Marchi <simon.marchi@efficios.com>
Fri, 4 Oct 2019 16:44:05 +0000 (12:44 -0400)
committerSimon Marchi <simon.marchi@efficios.com>
Mon, 7 Oct 2019 18:36:23 +0000 (14:36 -0400)
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 <simon.marchi@efficios.com>
Reviewed-on: https://review.lttng.org/c/babeltrace/+/2130
Reviewed-by: Francis Deslauriers <francis.deslauriers@efficios.com>
Reviewed-by: Philippe Proulx <eeppeliteloop@gmail.com>
Tested-by: jenkins <jenkins@lttng.org>
tests/utils/tap/tap.c
tests/utils/tap/tap.h

index 5699f387015b9610abda9ec75bd170929492bf97..a5c3a8109c8e279542d73f083cb5802a214c5bab 100644 (file)
@@ -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;
 
index 08e4f4157b79c7614595cf6489c83045ee37da6d..764f75dae00469463eb9e2e058e24356e204172b 100644 (file)
 #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);
This page took 0.025964 seconds and 4 git commands to generate.