bug-gnulib
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[PATCH] xstrtol: ensure errno is reset


From: Pádraig Brady
Subject: [PATCH] xstrtol: ensure errno is reset
Date: Tue, 30 Dec 2014 23:42:58 +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     | 8 ++++++++
 lib/xstrtol.c | 3 ++-
 2 files changed, 10 insertions(+), 1 deletion(-)

diff --git a/ChangeLog b/ChangeLog
index f660a4c..4e75982 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,11 @@
+2014-12-30  Pádraig Brady  <address@hidden>
+
+       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  <address@hidden>
 
        utimens: fix dependency typo
diff --git a/lib/xstrtol.c b/lib/xstrtol.c
index 544a74a..7ab864b 100644
--- 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);
 
   if (*p == s)
-- 
2.1.0




reply via email to

[Prev in Thread] Current Thread [Next in Thread]