]> git.ipfire.org Git - thirdparty/glibc.git/commitdiff
stdio-common: Silence clang -Wfortify-source warning in tst-vfscanf-bz34008
authorAdhemerval Zanella <adhemerval.zanella@linaro.org>
Fri, 15 May 2026 14:07:26 +0000 (11:07 -0300)
committerAdhemerval Zanella <adhemerval.zanella@linaro.org>
Fri, 15 May 2026 14:08:31 +0000 (11:08 -0300)
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.

stdio-common/tst-vfscanf-bz34008.c

index 48371c8a3d1c96e50163cedef809c0f7af02f323..ebf7ec3e4c562ca02eb623202ee199677f1906e0 100644 (file)
@@ -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);