aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDJ Delorie <dj@redhat.com>2019-04-03 17:49:43 -0400
committerDJ Delorie <dj@redhat.com>2019-04-03 17:49:43 -0400
commit8260f23616c1a2a4e609f989a195fba7690a42ca (patch)
tree32e5108ea112e5aa178894a6cb94bc3084d2d70d
parent0bd545ee235dd02aa95394e62bca1faff02eeae3 (diff)
downloadglibc-8260f23616c1a2a4e609f989a195fba7690a42ca.zip
glibc-8260f23616c1a2a4e609f989a195fba7690a42ca.tar.gz
glibc-8260f23616c1a2a4e609f989a195fba7690a42ca.tar.bz2
time/tst-strftime3.c: Disable snprintf warning.
snprintf will only truncate the output if the data its given is corrupted, but a truncated buffer will not match the "pristine" data's buffer, which is all we need. So just disable the warning via the DIAG macros.
-rw-r--r--ChangeLog5
-rw-r--r--time/tst-strftime3.c10
2 files changed, 15 insertions, 0 deletions
diff --git a/ChangeLog b/ChangeLog
index 9eb0afd..b5c13e8 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2019-04-03 DJ Delorie <dj@redhat.com>
+
+ * time/tst-strftime3.c (tm_to_printed): Disable warning about
+ snprintf truncating output.
+
2019-04-02 DJ Delorie <dj@redhat.com>
* time/tst-strftime3.c: Add new Japanese era tests. Fix printf
diff --git a/time/tst-strftime3.c b/time/tst-strftime3.c
index 32ce0d9..eeca092 100644
--- a/time/tst-strftime3.c
+++ b/time/tst-strftime3.c
@@ -25,6 +25,7 @@
#include <support/check.h>
#include <array_length.h>
+#include <libc-diag.h>
/* These exist for the convenience of writing the test data, because
zero-based vs one-based. */
@@ -440,6 +441,14 @@ tm_to_printed (struct tm *tm, char *buffer)
sprintf (temp, "%d", tm->tm_wday);
}
+ DIAG_PUSH_NEEDS_COMMENT;
+#if __GNUC_PREREQ (9, 0)
+ /* GCC 9 warns that strncmp may truncate its output, but that's why
+ we're using it. When it needs to truncate, it got corrupted
+ data, and we only care that the string is different than valid
+ data, which won't truncate. */
+ DIAG_IGNORE_NEEDS_COMMENT (9, "-Wformat-truncation=");
+#endif
snprintf (buffer, TMBUFLEN, "%04d/%02d/%02d %02d:%02d:%02d %s",
tm->tm_year + 1900,
tm->tm_mon + 1,
@@ -448,6 +457,7 @@ tm_to_printed (struct tm *tm, char *buffer)
tm->tm_min,
tm->tm_sec,
wn);
+ DIAG_POP_NEEDS_COMMENT;
}
static int