]> Savannah Git Hosting - gnulib.git/commitdiff
xstrtol: ensure errno is reset
authorPádraig Brady <P@draigBrady.com>
Tue, 30 Dec 2014 23:37:26 +0000 (23:37 +0000)
committerPádraig Brady <P@draigBrady.com>
Tue, 30 Dec 2014 23:42:03 +0000 (23:42 +0000)
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.

ChangeLog
lib/xstrtol.c

index f660a4c558ab75e16db25b4569ca4699847bd8c3..4e75982bb8a96e0c1d7d05961e1cd59002b837b5 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,11 @@
+2014-12-30  Pádraig Brady  <P@draigBrady.com>
+
+       xstrtol: ensure errno is reset
+       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.
+
 2014-12-28  Paul Eggert  <eggert@cs.ucla.edu>
 
        utimens: fix dependency typo
index 544a74aa1c52f13db33f579adbf91dc530773307..7ab864bb52ffb51d4bf9ca68ef95a1b93a6b63d4 100644 (file)
@@ -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);
 
   if (*p == s)