On Fri, 25 Dec 2015 00:30:29 +0100, Ingo Schwarze wrote:

> Besides, i don't see the point in messing with FILE flags at all
> in case of encoding errors.  As opposed to fgetwc(3) and fputwc(3),
> the manual doesn't document this fiddling, and POSIX doesn't ask
> for it.  No other conversions in printf(3) set the error indicator.
> It isn't required because printf(3) provides a proper error return
> (-1) in the first place.  Has anybody ever seen any code calling
> ferror(3) after printf(3)?  That just wouldn't make sense.
> Of course, printf(3) can result in the error indicator getting set,
> but only if the underlying low-level write calls fail.

You are correct that neither our man page nor ISO C document
setting the error indicator.  I get your expected output on Linux
and Solaris so I think this diff is correct.  I wonder if it is
worth documenting that the error indicator is not set in fprintf(3)?

We do have code in our tree that checks ferror() after doing writes
via fprintf.  One example src/usr.sbin/smtpd, but I have not done
an exhaustive check.

 - todd

Reply via email to