From 1c4053db63e2a3470ed8ace2ddd9636f9a6e135c Mon Sep 17 00:00:00 2001 From: Roland McGrath Date: Thu, 11 Dec 2014 13:46:21 -0800 Subject: Eliminate -Wno-format from printf/scanf tests. --- stdio-common/tst-sprintf.c | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) (limited to 'stdio-common/tst-sprintf.c') diff --git a/stdio-common/tst-sprintf.c b/stdio-common/tst-sprintf.c index 2fe373f350..ea3008b68b 100644 --- a/stdio-common/tst-sprintf.c +++ b/stdio-common/tst-sprintf.c @@ -45,15 +45,26 @@ do_test (void) result = 1; } - if (sprintf (buf, "%67108863.16\"%d", 7) != 14 - || strcmp (buf, "%67108863.16\"7") != 0) + /* We are testing a corner case of the sprintf format string here. */ + 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; } - if (sprintf (buf, "%*\"%d", 0x3ffffff, 7) != 11 - || strcmp (buf, "%67108863\"7") != 0) + /* We are testing a corner case of the sprintf format string here. */ + 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); result = 1; -- cgit v1.2.3