diff options
Diffstat (limited to 'io')
-rw-r--r-- | io/fts.c | 21 | ||||
-rw-r--r-- | io/readlink.c | 4 | ||||
-rw-r--r-- | io/readlinkat.c | 4 |
3 files changed, 20 insertions, 9 deletions
@@ -93,7 +93,8 @@ fts_open(argv, options, compar) register FTS *sp; register FTSENT *p, *root; register int nitems; - FTSENT *parent, *tmp; + FTSENT *parent = NULL; + FTSENT *tmp; /* Options check. */ if (options & ~FTS_OPTIONMASK) { @@ -124,9 +125,11 @@ fts_open(argv, options, compar) goto mem1; /* Allocate/initialize root's parent. */ - if ((parent = fts_alloc(sp, "", 0)) == NULL) - goto mem2; - parent->fts_level = FTS_ROOTPARENTLEVEL; + if (*argv != NULL) { + if ((parent = fts_alloc(sp, "", 0)) == NULL) + goto mem2; + parent->fts_level = FTS_ROOTPARENTLEVEL; + } /* Allocate/initialize root(s). */ for (root = NULL, nitems = 0; *argv != NULL; ++argv, ++nitems) { @@ -744,6 +747,10 @@ mem1: saved_errno = errno; p->fts_flags |= FTS_ISW; #endif +#if 0 + /* Unreachable code. cderrno is only ever set to a nonnull + value if dirp is closed at the same time. But then we + cannot enter this loop. */ if (cderrno) { if (nlinks) { p->fts_info = FTS_NS; @@ -751,7 +758,9 @@ mem1: saved_errno = errno; } else p->fts_info = FTS_NSOK; p->fts_accpath = cur->fts_accpath; - } else if (nlinks == 0 + } else +#endif + if (nlinks == 0 #if defined DT_DIR && defined _DIRENT_HAVE_D_TYPE || (nostat && dp->d_type != DT_DIR && dp->d_type != DT_UNKNOWN) @@ -819,6 +828,7 @@ mem1: saved_errno = errno; fts_safe_changedir(sp, cur->fts_parent, -1, ".."))) { cur->fts_info = FTS_ERR; SET(FTS_STOP); + fts_lfree(head); return (NULL); } @@ -826,6 +836,7 @@ mem1: saved_errno = errno; if (!nitems) { if (type == BREAD) cur->fts_info = FTS_DP; + fts_lfree(head); return (NULL); } diff --git a/io/readlink.c b/io/readlink.c index 779b809eaa..b69d08695c 100644 --- a/io/readlink.c +++ b/io/readlink.c @@ -1,4 +1,4 @@ -/* Copyright (C) 1991, 1995, 1996, 1997 Free Software Foundation, Inc. +/* Copyright (C) 1991, 1995, 1996, 1997, 2006 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or @@ -22,7 +22,7 @@ /* Read the contents of the symbolic link PATH into no more than LEN bytes of BUF. The contents are not null-terminated. Returns the number of characters read, or -1 for errors. */ -int +ssize_t __readlink (path, buf, len) const char *path; char *buf; diff --git a/io/readlinkat.c b/io/readlinkat.c index c6a032c474..483dc4914d 100644 --- a/io/readlinkat.c +++ b/io/readlinkat.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2005 Free Software Foundation, Inc. +/* Copyright (C) 2005, 2006 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or @@ -23,7 +23,7 @@ /* Read the contents of the symbolic link PATH relative to FD into no more than LEN bytes of BUF. The contents are not null-terminated. Returns the number of characters read, or -1 for errors. */ -int +ssize_t readlinkat (fd, path, buf, len) int fd; const char *path; |