From 9719073707628e6db630de1375f33fbb7ac780c4 Mon Sep 17 00:00:00 2001 From: Nigel Tao Date: Sun, 6 Feb 2022 14:27:19 +1100 Subject: [PATCH] Fix test/c/testlib 'const char *' vs 'char *' MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Prior to this commit, `g++ test/c/std/png.c` failed with: test/c/std/../testlib/testlib.c:107:14: error: invalid conversion from ‘const char*’ to ‘char*’ [-fpermissive] ... test/c/std/../testlib/testlib.c:741:5: note: in expansion of macro ‘RETURN_FAIL’ 741 | RETURN_FAIL("hex_dump: NULL argument"); Likewise, clang++ also failed with: test/c/std/../testlib/testlib.c:741:5: error: cannot initialize return object of type 'char *' with an rvalue of type 'const char *' RETURN_FAIL("hex_dump: NULL argument"); Also run "clang-format-9 -style=Chromium" --- test/c/testlib/testlib.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/test/c/testlib/testlib.c b/test/c/testlib/testlib.c index 9b099cc5..b6aebbf5 100644 --- a/test/c/testlib/testlib.c +++ b/test/c/testlib/testlib.c @@ -105,7 +105,7 @@ char g_fail_msg[65536] = {0}; #define RETURN_FAIL(...) \ return (snprintf(g_fail_msg, sizeof(g_fail_msg), ##__VA_ARGS__) >= 0) \ ? g_fail_msg \ - : "unknown failure (snprintf-related)" + : strcpy(g_fail_msg, "unknown failure (snprintf-related)") #define INCR_FAIL(msg, ...) \ msg += snprintf(msg, sizeof(g_fail_msg) - (msg - g_fail_msg), ##__VA_ARGS__) @@ -422,7 +422,8 @@ test_main(int argc, char** argv, proc* tests, proc* benches) { "compatible with the\n" "# https://godoc.org/golang.org/x/perf/cmd/benchstat tool. To install " "it, first\n" - "# install Go, then run \"go install golang.org/x/perf/cmd/benchstat\".\n"); + "# install Go, then run \"go install " + "golang.org/x/perf/cmd/benchstat\".\n"); } for (int i = 0; i < reps; i++) {