* lib/glob.c (glob): Lose register modifier. Drop redundant code. (globfree): Drop useless if-before-free. (collated_compare): Add const-safety.
Signed-off-by: Eric Blake <ebl...@redhat.com> --- ChangeLog | 8 ++++++++ lib/glob.c | 13 +++++-------- 2 files changed, 13 insertions(+), 8 deletions(-) diff --git a/ChangeLog b/ChangeLog index 5153846..b2e66e4 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,11 @@ +2010-03-22 Eric Blake <ebl...@redhat.com> + + glob: synchronize from glibc + * lib/glob.c (glob): Lose register modifier. Drop redundant + code. + (globfree): Drop useless if-before-free. + (collated_compare): Add const-safety. + 2010-02-17 Eric Blake <e...@byu.net> manywarnings: add more warnings diff --git a/lib/glob.c b/lib/glob.c index 03b55df..deceeb7 100644 --- a/lib/glob.c +++ b/lib/glob.c @@ -256,10 +256,10 @@ int GLOB_ATTRIBUTE #endif glob (pattern, flags, errfunc, pglob) - const char * restrict pattern; + const char *pattern; int flags; int (*errfunc) (const char *, int); - glob_t * restrict pglob; + glob_t *pglob; { const char *filename; const char *dirname; @@ -698,8 +698,6 @@ glob (pattern, flags, errfunc, pglob) { char *newp; newp = __alloca (end_name - dirname); - *((char *) mempcpy (newp, dirname + 1, end_name - dirname)) - = '\0'; if (unescape != NULL) { char *p = mempcpy (newp, dirname + 1, @@ -1100,7 +1098,6 @@ globfree (pglob) { size_t i; for (i = 0; i < pglob->gl_pathc; ++i) - if (pglob->gl_pathv[pglob->gl_offs + i] != NULL) free (pglob->gl_pathv[pglob->gl_offs + i]); free (pglob->gl_pathv); pglob->gl_pathv = NULL; @@ -1115,8 +1112,8 @@ libc_hidden_def (globfree) static int collated_compare (const void *a, const void *b) { - char *const *ps1 = a; char *s1 = *ps1; - char *const *ps2 = b; char *s2 = *ps2; + const char *const s1 = *(const char *const *const) a; + const char *const s2 = *(const char *const *const) b; if (s1 == s2) return 0; @@ -1243,9 +1240,9 @@ weak_alias (__glob_pattern_p, glob_pattern_p) #endif /* !GLOB_ONLY_P */ -#if !defined _LIBC || !defined GLOB_ONLY_P /* We put this in a separate function mainly to allow the memory allocated with alloca to be recycled. */ +#if !defined _LIBC || !defined GLOB_ONLY_P static int __attribute_noinline__ link_exists2_p (const char *dir, size_t dirlen, const char *fname, -- 1.6.6.1