From 8ac17a6ad40103e78e2905878c8d3d64b2f82894 Mon Sep 17 00:00:00 2001 From: Paul Eggert Date: Sat, 2 Sep 2017 02:05:09 -0700 Subject: [PATCH 3/3] glob: don't save and restore errno unnecessarily * lib/glob.c (glob): Don't save and restore errno merely because we have getpwnam_r. --- ChangeLog | 4 ++++ lib/glob.c | 4 ---- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/ChangeLog b/ChangeLog index 4314e91..867662d 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,9 @@ 2017-09-02 Paul Eggert + glob: don't save and restore errno unnecessarily + * lib/glob.c (glob): Don't save and restore errno + merely because we have getpwnam_r. + glob: don't assume getpwnam_r * lib/glob.c (glob): Port recent patches to platforms lacking getpwnam_r. diff --git a/lib/glob.c b/lib/glob.c index e9cf775..8de2d5f 100644 --- a/lib/glob.c +++ b/lib/glob.c @@ -637,7 +637,6 @@ glob (const char *pattern, int flags, int (*errfunc) (const char *, int), if (success) { struct passwd *p; - int save = errno; struct scratch_buffer pwtmpbuf; scratch_buffer_init (&pwtmpbuf); # if defined HAVE_GETPWNAM_R || defined _LIBC @@ -657,7 +656,6 @@ glob (const char *pattern, int flags, int (*errfunc) (const char *, int), retval = GLOB_NOSPACE; goto out; } - __set_errno (save); } # else p = getpwnam (pwtmpbuf.data); @@ -815,7 +813,6 @@ glob (const char *pattern, int flags, int (*errfunc) (const char *, int), # if defined HAVE_GETPWNAM_R || defined _LIBC struct passwd pwbuf; - int save = errno; while (getpwnam_r (user_name, &pwbuf, pwtmpbuf.data, pwtmpbuf.length, &p) != 0) @@ -830,7 +827,6 @@ glob (const char *pattern, int flags, int (*errfunc) (const char *, int), retval = GLOB_NOSPACE; goto out; } - __set_errno (save); } # else p = getpwnam (user_name); -- 2.7.4