aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSteve Ellcey <sellcey@caviumnetworks.com>2016-11-02 16:00:39 -0700
committerH.J. Lu <hjl.tools@gmail.com>2017-06-30 09:43:17 -0700
commitd248276e69af21c9729d8df6c920a984efccc6ae (patch)
tree0779ac724d4083e58f0cf0dc20e909b217cb2615
parent67f1789e52e8b3a6107c536e160bc630f6b501e5 (diff)
downloadglibc-d248276e69af21c9729d8df6c920a984efccc6ae.tar
glibc-d248276e69af21c9729d8df6c920a984efccc6ae.tar.gz
glibc-d248276e69af21c9729d8df6c920a984efccc6ae.tar.bz2
glibc-d248276e69af21c9729d8df6c920a984efccc6ae.zip
Fix -Wformat-length warning in time/tst-strptime2.c
* time/tst-strptime2.c: Ignore -Wformat-length warning. (cherry picked from commit 26d7185d6f0a79188fdf02c5eec6e52bb29112f8)
-rw-r--r--time/tst-strptime2.c11
1 files changed, 11 insertions, 0 deletions
diff --git a/time/tst-strptime2.c b/time/tst-strptime2.c
index 7fe7350024..04f7cff437 100644
--- a/time/tst-strptime2.c
+++ b/time/tst-strptime2.c
@@ -4,6 +4,7 @@
#include <stdbool.h>
#include <stdio.h>
#include <time.h>
+#include <libc-internal.h>
/* Dummy string is used to match strptime's %s specifier. */
@@ -67,10 +68,20 @@ mkbuf (char *buf, bool neg, bool colon, unsigned int hhmm, size_t ndigits)
long int expect = LONG_MAX;
i = sprintf (buf, "%s %c", dummy_string, sign);
+#if __GNUC_PREREQ (7, 0)
+ /* GCC issues a warning when it thinks the snprintf buffer may be too short.
+ This test is explicitly using short buffers to force snprintf to truncate
+ the output so we ignore the warnings. */
+ DIAG_PUSH_NEEDS_COMMENT;
+ DIAG_IGNORE_NEEDS_COMMENT (7.0, "-Wformat-length");
+#endif
if (colon)
snprintf (buf + i, ndigits + 2, "%02u:%02u", hh, mm);
else
snprintf (buf + i, ndigits + 1, "%04u", hhmm);
+#if __GNUC_PREREQ (7, 0)
+ DIAG_POP_NEEDS_COMMENT;
+#endif
if (mm <= mm_max && (ndigits == 2 || ndigits == 4))
{