cvs commit: src/usr.sbin/iostat iostat.c

Bruce Evans brde at optusnet.com.au
Sun Jan 13 09:44:22 PST 2008


On Sun, 13 Jan 2008, [utf-8] Dag-Erling Smørgrav wrote:

> David Schultz <das at FreeBSD.ORG> writes:
>> I don't think it always does set errno, but you can set errno to 0
>> before the call, and you'll get either the real error message from
>> err() or "unknown error".
>
> If asprintf() fails because malloc() failed, malloc() will have set
> errno to ENOMEM.  I can't think of any other failure mode for asprintf()
> that won't either be silently ignored (error in format string) or result
> in a segmentation fault (bogus argument to %s).

FreeBSD vfprintf.c doesn't touch errno directly, but POSIX with XSI
bugfeatures says that it sets errno to EILSEQ or EINVAL if it fails
with certain errors.  Also, when the printf variant is printf or
fprintf, it may set errno to ENOMEM, and when it is snprintf it may
set errno to EOVERFLOW for the non-error of passing a buffer size of
> INT_MAX (with a buffer that large) or for the error of the the result
wanting to be larger than INT_MAX.  POSIX is standardizing the behaviour
in the latter case and might require it to set errno (FreeBSD vfprintf.c
just returns EOF).

Bruce


More information about the cvs-src mailing list