bug-gnulib
[Top][All Lists]
Advanced

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

[PATCH] glob: fix getpwnam_r errno typo


From: Paul Eggert
Subject: [PATCH] glob: fix getpwnam_r errno typo
Date: Sat, 2 Sep 2017 03:57:55 -0700

* lib/glob.c (glob): Fix longstanding misuse of errno after
getpwnam_r, which returns an error number rather than setting
errno.
---
 ChangeLog  |  5 +++++
 lib/glob.c | 15 +++------------
 2 files changed, 8 insertions(+), 12 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 4dd0367..b5c3430 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,10 @@
 2017-09-02  Paul Eggert  <address@hidden>
 
+       glob: fix getpwnam_r errno typo
+       * lib/glob.c (glob): Fix longstanding misuse of errno after
+       getpwnam_r, which returns an error number rather than setting
+       errno.
+
        glob: fix typo in recent change
        * lib/glob.c (glob) [!HAVE_GETPWNAM_R && !_LIBC]:
        Fix recently-introduced typo.
diff --git a/lib/glob.c b/lib/glob.c
index f1b30ee..7ca1136 100644
--- a/lib/glob.c
+++ b/lib/glob.c
@@ -644,13 +644,8 @@ glob (const char *pattern, int flags, int (*errfunc) 
(const char *, int),
 
                   while (getpwnam_r (name, &pwbuf,
                                      pwtmpbuf.data, pwtmpbuf.length, &p)
-                         != 0)
+                         == ERANGE)
                     {
-                      if (errno != ERANGE)
-                        {
-                          p = NULL;
-                          break;
-                        }
                       if (!scratch_buffer_grow (&pwtmpbuf))
                         {
                           retval = GLOB_NOSPACE;
@@ -815,13 +810,9 @@ glob (const char *pattern, int flags, int (*errfunc) 
(const char *, int),
             struct passwd pwbuf;
 
             while (getpwnam_r (user_name, &pwbuf,
-                               pwtmpbuf.data, pwtmpbuf.length, &p) != 0)
+                               pwtmpbuf.data, pwtmpbuf.length, &p)
+                   == ERANGE)
               {
-                if (errno != ERANGE)
-                  {
-                    p = NULL;
-                    break;
-                  }
                 if (!scratch_buffer_grow (&pwtmpbuf))
                   {
                     retval = GLOB_NOSPACE;
-- 
2.7.4




reply via email to

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