svn commit: r217589 - head/usr.sbin/syslogd
brde at optusnet.com.au
Thu Jan 20 13:12:48 UTC 2011
On Thu, 20 Jan 2011, David Malone wrote:
>> snprintf(buf, 2, "%*s%*s%*s", INT_MAX, "223", INT_MAX, "", 3, "bar");
> Ah - good example. Would it be worth adding some clarification to
> our man page? The paragraphs discussing return values suggest that
> *printf() functions can only fail because of output or malloc errors.
> I guess two other cases are invalid wide characters and the return
> value not being representable as an int?
I don't really understand wide characters. C99 doesn't seem to mention
EILSEQ for the printf() family. POSIX seems to mention it for the
printf() family only as an XSI extension, at least in an old draft.
FreeBSD's printf(3) mentions it, but in FreeBSD stdio only fgetwc.c
and vswprintf.c set it, and vswprintf() is documented in wprintf(3)
which doesn't mention EILSEQ. EILSEQ is mentioned for vfswprintf()
in POSIX via a long chain of cross references which eventually reach
fwprintf(), where EILSEQ is again an XSI extension. Peharps the meta-
sections associate this error with *all* wide character functions in
both C and POSIX, but that is even harder to find than the chain.
wprintf(3) doesn't have an ERRORS or RETURN VALUES section, but describes
the return values (without mentioning errno) in the DESCRIPTION section.
printf(3) doesn't have a RETURN VALUES section.
But yes, any clarification would be worth it :-).
The above format can be used with fprintf() and printf() too. These must
fail at the INT_MAX limit, and I think they do in FreeBSD. Files of size
>= 2GB have been small enough to create since about the same time as
FreeBSD-2 release. Trying to printf() more than 2GB to a terminal has
been possible for longer. Even at 300 bps, it only takes 2.26 years to
More information about the svn-src-head