diff options
author | imp <imp@cvs.openbsd.org> | 1997-08-29 22:43:09 +0000 |
---|---|---|
committer | imp <imp@cvs.openbsd.org> | 1997-08-29 22:43:09 +0000 |
commit | 4ae4ca31d118046952c54279bc6b91a188b9cdde (patch) | |
tree | 84ade6ba68622136ea94e974ad6512db0d9c6173 /lib | |
parent | b794a59429443fbc80b0c20d0b5ff7823939a60f (diff) |
Minor KNF changes to fts_safe_chdir and recent NetBSD code integration
as pointed out by Bruce Evans.
Diffstat (limited to 'lib')
-rw-r--r-- | lib/libc/gen/fts.c | 22 |
1 files changed, 8 insertions, 14 deletions
diff --git a/lib/libc/gen/fts.c b/lib/libc/gen/fts.c index e3c6197a1c0..ce5d2674f27 100644 --- a/lib/libc/gen/fts.c +++ b/lib/libc/gen/fts.c @@ -1,4 +1,4 @@ -/* $OpenBSD: fts.c,v 1.9 1997/08/02 00:13:49 millert Exp $ */ +/* $OpenBSD: fts.c,v 1.10 1997/08/29 22:43:08 imp Exp $ */ /*- * Copyright (c) 1990, 1993, 1994 @@ -37,7 +37,7 @@ #if 0 static char sccsid[] = "@(#)fts.c 8.6 (Berkeley) 8/14/94"; #else -static char rcsid[] = "$OpenBSD: fts.c,v 1.9 1997/08/02 00:13:49 millert Exp $"; +static char rcsid[] = "$OpenBSD: fts.c,v 1.10 1997/08/29 22:43:08 imp Exp $"; #endif #endif /* LIBC_SCCS and not lint */ @@ -261,8 +261,8 @@ fts_close(sp) * appended which would cause paths to be written as "....//foo". */ #define NAPPEND(p) \ - (p->fts_path[p->fts_pathlen-1] == '/' \ - ? p->fts_pathlen-1 : p->fts_pathlen) + (p->fts_path[p->fts_pathlen - 1] == '/' \ + ? p->fts_pathlen - 1 : p->fts_pathlen) FTSENT * fts_read(sp) @@ -1020,34 +1020,28 @@ fts_safe_changedir(sp, p, fd) FTSENT *p; int fd; { - int ret, oerrno, newfd = fd; + int ret, oerrno, newfd; struct stat sb; + newfd = fd; if (ISSET(FTS_NOCHDIR)) return (0); - if (fd < 0 && (newfd = open(p->fts_accpath, O_RDONLY, 0)) < 0) return (-1); - if (fstat(newfd, &sb)) { ret = -1; goto bail; } - if (p->fts_dev != sb.st_dev || p->fts_ino != sb.st_ino) { errno = ENOENT; /* disinformation */ ret = -1; goto bail; } - ret = fchdir(newfd); - bail: oerrno = errno; - if (fd < 0) - (void) close(newfd); - + (void)close(newfd); errno = oerrno; - return(ret); + return (ret); } |