[glibc] stdio-common: Silence clang -Wfortify-source warning in tst-vfscanf-bz34008
Adhemerval Zanella via Glibc-cvs <[email protected]> Fri, 15 May 2026 16:15:03 +0000 (GMT)
| Newsgroups | gmane.comp.lib.glibc.cvs |
|---|---|
| Message-ID | <[email protected]> |
https://sourceware.org/git/gitweb.cgi?p=glibc.git;h=d9981b54396038bb85f3b2db7b68de1f6755530b commit d9981b54396038bb85f3b2db7b68de1f6755530b Author: Adhemerval Zanella <[email protected]> Date: Fri May 15 11:07:26 2026 -0300 stdio-common: Silence clang -Wfortify-source warning in tst-vfscanf-bz34008 clang does not recognize the 'm' scanf specifier and incorrectly warns that the buf argument may overflow. Suppress the warning with the clang-specific DIAG_* macros. Diff: --- stdio-common/tst-vfscanf-bz34008.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/stdio-common/tst-vfscanf-bz34008.c b/stdio-common/tst-vfscanf-bz34008.c index 48371c8a3d..ebf7ec3e4c 100644 --- a/stdio-common/tst-vfscanf-bz34008.c +++ b/stdio-common/tst-vfscanf-bz34008.c @@ -24,6 +24,7 @@ #include <stdlib.h> #include <malloc.h> #include <support/check.h> +#include <libc-diag.h> #define WIDTH 0x410 #define SCANFSTR "%1040mc" @@ -37,7 +38,14 @@ do_test (void) input[WIDTH] = '\0'; char *buf = NULL; + + /* clang does not recognize the 'm' scanf specifier and incorrectly warns + that the buf argument may overflow ((argument 3 has size 8, but the + corresponding specifier may require size 1040). */ + DIAG_PUSH_NEEDS_COMMENT_CLANG; + DIAG_IGNORE_NEEDS_COMMENT_CLANG (18, "-Wfortify-source"); TEST_VERIFY (sscanf (input, SCANFSTR, &buf) != -1); + DIAG_POP_NEEDS_COMMENT_CLANG; TEST_VERIFY (buf != NULL); free (buf);