Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 30 Jul 2016 23:10:55 +0300
From:      Andrey Chernov <ache@freebsd.org>
To:        Bruce Evans <brde@optusnet.com.au>
Cc:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   Re: svn commit: r303530 - head/lib/libc/gen
Message-ID:  <71b31670-244e-73e1-2092-4c4de5b8a692@freebsd.org>
In-Reply-To: <20160730184454.I2661@besplex.bde.org>
References:  <201607300209.u6U29BXC082700@repo.freebsd.org> <20160730140305.G1962@besplex.bde.org> <84c77b80-8b51-8698-f27a-7f6452867d66@freebsd.org> <20160730184454.I2661@besplex.bde.org>

next in thread | previous in thread | raw e-mail | index | archive | help
On 30.07.2016 11:52, Bruce Evans wrote:
> On Sat, 30 Jul 2016, Andrey Chernov wrote:
> 
>> On 30.07.2016 7:15, Bruce Evans wrote:
>>> On Sat, 30 Jul 2016, Andrey A. Chernov wrote:
>>>
>>>> Log:
>>>>  Reset errno for readdirfunc() before contunue.
>>>
>>> In C99, library functions are not permitted to set errno to 0.  The
>>> glob()
>>> family shouldn't use a different (worse) convention, and POSIX doesn't
>>> seem to have any special wording to allow different behaviour.

BTW, POSIX says so too: "No function in this volume of POSIX.1-2008
shall set errno to 0."

>> This is historic practice for this function at least since GLOB_LIMIT
>> was introduced (in 2001) and common across NetBSD/OpenBSD. Existent
>> programs may relay on that to check that limit is reached and not
>> allocation error, so with few additional overwriting from my side I add
>> nothing new:
>>
>> Revision 80525
>> Modified Sun Jul 29 00:52:37 2001 UTC (15 years ago) by mikeh
>> ...
>> errno = 0 is documented. See glob(3), GLOB_NOSPACE section too.
> 
> Hmm.  This is not in the BUGS section.  Strangely, the related non-bug
> that glob() may fail and set errno (to a reasonable but nonstandard and
> undocumented value?) is in the BUGS section.  I guess this is a bug
> in conjunction with the promise to set errno to 0 for some failures.
> 
>> The real problem is that glob(3) is very limited in error return codes,
>> so they reuse existent codes with errno hack.
> 
> It should have just used the least-unclosely-related standard errno
> instead of 0.

I was thinking about this way too, f.e. E2BIG or ERANGE are nice
candidatures, but still can't decide to break cross-BSD compatibility
and historic practice.




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?71b31670-244e-73e1-2092-4c4de5b8a692>