This is the mail archive of the libc-alpha@sourceware.org mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

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.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]