mirror of git://sourceware.org/git/glibc.git
Eliminate -Wno-format from printf/scanf tests.
This commit is contained in:
parent
a1edbf3cb8
commit
1c4053db63
22
ChangeLog
22
ChangeLog
|
@ -1,3 +1,25 @@
|
||||||
|
2014-12-11 Roland McGrath <roland@hack.frob.com>
|
||||||
|
|
||||||
|
* stdio-common/tstdiomisc.c (t2): Ignore -Wformat and
|
||||||
|
-Wformat-extra-args warnings for scanf formats.
|
||||||
|
* stdio-common/scanf4.c (main): Ignore -Wformat-zero-length around
|
||||||
|
test of zero-length format (duh).
|
||||||
|
* stdio-common/scanf7.c (main): Ignore -Wformat warnings for
|
||||||
|
corner-case scanf format test.
|
||||||
|
* stdio-common/test-vfprintf.c (do_test): Ignore -Wformat-security for
|
||||||
|
generated fprintf format string.
|
||||||
|
* stdio-common/tst-sprintf.c (do_test): Ignore -Wformat warnings for
|
||||||
|
corner-case sprintf format tests.
|
||||||
|
* stdio-common/tst-printf.c: Ignore -Wformat throughout.
|
||||||
|
* stdio-common/tst-printfsz.c (main): Ignore -Wformat and
|
||||||
|
-Wformat-extra-args warnings throughout.
|
||||||
|
* stdio-common/Makefile (CFLAGS-tstdiomisc.c): Variable removed.
|
||||||
|
(CFLAGS-scanf4.c): Likewise.
|
||||||
|
(CFLAGS-scanf7.c): Likewise.
|
||||||
|
(CFLAGS-tst-sprintf.c): Likewise.
|
||||||
|
(CFLAGS-tst-printf.c): Likewise.
|
||||||
|
(CFLAGS-tst-printfsz.c): Likewise.
|
||||||
|
|
||||||
2014-12-11 Joseph Myers <joseph@codesourcery.com>
|
2014-12-11 Joseph Myers <joseph@codesourcery.com>
|
||||||
|
|
||||||
* include/cpio.h: New file.
|
* include/cpio.h: New file.
|
||||||
|
|
|
@ -80,11 +80,6 @@ endif
|
||||||
|
|
||||||
CFLAGS-vfprintf.c = -Wno-uninitialized
|
CFLAGS-vfprintf.c = -Wno-uninitialized
|
||||||
CFLAGS-vfwprintf.c = -Wno-uninitialized
|
CFLAGS-vfwprintf.c = -Wno-uninitialized
|
||||||
CFLAGS-tst-printf.c = -Wno-format
|
|
||||||
CFLAGS-tstdiomisc.c = -Wno-format
|
|
||||||
CFLAGS-scanf4.c = -Wno-format
|
|
||||||
CFLAGS-scanf7.c = -Wno-format
|
|
||||||
CFLAGS-tst-printfsz.c = -Wno-format
|
|
||||||
|
|
||||||
CFLAGS-tmpfile.c = -fexceptions
|
CFLAGS-tmpfile.c = -fexceptions
|
||||||
CFLAGS-tmpfile64.c = -fexceptions
|
CFLAGS-tmpfile64.c = -fexceptions
|
||||||
|
@ -116,9 +111,6 @@ CFLAGS-scanf15.c = -I../libio -I../stdlib -I../wcsmbs -I../time -I../string \
|
||||||
CFLAGS-scanf17.c = -I../libio -I../stdlib -I../wcsmbs -I../time -I../string \
|
CFLAGS-scanf17.c = -I../libio -I../stdlib -I../wcsmbs -I../time -I../string \
|
||||||
-I../wctype
|
-I../wctype
|
||||||
|
|
||||||
# We know the test has a format string problem.
|
|
||||||
CFLAGS-tst-sprintf.c = -Wno-format
|
|
||||||
|
|
||||||
CPPFLAGS += $(libio-mtsafe)
|
CPPFLAGS += $(libio-mtsafe)
|
||||||
|
|
||||||
$(objpfx)tst-setvbuf1.out: /dev/null $(objpfx)tst-setvbuf1
|
$(objpfx)tst-setvbuf1.out: /dev/null $(objpfx)tst-setvbuf1
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
#include <libc-internal.h>
|
||||||
|
|
||||||
int
|
int
|
||||||
main(int arc, char *argv[])
|
main(int arc, char *argv[])
|
||||||
|
@ -15,7 +16,14 @@ main(int arc, char *argv[])
|
||||||
printf("Result of fscanf %%n = %d\n", res);
|
printf("Result of fscanf %%n = %d\n", res);
|
||||||
printf("Scanned format = %d\n", val);
|
printf("Scanned format = %d\n", val);
|
||||||
|
|
||||||
|
/* We're testing exactly the case the warning is for. */
|
||||||
|
DIAG_PUSH_NEEDS_COMMENT;
|
||||||
|
DIAG_IGNORE_NEEDS_COMMENT (4.9, "-Wformat-zero-length");
|
||||||
|
|
||||||
res = fscanf(fp, "");
|
res = fscanf(fp, "");
|
||||||
|
|
||||||
|
DIAG_POP_NEEDS_COMMENT;
|
||||||
|
|
||||||
printf("Result of fscanf \"\" = %d\n", res);
|
printf("Result of fscanf \"\" = %d\n", res);
|
||||||
if (res != 0)
|
if (res != 0)
|
||||||
abort ();
|
abort ();
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
#include <libc-internal.h>
|
||||||
|
|
||||||
int
|
int
|
||||||
main (int argc, char *argv[])
|
main (int argc, char *argv[])
|
||||||
|
@ -14,7 +15,16 @@ main (int argc, char *argv[])
|
||||||
abort ();
|
abort ();
|
||||||
|
|
||||||
n = -2;
|
n = -2;
|
||||||
|
|
||||||
|
/* We are testing a corner case of the scanf format string here. */
|
||||||
|
DIAG_PUSH_NEEDS_COMMENT;
|
||||||
|
DIAG_IGNORE_NEEDS_COMMENT (4.9, "-Wformat");
|
||||||
|
DIAG_IGNORE_NEEDS_COMMENT (4.9, "-Wformat-extra-args");
|
||||||
|
|
||||||
ret = sscanf ("1000", "%llld", &n);
|
ret = sscanf ("1000", "%llld", &n);
|
||||||
|
|
||||||
|
DIAG_POP_NEEDS_COMMENT;
|
||||||
|
|
||||||
printf ("%%llld: ret: %d, n: %Ld\n", ret, n);
|
printf ("%%llld: ret: %d, n: %Ld\n", ret, n);
|
||||||
if (ret > 0 || n >= 0L)
|
if (ret > 0 || n >= 0L)
|
||||||
abort ();
|
abort ();
|
||||||
|
|
|
@ -92,7 +92,13 @@ do_test (void)
|
||||||
fprintf (fp, "%s", large);
|
fprintf (fp, "%s", large);
|
||||||
fprintf (fp, "%.*s", 30000, large);
|
fprintf (fp, "%.*s", 30000, large);
|
||||||
large[20000] = '\0';
|
large[20000] = '\0';
|
||||||
|
/* We're testing a large format string here and need to generate it
|
||||||
|
to avoid this source file being ridiculous. So disable the warning
|
||||||
|
about a generated format string. */
|
||||||
|
DIAG_PUSH_NEEDS_COMMENT;
|
||||||
|
DIAG_IGNORE_NEEDS_COMMENT (4.9, "-Wformat-security");
|
||||||
fprintf (fp, large);
|
fprintf (fp, large);
|
||||||
|
DIAG_POP_NEEDS_COMMENT;
|
||||||
fprintf (fp, "%-1.300000000s", "hello");
|
fprintf (fp, "%-1.300000000s", "hello");
|
||||||
|
|
||||||
if (fflush (fp) != 0 || ferror (fp) != 0 || fclose (fp) != 0)
|
if (fflush (fp) != 0 || ferror (fp) != 0 || fclose (fp) != 0)
|
||||||
|
|
|
@ -26,6 +26,11 @@
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include <float.h>
|
#include <float.h>
|
||||||
|
#include <libc-internal.h>
|
||||||
|
|
||||||
|
/* This whole file is picayune tests of corner cases of printf format strings.
|
||||||
|
The compiler warnings are not useful here. */
|
||||||
|
DIAG_IGNORE_NEEDS_COMMENT (4.9, "-Wformat");
|
||||||
|
|
||||||
static void rfg1 (void);
|
static void rfg1 (void);
|
||||||
static void rfg2 (void);
|
static void rfg2 (void);
|
||||||
|
|
|
@ -23,6 +23,10 @@ main (int argc, char *argv[])
|
||||||
register_printf_function ('B', printf_size, printf_size_info);
|
register_printf_function ('B', printf_size, printf_size_info);
|
||||||
DIAG_POP_NEEDS_COMMENT;
|
DIAG_POP_NEEDS_COMMENT;
|
||||||
|
|
||||||
|
/* All of the formats here use the nonstandard extension specifier
|
||||||
|
just registered, so compiler checking will never grok them. */
|
||||||
|
DIAG_IGNORE_NEEDS_COMMENT (4.9, "-Wformat");
|
||||||
|
DIAG_IGNORE_NEEDS_COMMENT (4.9, "-Wformat-extra-args");
|
||||||
|
|
||||||
sprintf (buf, "%g %b %B %.0b %.0B %.1b %.1B %8.0b %08.0B",
|
sprintf (buf, "%g %b %B %.0b %.0B %.1b %.1B %8.0b %08.0B",
|
||||||
V, 1025., V, V, V, V, V, V, V, V);
|
V, 1025., V, V, V, V, V, V, V, V);
|
||||||
|
|
|
@ -45,15 +45,26 @@ do_test (void)
|
||||||
result = 1;
|
result = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (sprintf (buf, "%67108863.16\"%d", 7) != 14
|
/* We are testing a corner case of the sprintf format string here. */
|
||||||
|| strcmp (buf, "%67108863.16\"7") != 0)
|
DIAG_PUSH_NEEDS_COMMENT;
|
||||||
|
DIAG_IGNORE_NEEDS_COMMENT (4.9, "-Wformat");
|
||||||
|
int n = sprintf (buf, "%67108863.16\"%d", 7);
|
||||||
|
DIAG_POP_NEEDS_COMMENT;
|
||||||
|
|
||||||
|
if (n != 14 || strcmp (buf, "%67108863.16\"7") != 0)
|
||||||
{
|
{
|
||||||
printf ("sprintf (buf, \"%%67108863.16\\\"%%d\", 7) produced `%s' output", buf);
|
printf ("sprintf (buf, \"%%67108863.16\\\"%%d\", 7) produced `%s' output",
|
||||||
|
buf);
|
||||||
result = 1;
|
result = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (sprintf (buf, "%*\"%d", 0x3ffffff, 7) != 11
|
/* We are testing a corner case of the sprintf format string here. */
|
||||||
|| strcmp (buf, "%67108863\"7") != 0)
|
DIAG_PUSH_NEEDS_COMMENT;
|
||||||
|
DIAG_IGNORE_NEEDS_COMMENT (4.9, "-Wformat");
|
||||||
|
n = sprintf (buf, "%*\"%d", 0x3ffffff, 7);
|
||||||
|
DIAG_POP_NEEDS_COMMENT;
|
||||||
|
|
||||||
|
if (n != 11 || strcmp (buf, "%67108863\"7") != 0)
|
||||||
{
|
{
|
||||||
printf ("sprintf (buf, \"%%*\\\"%%d\", 0x3ffffff, 7) produced `%s' output", buf);
|
printf ("sprintf (buf, \"%%*\\\"%%d\", 0x3ffffff, 7) produced `%s' output", buf);
|
||||||
result = 1;
|
result = 1;
|
||||||
|
|
|
@ -3,6 +3,7 @@
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <wchar.h>
|
#include <wchar.h>
|
||||||
|
#include <libc-internal.h>
|
||||||
|
|
||||||
static int
|
static int
|
||||||
t1 (void)
|
t1 (void)
|
||||||
|
@ -28,6 +29,12 @@ t2 (void)
|
||||||
INPUT, FORMAT, retval, (long int) VAR); \
|
INPUT, FORMAT, retval, (long int) VAR); \
|
||||||
result |= retval != EXP_RES || VAR != EXP_VAL
|
result |= retval != EXP_RES || VAR != EXP_VAL
|
||||||
|
|
||||||
|
/* This function is testing corner cases of the scanf format string,
|
||||||
|
so they do not all conform to -Wformat's expectations. */
|
||||||
|
DIAG_PUSH_NEEDS_COMMENT;
|
||||||
|
DIAG_IGNORE_NEEDS_COMMENT (4.9, "-Wformat");
|
||||||
|
DIAG_IGNORE_NEEDS_COMMENT (4.9, "-Wformat-extra-args");
|
||||||
|
|
||||||
SCAN ("12345", "%ld", N, 1, 12345);
|
SCAN ("12345", "%ld", N, 1, 12345);
|
||||||
SCAN ("12345", "%llllld", N, 0, -1);
|
SCAN ("12345", "%llllld", N, 0, -1);
|
||||||
SCAN ("12345", "%LLLLLd", N, 0, -1);
|
SCAN ("12345", "%LLLLLd", N, 0, -1);
|
||||||
|
@ -43,6 +50,8 @@ t2 (void)
|
||||||
retval, n, N); \
|
retval, n, N); \
|
||||||
result |= retval != 1 || n != 1 || N != -1;
|
result |= retval != 1 || n != 1 || N != -1;
|
||||||
|
|
||||||
|
DIAG_POP_NEEDS_COMMENT;
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue