> From: "Theo de Raadt" <dera...@openbsd.org>
> Date: Wed, 26 Jul 2017 08:07:53 -0600
> 
> > The current behaviour of our implementation is to return the number
> > of characters printed *and* set errno = ENOMEM.
> 
> I expect it should not set errno.  As a general rule, errno should
> only be set if an error has been indicated.  Other short operations
> don't set errno.

POSIX says:

  "The value of errno should only be examined when it is indicated to
  be valid by a function's return value."

So clobbering errno when not returning a negative number is allowed.

The real question here is if we should report (partial) success if we
encounter an error halfway through printing/formatting.

Reply via email to