diff options
author | Dimitry Andric <dim@FreeBSD.org> | 2023-12-21 22:39:15 +0000 |
---|---|---|
committer | Dimitry Andric <dim@FreeBSD.org> | 2023-12-21 22:45:52 +0000 |
commit | 69c8025a498450b6bc4cc9e97ba779ed1c2e7f4b (patch) | |
tree | 16a6a35ba37f5f1fa33948e17d0f190976dd6cdf | |
parent | c794d188222a4d3414233ff9630d47eedc090fbe (diff) | |
download | src-69c8025a498450b6bc4cc9e97ba779ed1c2e7f4b.tar.gz src-69c8025a498450b6bc4cc9e97ba779ed1c2e7f4b.zip |
Silence snprintf truncation warnings in printf_test examples
Building share/examples/tests with clang 18 results in a few warnings
like:
share/examples/tests/tests/plain/printf_test.c:67:6: error: 'snprintf' will always be truncated; specified size is 10, but format string expands to at least 17 [-Werror,-Wformat-truncation]
67 | if (snprintf(buffer, sizeof(buffer), "0123456789abcdef") != 16)
| ^
Since these tests are meant as an example of testing snprintf overflow,
suppress the warnings.
MFC after: 3 days
-rw-r--r-- | share/examples/tests/tests/atf/Makefile | 4 | ||||
-rw-r--r-- | share/examples/tests/tests/plain/Makefile | 4 | ||||
-rw-r--r-- | share/examples/tests/tests/tap/Makefile | 4 |
3 files changed, 12 insertions, 0 deletions
diff --git a/share/examples/tests/tests/atf/Makefile b/share/examples/tests/tests/atf/Makefile index 305d66c51f38..7614767b6e0a 100644 --- a/share/examples/tests/tests/atf/Makefile +++ b/share/examples/tests/tests/atf/Makefile @@ -46,3 +46,7 @@ file1: @echo "File 1" > ${.TARGET} .include <bsd.test.mk> + +.if ${COMPILER_TYPE} == "clang" && ${COMPILER_VERSION} >= 180000 +CWARNFLAGS.printf_test.c+= -Wno-format-truncation +.endif diff --git a/share/examples/tests/tests/plain/Makefile b/share/examples/tests/tests/plain/Makefile index 2594968a6f44..462324309f6a 100644 --- a/share/examples/tests/tests/plain/Makefile +++ b/share/examples/tests/tests/plain/Makefile @@ -46,3 +46,7 @@ file1: @echo "File 1" > ${.TARGET} .include <bsd.test.mk> + +.if ${COMPILER_TYPE} == "clang" && ${COMPILER_VERSION} >= 180000 +CWARNFLAGS.printf_test.c+= -Wno-format-truncation +.endif diff --git a/share/examples/tests/tests/tap/Makefile b/share/examples/tests/tests/tap/Makefile index 5b829afd5838..86d3f6805045 100644 --- a/share/examples/tests/tests/tap/Makefile +++ b/share/examples/tests/tests/tap/Makefile @@ -46,3 +46,7 @@ file1: @echo "File 1" > ${.TARGET} .include <bsd.test.mk> + +.if ${COMPILER_TYPE} == "clang" && ${COMPILER_VERSION} >= 180000 +CWARNFLAGS.printf_test.c+= -Wno-format-truncation +.endif |