This is the mail archive of the
libc-alpha@sourceware.org
mailing list for the glibc project.
Re: [v1] Add Reiwa era tests to time/tst-strftime3.c
- From: DJ Delorie <dj at redhat dot com>
- To: Andreas Schwab <schwab at suse dot de>
- Cc: sellcey at marvell dot com, libc-alpha at sourceware dot org, tamuki at linet dot gr dot jp, digitalfreak at lingonborough dot com
- Date: Wed, 03 Apr 2019 12:06:17 -0400
- Subject: Re: [v1] Add Reiwa era tests to time/tst-strftime3.c
Andreas Schwab <schwab@suse.de> writes:
> The point of -Wformat-truncation is to warn if snprintf results in
> incomplete output, which is a generally a bug. If you want to truncate
> a string argument, use %s with a precision.
I don't want to truncate the string. Valid results from strptime will
never overflow the buffer, but if - in the rare case something goes
horribly wrong - the numbers are random and thus closer to MAXINT than
zero, a truncated buffer is no more than "doesn't match" as far as the
testsuite is concerned, and all I need.
I tried silencing the warning, but I couldn't find a way to limit the
max width of the various %d fields either; we'd need a buffer of
hundreds of bytes to guarantee *any* number will be ok, but if we can
guarantee that, there's no point in using snprintf anyway, might as well
use sprintf.