summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorpeadar <peadar@FreeBSD.org>2004-05-12 21:38:39 +0000
committerpeadar <peadar@FreeBSD.org>2004-05-12 21:38:39 +0000
commitffbf3dfefddedd27ca8a4b4961a9ae5d89802723 (patch)
treed8fc61e870f3320e715a2360327822714b1a3834
parent8f6801f678798f16b265e179d24b47e1c3554b67 (diff)
downloadFreeBSD-src-ffbf3dfefddedd27ca8a4b4961a9ae5d89802723.zip
FreeBSD-src-ffbf3dfefddedd27ca8a4b4961a9ae5d89802723.tar.gz
Fix some^Wseveral style bugs from last commit.
Remove "sys/types.h" as "sys/param.h" is already included Use cast rather than back-pointer to convert from public to private version of FTS data, and so avoid littering fts.h with any of the details. Pointed out By: bde, kientzle
-rw-r--r--include/fts.h1
-rw-r--r--lib/libc/gen/fts-compat.c41
-rw-r--r--lib/libc/gen/fts-compat.h1
-rw-r--r--lib/libc/gen/fts.c41
4 files changed, 38 insertions, 46 deletions
diff --git a/include/fts.h b/include/fts.h
index 20dfbfe..09c4600 100644
--- a/include/fts.h
+++ b/include/fts.h
@@ -63,7 +63,6 @@ typedef struct {
#define FTS_STOP 0x200 /* (private) unrecoverable error */
int fts_options; /* fts_open options, global flags */
void *fts_clientptr; /* thunk for sort function */
- struct _fts_private *fts_priv; /* implementation data */
} FTS;
typedef struct _ftsent {
diff --git a/lib/libc/gen/fts-compat.c b/lib/libc/gen/fts-compat.c
index 2081f44..3a4647e 100644
--- a/lib/libc/gen/fts-compat.c
+++ b/lib/libc/gen/fts-compat.c
@@ -40,10 +40,9 @@ static char sccsid[] = "@(#)fts.c 8.6 (Berkeley) 8/14/94";
__FBSDID("$FreeBSD$");
#include "namespace.h"
-#include <sys/types.h>
#include <sys/param.h>
-#include <sys/stat.h>
#include <sys/mount.h>
+#include <sys/stat.h>
#include <dirent.h>
#include <errno.h>
@@ -64,7 +63,7 @@ static int fts_palloc(FTS *, size_t);
static FTSENT *fts_sort(FTS *, FTSENT *, int);
static u_short fts_stat(FTS *, FTSENT *, int);
static int fts_safe_changedir(FTS *, FTSENT *, int, char *);
-static int fts_ufslinks(FTS *sp, const FTSENT *ent);
+static int fts_ufslinks(FTS *, const FTSENT *);
#define ISDOT(a) (a[0] == '.' && (!a[1] || (a[1] == '.' && !a[2])))
@@ -80,25 +79,24 @@ static int fts_ufslinks(FTS *sp, const FTSENT *ent);
#define BREAD 3 /* fts_read */
/*
- * Internal representation of FTS, including extra implementation details.
- * The FTS returned from fts_open is ftsp_fts from this structure, and it's
- * fts_priv in turn points back to this internal version. i.e. for a given
- * fts_private *priv: &priv->fts_fts == (FTS *)f == priv->fts_fts.fts_priv
+ * Internal representation of an FTS, including extra implementation
+ * details. The FTS returned from fts_open points to this structure's
+ * ftsp_fts member (and can be cast to an _fts_private as required)
*/
struct _fts_private {
- FTS ftsp_fts;
- struct statfs ftsp_statfs;
- dev_t ftsp_dev;
- int ftsp_linksreliable;
+ FTS ftsp_fts;
+ struct statfs ftsp_statfs;
+ dev_t ftsp_dev;
+ int ftsp_linksreliable;
};
/*
- * The "FTS_NOSTAT" option can avoid a lot of calls to stat(2) if it knows
- * that a directory could not possibly have subdirectories. This is decided
- * by looking at the link count: A subdirectory would increment its parent's
- * link count by virtue of its own ".." entry.
- * This assumption only holds for UFS-like filesystems that implement links
- * and directories this way, so we must punt for others.
+ * The "FTS_NOSTAT" option can avoid a lot of calls to stat(2) if it
+ * knows that a directory could not possibly have subdirectories. This
+ * is decided by looking at the link count: a subdirectory would
+ * increment its parent's link count by virtue of its own ".." entry.
+ * This assumption only holds for UFS-like filesystems that implement
+ * links and directories this way, so we must punt for others.
*/
static const char *ufslike_filesystems[] = {
@@ -129,13 +127,12 @@ fts_open(argv, options, compar)
}
/* Allocate/initialize the stream */
- if ((priv = malloc(sizeof(struct _fts_private))) == NULL)
+ if ((priv = malloc(sizeof(*priv))) == NULL)
return (NULL);
- memset(priv, 0, sizeof(struct _fts_private));
+ memset(priv, 0, sizeof(*priv));
sp = &priv->ftsp_fts;
sp->fts_compar = compar;
sp->fts_options = options;
- sp->fts_priv = priv;
/* Shush, GCC. */
tmp = NULL;
@@ -1202,7 +1199,7 @@ fts_ufslinks(FTS *sp, const FTSENT *ent)
struct _fts_private *priv;
const char **cpp;
- priv = sp->fts_priv;
+ priv = (struct _fts_private *)sp;
/*
* If this node's device is different from the previous, grab
* the filesystem information, and decide on the reliability
@@ -1224,5 +1221,5 @@ fts_ufslinks(FTS *sp, const FTSENT *ent)
priv->ftsp_linksreliable = 0;
}
}
- return priv->ftsp_linksreliable;
+ return (priv->ftsp_linksreliable);
}
diff --git a/lib/libc/gen/fts-compat.h b/lib/libc/gen/fts-compat.h
index 20dfbfe..09c4600 100644
--- a/lib/libc/gen/fts-compat.h
+++ b/lib/libc/gen/fts-compat.h
@@ -63,7 +63,6 @@ typedef struct {
#define FTS_STOP 0x200 /* (private) unrecoverable error */
int fts_options; /* fts_open options, global flags */
void *fts_clientptr; /* thunk for sort function */
- struct _fts_private *fts_priv; /* implementation data */
} FTS;
typedef struct _ftsent {
diff --git a/lib/libc/gen/fts.c b/lib/libc/gen/fts.c
index 2081f44..3a4647e 100644
--- a/lib/libc/gen/fts.c
+++ b/lib/libc/gen/fts.c
@@ -40,10 +40,9 @@ static char sccsid[] = "@(#)fts.c 8.6 (Berkeley) 8/14/94";
__FBSDID("$FreeBSD$");
#include "namespace.h"
-#include <sys/types.h>
#include <sys/param.h>
-#include <sys/stat.h>
#include <sys/mount.h>
+#include <sys/stat.h>
#include <dirent.h>
#include <errno.h>
@@ -64,7 +63,7 @@ static int fts_palloc(FTS *, size_t);
static FTSENT *fts_sort(FTS *, FTSENT *, int);
static u_short fts_stat(FTS *, FTSENT *, int);
static int fts_safe_changedir(FTS *, FTSENT *, int, char *);
-static int fts_ufslinks(FTS *sp, const FTSENT *ent);
+static int fts_ufslinks(FTS *, const FTSENT *);
#define ISDOT(a) (a[0] == '.' && (!a[1] || (a[1] == '.' && !a[2])))
@@ -80,25 +79,24 @@ static int fts_ufslinks(FTS *sp, const FTSENT *ent);
#define BREAD 3 /* fts_read */
/*
- * Internal representation of FTS, including extra implementation details.
- * The FTS returned from fts_open is ftsp_fts from this structure, and it's
- * fts_priv in turn points back to this internal version. i.e. for a given
- * fts_private *priv: &priv->fts_fts == (FTS *)f == priv->fts_fts.fts_priv
+ * Internal representation of an FTS, including extra implementation
+ * details. The FTS returned from fts_open points to this structure's
+ * ftsp_fts member (and can be cast to an _fts_private as required)
*/
struct _fts_private {
- FTS ftsp_fts;
- struct statfs ftsp_statfs;
- dev_t ftsp_dev;
- int ftsp_linksreliable;
+ FTS ftsp_fts;
+ struct statfs ftsp_statfs;
+ dev_t ftsp_dev;
+ int ftsp_linksreliable;
};
/*
- * The "FTS_NOSTAT" option can avoid a lot of calls to stat(2) if it knows
- * that a directory could not possibly have subdirectories. This is decided
- * by looking at the link count: A subdirectory would increment its parent's
- * link count by virtue of its own ".." entry.
- * This assumption only holds for UFS-like filesystems that implement links
- * and directories this way, so we must punt for others.
+ * The "FTS_NOSTAT" option can avoid a lot of calls to stat(2) if it
+ * knows that a directory could not possibly have subdirectories. This
+ * is decided by looking at the link count: a subdirectory would
+ * increment its parent's link count by virtue of its own ".." entry.
+ * This assumption only holds for UFS-like filesystems that implement
+ * links and directories this way, so we must punt for others.
*/
static const char *ufslike_filesystems[] = {
@@ -129,13 +127,12 @@ fts_open(argv, options, compar)
}
/* Allocate/initialize the stream */
- if ((priv = malloc(sizeof(struct _fts_private))) == NULL)
+ if ((priv = malloc(sizeof(*priv))) == NULL)
return (NULL);
- memset(priv, 0, sizeof(struct _fts_private));
+ memset(priv, 0, sizeof(*priv));
sp = &priv->ftsp_fts;
sp->fts_compar = compar;
sp->fts_options = options;
- sp->fts_priv = priv;
/* Shush, GCC. */
tmp = NULL;
@@ -1202,7 +1199,7 @@ fts_ufslinks(FTS *sp, const FTSENT *ent)
struct _fts_private *priv;
const char **cpp;
- priv = sp->fts_priv;
+ priv = (struct _fts_private *)sp;
/*
* If this node's device is different from the previous, grab
* the filesystem information, and decide on the reliability
@@ -1224,5 +1221,5 @@ fts_ufslinks(FTS *sp, const FTSENT *ent)
priv->ftsp_linksreliable = 0;
}
}
- return priv->ftsp_linksreliable;
+ return (priv->ftsp_linksreliable);
}
OpenPOWER on IntegriCloud