Fix test/c/testlib 'const char *' vs 'char *'

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"
This commit is contained in:
Nigel Tao committed 2022-02-06 14:31:28 +11:00
1 parent 94736e2eae
commit 9719073707
1 file changed
+3 -2
+3 -2
View File
@@ -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++) {