Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 14 Jan 2008 04:44:08 +1100 (EST)
From:      Bruce Evans <brde@optusnet.com.au>
To:        =?utf-8?Q?Dag-Erling_Sm=C3=B8rgrav?= <des@des.no>
Cc:        cvs-src@FreeBSD.org, Maxim Konovalov <maxim@macomnet.ru>, src-committers@FreeBSD.org, cvs-all@FreeBSD.org
Subject:   Re: cvs commit: src/usr.sbin/iostat iostat.c
Message-ID:  <20080114042508.X11683@besplex.bde.org>
In-Reply-To: <86ve5xq142.fsf@ds4.des.no>
References:  <200801122037.m0CKb6CS009262@repoman.freebsd.org> <20080112205254.GB3090@VARK.MIT.EDU> <20080112235350.C10888@mp2.macomnet.net> <20080112211919.GA3408@VARK.MIT.EDU> <86ve5xq142.fsf@ds4.des.no>

next in thread | previous in thread | raw e-mail | index | archive | help
  This message is in MIME format.  The first part should be readable text,
  while the remaining parts are likely unreadable without MIME-aware tools.

--0-1524310525-1200246248=:11683
Content-Type: TEXT/PLAIN; charset=X-UNKNOWN; format=flowed
Content-Transfer-Encoding: QUOTED-PRINTABLE

On Sun, 13 Jan 2008, [utf-8] Dag-Erling Sm=C3=B8rgrav wrote:

> David Schultz <das@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
--0-1524310525-1200246248=:11683--



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20080114042508.X11683>