summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authormillert <millert@openbsd.org>2004-07-06 15:51:17 +0000
committermillert <millert@openbsd.org>2004-07-06 15:51:17 +0000
commitc1e28e316f0d337073cc2f584c0280e9793a41c0 (patch)
treeaf143e8a7739b8367594d8687a40a6181895b7ce /lib
parentvarious cleanup (diff)
downloadwireguard-openbsd-c1e28e316f0d337073cc2f584c0280e9793a41c0.tar.xz
wireguard-openbsd-c1e28e316f0d337073cc2f584c0280e9793a41c0.zip
Set path in declaration to avoid an ugly cast in fts_open()
Set FTS_LOGICAL in flags if we didn't set FTS_PHYSICAL as required by fts(3)
Diffstat (limited to 'lib')
-rw-r--r--lib/libc/gen/ftw.c16
-rw-r--r--lib/libc/gen/nftw.c17
2 files changed, 14 insertions, 19 deletions
diff --git a/lib/libc/gen/ftw.c b/lib/libc/gen/ftw.c
index 98bb8e8fd00..de54cead64b 100644
--- a/lib/libc/gen/ftw.c
+++ b/lib/libc/gen/ftw.c
@@ -1,7 +1,7 @@
-/* $OpenBSD: ftw.c,v 1.2 2003/07/21 21:15:32 millert Exp $ */
+/* $OpenBSD: ftw.c,v 1.3 2004/07/06 15:51:17 millert Exp $ */
/*
- * Copyright (c) 2003 Todd C. Miller <Todd.Miller@courtesan.com>
+ * Copyright (c) 2003, 2004 Todd C. Miller <Todd.Miller@courtesan.com>
*
* Permission to use, copy, modify, and distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
@@ -21,7 +21,7 @@
*/
#if defined(LIBC_SCCS) && !defined(lint)
-static const char rcsid[] = "$OpenBSD: ftw.c,v 1.2 2003/07/21 21:15:32 millert Exp $";
+static const char rcsid[] = "$OpenBSD: ftw.c,v 1.3 2004/07/06 15:51:17 millert Exp $";
#endif /* LIBC_SCCS and not lint */
#include <sys/types.h>
@@ -35,10 +35,10 @@ int
ftw(const char *path, int (*fn)(const char *, const struct stat *, int),
int nfds)
{
- const char *paths[2];
+ char * const paths[2] = { (char *)path, NULL };
FTSENT *cur;
FTS *ftsp;
- int fnflag, error, sverrno;
+ int error = 0, fnflag, sverrno;
/* XXX - nfds is currently unused */
if (nfds < 1 || nfds > OPEN_MAX) {
@@ -46,13 +46,9 @@ ftw(const char *path, int (*fn)(const char *, const struct stat *, int),
return (-1);
}
- paths[0] = path;
- paths[1] = NULL;
- ftsp = fts_open((char * const *)paths, FTS_COMFOLLOW | FTS_NOCHDIR,
- NULL);
+ ftsp = fts_open(paths, FTS_LOGICAL | FTS_COMFOLLOW | FTS_NOCHDIR, NULL);
if (ftsp == NULL)
return (-1);
- error = 0;
while ((cur = fts_read(ftsp)) != NULL) {
switch (cur->fts_info) {
case FTS_D:
diff --git a/lib/libc/gen/nftw.c b/lib/libc/gen/nftw.c
index b3ba35704dd..6ebe473c26d 100644
--- a/lib/libc/gen/nftw.c
+++ b/lib/libc/gen/nftw.c
@@ -1,7 +1,7 @@
-/* $OpenBSD: nftw.c,v 1.2 2003/07/21 21:15:32 millert Exp $ */
+/* $OpenBSD: nftw.c,v 1.3 2004/07/06 15:51:17 millert Exp $ */
/*
- * Copyright (c) 2003 Todd C. Miller <Todd.Miller@courtesan.com>
+ * Copyright (c) 2003, 2004 Todd C. Miller <Todd.Miller@courtesan.com>
*
* Permission to use, copy, modify, and distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
@@ -21,7 +21,7 @@
*/
#if defined(LIBC_SCCS) && !defined(lint)
-static const char rcsid[] = "$OpenBSD: nftw.c,v 1.2 2003/07/21 21:15:32 millert Exp $";
+static const char rcsid[] = "$OpenBSD: nftw.c,v 1.3 2004/07/06 15:51:17 millert Exp $";
#endif /* LIBC_SCCS and not lint */
#include <sys/types.h>
@@ -35,11 +35,11 @@ int
nftw(const char *path, int (*fn)(const char *, const struct stat *, int,
struct FTW *), int nfds, int ftwflags)
{
- const char *paths[2];
+ char * const paths[2] = { (char *)path, NULL };
struct FTW ftw;
FTSENT *cur;
FTS *ftsp;
- int ftsflags, fnflag, error, postorder, sverrno;
+ int error = 0, ftsflags, fnflag, postorder, sverrno;
/* XXX - nfds is currently unused */
if (nfds < 1 || nfds > OPEN_MAX) {
@@ -54,13 +54,12 @@ nftw(const char *path, int (*fn)(const char *, const struct stat *, int,
ftsflags |= FTS_XDEV;
if (ftwflags & FTW_PHYS)
ftsflags |= FTS_PHYSICAL;
+ else
+ ftsflags |= FTS_LOGICAL;
postorder = (ftwflags & FTW_DEPTH) != 0;
- paths[0] = path;
- paths[1] = NULL;
- ftsp = fts_open((char * const *)paths, ftsflags, NULL);
+ ftsp = fts_open(paths, ftsflags, NULL);
if (ftsp == NULL)
return (-1);
- error = 0;
while ((cur = fts_read(ftsp)) != NULL) {
switch (cur->fts_info) {
case FTS_D: