changeset 17845:e0af97efdba6

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.
author Pádraig Brady <P@draigBrady.com>
date Tue, 30 Dec 2014 23:37:26 +0000
parents 5f3fec5cdd17
children 566c9cd96b30
files ChangeLog lib/xstrtol.c
diffstat 2 files changed, 10 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- 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
--- a/lib/xstrtol.c
+++ b/lib/xstrtol.c
@@ -97,6 +97,8 @@
 
   p = (ptr ? ptr : &t_ptr);
 
+  errno = 0;
+
   if (! TYPE_SIGNED (__strtol_t))
     {
       const char *q = s;
@@ -107,7 +109,6 @@
         return LONGINT_INVALID;
     }
 
-  errno = 0;
   tmp = __strtol (s, p, strtol_base);
 
   if (*p == s)