This is the mail archive of the
libc-alpha@sourceware.org
mailing list for the glibc project.
Re: [PATCH 0/3] Fix wrong assumption about errno
- From: Zack Weinberg <zackw at panix dot com>
- To: Aurelien Jarno <aurelien at aurel32 dot net>
- Cc: GNU C Library <libc-alpha at sourceware dot org>
- Date: Thu, 21 Dec 2017 19:40:52 -0800
- Subject: Re: [PATCH 0/3] Fix wrong assumption about errno
- Authentication-results: sourceware.org; auth=none
- References: <20171221225453.13158-1-aurelien@aurel32.net>
On Thu, Dec 21, 2017 at 2:54 PM, Aurelien Jarno <aurelien@aurel32.net> wrote:
> These 3 patches fixes the wrong assumption that a successful function
> does not change errno. POSIX explicitly says that applications should
> check errno only after failure (or if the function specification
> provides additional scenarios where it has a defined value).
I like these changes in general, but there are a few specific cases
where functions _are_ guaranteed not to change the value of errno on
success, and application code relies on that. The one I remember off
the top of my head is the strto* family, where all possible return
values _could_ be the result of a successful parse, so you have to set
errno to 0 beforehand and then check it afterward. Please make sure
that your changes do not imply this is not the case.
zw