mirror of
https://sourceware.org/git/glibc.git
synced 2026-10-28 10:25:13 +08:00
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.
This commit is contained in:
1 parent
1172d0e9cf
commit
d9981b5439
1 file changed
+8
@@ -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);
|
||||
|
||||
Reference in new issue
Block a user