Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 30 Jan 2014 19:52:26 +0200
From:      Konstantin Belousov <kostikbel@gmail.com>
To:        Bruce Evans <brde@optusnet.com.au>
Cc:        Gennady Proskurin <gpr@mail.ru>, mdf@freebsd.org, standards@freebsd.org, jhb@freebsd.org
Subject:   Re: standards/186028: incorrect return values for posix_fallocate()
Message-ID:  <20140130175226.GW24664@kib.kiev.ua>
In-Reply-To: <20140125062048.R1518@besplex.bde.org>
References:  <201401230858.s0N8wwQB039907@oldred.freebsd.org> <20140123094017.GH24664@kib.kiev.ua> <F5BBA557-7ACA-4A7A-9245-165CF962922D@gid.co.uk> <20140124181246.GO24664@kib.kiev.ua> <20140125062048.R1518@besplex.bde.org>

next in thread | previous in thread | raw e-mail | index | archive | help

--lGQpFNrcSq0Rb43w
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
Content-Transfer-Encoding: quoted-printable

On Sat, Jan 25, 2014 at 06:46:16AM +1100, Bruce Evans wrote:
> I think it is better to not preserve errno, but to intentionally clobber
> it to the same value as madvise() does.  Its value is unspecified, and
> it is better to set it to new garbage than old garbage in case the
> application doesn't understand POSIX's suprising error handling.  This
> follows from C's specification of errno and POSIX's not saying anything
> about errnor for posix_madvise().  From a C99 draft:
>=20
>         [#3]  The  value of errno is zero at program startup, but is
>         never set to zero by any library function.159)  The value of
>         errno  may  be  set  to  nonzero  by a library function call
>         whether or not there is an error, provided the use of  errno
>         is not documented in the description of the function in this
>         International Standard.
>=20
> So any library function can set errno to any nonzero value other than
> 0, unless it is specifically documented to not do so.  stdio
> (__smakebuf()) setting errno to ENOTTY on success in most cases (by
> calling isatty() on a non-terminal) a classic example, and
> posix_madvise() should be no different, with more reason than stdio.
>=20
> In the above, you preserve errno on failure but don't explicitly
> preserve it on sucess.  madvise() doesn't clobber it on success, but
> this is an implementation detail.  For most functions, errno becomes
> garbage on success.
Yes, this is question of quality.  posix_madvise(2) should behave like
a syscall.

> The man pages emphasize not setting errno too much.  This matches your
> implementation (assuming the undocmented behaviour that madvise() doesn't
> modify errno on success), but applications shouldn't depend on this.

I document the implementation.  If somebody could provide the better
wording, I cannot object.

For now, I am going to commit the existing patch.

--lGQpFNrcSq0Rb43w
Content-Type: application/pgp-signature

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2.0.22 (FreeBSD)

iQIcBAEBAgAGBQJS6pFZAAoJEJDCuSvBvK1BRb0P/3Nvu7eXvK0+RfkOOUfZBuOc
SHSCbkjahEUw/VqiWXR96yLsHVSqhZFdEfObkG9IY3ErNElGNT4/ifJrMjrfxuUX
drfTK48DL8tkNE1YfzBK2qwsB1FUWo1ZxB89cqOhV5GZ49cUnivtV88G22NYXw5z
8tsjpyJEgTrl7pUDlaAzB99/9Lr7000jTIhGYG9eRTtede+Jes/uybChDeQHoso0
ilrLYenhVB0blsvvks8kzIK5bkCSPsWQh4515lhID/ERL0H8a1zr32HGYncEkZ1g
HliyF0FevrfuscYtsIMwbXOkfbUR07LO8qxWXeMZ/rWR7PWxO9kdimnnvBRhNE4z
4vXMCQ0kxdlEHHbEKrc+1O1geVsBuZZ7cnNP4VPw5wDuRmF/F8w/S7XG3BHXK9B6
+HsdQi6yxBFnLR3YqZE6MLg81FVtWMUP8X33yjuMC+aADUR2K3W2IOHOHvixiKFB
8LQ06oxARKvKQ6/38JjMXvLBoyZt6oiYmuqDIDaNRHcD+40vdqKxCtOZz+PwNPnm
20q1N0AXkO8WX5b4S31xWSPR/GDkp6Rwjl9KVaAqjbOErgZdMqriNT616PBR3kvN
2XWuIeZTieg1OewKgycHucbK0roAuB3+Wsp0aFSHIdUGceVsaB/W01CRf0qHXDRs
a5EZfH4GyDyzEWJ0J9Mx
=CjaO
-----END PGP SIGNATURE-----

--lGQpFNrcSq0Rb43w--



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