diff options
author | Todd C. Miller <millert@cvs.openbsd.org> | 2004-07-07 16:05:24 +0000 |
---|---|---|
committer | Todd C. Miller <millert@cvs.openbsd.org> | 2004-07-07 16:05:24 +0000 |
commit | 65ea41ef3c414b88623900e4353eb4717eebebb1 (patch) | |
tree | 10d1295e338c43f5acee8e75f90f17b7d67f8cb7 | |
parent | a8d68d9cb0e3fcaf601296187ca5c2ca499e741b (diff) |
If fts_close() fails and we have not yet seen an error, return -1.
-rw-r--r-- | lib/libc/gen/ftw.c | 10 | ||||
-rw-r--r-- | lib/libc/gen/nftw.c | 10 |
2 files changed, 12 insertions, 8 deletions
diff --git a/lib/libc/gen/ftw.c b/lib/libc/gen/ftw.c index de54cead64b..e6bc09c2f11 100644 --- a/lib/libc/gen/ftw.c +++ b/lib/libc/gen/ftw.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ftw.c,v 1.3 2004/07/06 15:51:17 millert Exp $ */ +/* $OpenBSD: ftw.c,v 1.4 2004/07/07 16:05:23 millert Exp $ */ /* * Copyright (c) 2003, 2004 Todd C. Miller <Todd.Miller@courtesan.com> @@ -21,7 +21,7 @@ */ #if defined(LIBC_SCCS) && !defined(lint) -static const char rcsid[] = "$OpenBSD: ftw.c,v 1.3 2004/07/06 15:51:17 millert Exp $"; +static const char rcsid[] = "$OpenBSD: ftw.c,v 1.4 2004/07/07 16:05:23 millert Exp $"; #endif /* LIBC_SCCS and not lint */ #include <sys/types.h> @@ -85,7 +85,9 @@ ftw(const char *path, int (*fn)(const char *, const struct stat *, int), } done: sverrno = errno; - (void) fts_close(ftsp); - errno = sverrno; + if (fts_close(ftsp) != 0 && error == 0) + error = -1; + else + errno = sverrno; return (error); } diff --git a/lib/libc/gen/nftw.c b/lib/libc/gen/nftw.c index 6ebe473c26d..9012c7dbdf9 100644 --- a/lib/libc/gen/nftw.c +++ b/lib/libc/gen/nftw.c @@ -1,4 +1,4 @@ -/* $OpenBSD: nftw.c,v 1.3 2004/07/06 15:51:17 millert Exp $ */ +/* $OpenBSD: nftw.c,v 1.4 2004/07/07 16:05:23 millert Exp $ */ /* * Copyright (c) 2003, 2004 Todd C. Miller <Todd.Miller@courtesan.com> @@ -21,7 +21,7 @@ */ #if defined(LIBC_SCCS) && !defined(lint) -static const char rcsid[] = "$OpenBSD: nftw.c,v 1.3 2004/07/06 15:51:17 millert Exp $"; +static const char rcsid[] = "$OpenBSD: nftw.c,v 1.4 2004/07/07 16:05:23 millert Exp $"; #endif /* LIBC_SCCS and not lint */ #include <sys/types.h> @@ -104,7 +104,9 @@ nftw(const char *path, int (*fn)(const char *, const struct stat *, int, } done: sverrno = errno; - (void) fts_close(ftsp); - errno = sverrno; + if (fts_close(ftsp) != 0 && error == 0) + error = -1; + else + errno = sverrno; return (error); } |