[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH] xstrtol: ensure errno is reset
From: |
Jim Meyering |
Subject: |
Re: [PATCH] xstrtol: ensure errno is reset |
Date: |
Tue, 30 Dec 2014 16:13:10 -0800 |
On Tue, Dec 30, 2014 at 3:42 PM, Pádraig Brady <address@hidden> wrote:
> Since commit 3bf75404, on 26-09-1998, errno may not have been reset.
> Noticed with a spurious coreutils test failure on Darwin 14.0.0.
>
> * lib/xstrtol.c (__xstrtol): Always reset errno before returning.
Cool (well, sort of :-), since it's mine), a 16-year-old bug.
Thanks for noticing/fixing it!
> --- a/lib/xstrtol.c
> +++ b/lib/xstrtol.c
> @@ -97,6 +97,8 @@ __xstrtol (const char *s, char **ptr, int strtol_base,
>
> p = (ptr ? ptr : &t_ptr);
>
> + errno = 0;
> +
> if (! TYPE_SIGNED (__strtol_t))
> {
> const char *q = s;
> @@ -107,7 +109,6 @@ __xstrtol (const char *s, char **ptr, int strtol_base,
> return LONGINT_INVALID;
> }
>
> - errno = 0;
> tmp = __strtol (s, p, strtol_base);
...