diff --git a/usr.sbin/mtree/Makefile b/usr.sbin/mtree/Makefile index 5b5e03d8b416..e8afa08bd581 100644 --- a/usr.sbin/mtree/Makefile +++ b/usr.sbin/mtree/Makefile @@ -7,6 +7,8 @@ PROG= mtree MAN= mtree.8 SRCS= compare.c crc.c create.c excludes.c misc.c mtree.c spec.c verify.c +WARNS?= 4 + .if defined(BOOTSTRAPPING) .PATH: ${.CURDIR}/../../lib/libc/gen SRCS+= strtofflags.c diff --git a/usr.sbin/mtree/compare.c b/usr.sbin/mtree/compare.c index b2328a6643fa..5393b5d1c66b 100644 --- a/usr.sbin/mtree/compare.c +++ b/usr.sbin/mtree/compare.c @@ -63,7 +63,7 @@ static const char rcsid[] = extern int uflag; extern int lineno; -static char *ftype(u_int); +static const char *ftype(u_int); #define INDENTNAMELEN 8 #define LABEL \ @@ -74,14 +74,15 @@ static char *ftype(u_int); int compare(name, s, p) - char *name; + char *name __unused; register NODE *s; register FTSENT *p; { extern int uflag; u_long len, val; int fd, label; - char *cp, *tab = ""; + char *cp; + const char *tab = ""; char *fflags; label = 0; @@ -304,7 +305,7 @@ typeerr: LABEL; return (label); } -char * +const char * inotype(type) u_int type; { @@ -329,7 +330,7 @@ inotype(type) /* NOTREACHED */ } -static char * +static const char * ftype(type) u_int type; { diff --git a/usr.sbin/mtree/create.c b/usr.sbin/mtree/create.c index a7dfc67f9c72..3db05027bf9d 100644 --- a/usr.sbin/mtree/create.c +++ b/usr.sbin/mtree/create.c @@ -89,17 +89,18 @@ cwalk() { register FTS *t; register FTSENT *p; - time_t clock; + time_t cl; char *argv[2], host[MAXHOSTNAMELEN]; + char dot[] = "."; int indent = 0; - (void)time(&clock); + (void)time(&cl); (void)gethostname(host, sizeof(host)); (void)printf( "#\t user: %s\n#\tmachine: %s\n#\t tree: %s\n#\t date: %s", - getlogin(), host, fullpath, ctime(&clock)); + getlogin(), host, fullpath, ctime(&cl)); - argv[0] = "."; + argv[0] = dot; argv[1] = NULL; if ((t = fts_open(argv, ftsoptions, dsort)) == NULL) err(1, "line %d: fts_open", lineno); @@ -208,7 +209,7 @@ statf(indent, p) output(indent, &offset, "size=%qd", p->fts_statp->st_size); if (keys & F_TIME) output(indent, &offset, "time=%ld.%ld", - p->fts_statp->st_mtimespec.tv_sec, + (long)p->fts_statp->st_mtimespec.tv_sec, p->fts_statp->st_mtimespec.tv_nsec); if (keys & F_CKSUM && S_ISREG(p->fts_statp->st_mode)) { if ((fd = open(p->fts_accpath, O_RDONLY, 0)) < 0 || diff --git a/usr.sbin/mtree/excludes.c b/usr.sbin/mtree/excludes.c index 624b57a9ba92..253ef00211ac 100644 --- a/usr.sbin/mtree/excludes.c +++ b/usr.sbin/mtree/excludes.c @@ -103,7 +103,7 @@ check_excludes(const char *fname, const char *path) #define MATCH(g, n) (fnmatch((g), (n), FNM_PATHNAME) == 0) LIST_FOREACH(e, &excludes, link) { - if (e->pathname && MATCH(e->glob, path) + if ((e->pathname && MATCH(e->glob, path)) || MATCH(e->glob, fname)) return 1; } diff --git a/usr.sbin/mtree/extern.h b/usr.sbin/mtree/extern.h index 08054305e91f..68c13aa4180a 100644 --- a/usr.sbin/mtree/extern.h +++ b/usr.sbin/mtree/extern.h @@ -39,7 +39,7 @@ int crc(int, u_long *, u_long *); void cwalk(void); char *flags_to_string(u_long); -char *inotype(u_int); +const char *inotype(u_int); u_int parsekey(char *, int *); char *rlink(char *); NODE *spec(void); diff --git a/usr.sbin/mtree/misc.c b/usr.sbin/mtree/misc.c index 151a28bbda80..473adb7f0c52 100644 --- a/usr.sbin/mtree/misc.c +++ b/usr.sbin/mtree/misc.c @@ -51,7 +51,7 @@ static const char rcsid[] = extern int lineno; typedef struct _key { - char *name; /* key name */ + const char *name; /* key name */ u_int val; /* value */ #define NEEDVALUE 0x01 @@ -85,13 +85,14 @@ static KEY keylist[] = { {"uname", F_UNAME, NEEDVALUE}, }; +int keycompare(const void *, const void *); + u_int parsekey(name, needvaluep) char *name; int *needvaluep; { KEY *k, tmp; - int keycompare(const void *, const void *); tmp.name = name; k = (KEY *)bsearch(&tmp, keylist, sizeof(keylist) / sizeof(KEY), @@ -108,7 +109,7 @@ int keycompare(a, b) const void *a, *b; { - return (strcmp(((KEY *)a)->name, ((KEY *)b)->name)); + return (strcmp(((const KEY *)a)->name, ((const KEY *)b)->name)); } char * diff --git a/usr.sbin/mtree/mtree.c b/usr.sbin/mtree/mtree.c index 254c1b602bf3..c2c4710098a4 100644 --- a/usr.sbin/mtree/mtree.c +++ b/usr.sbin/mtree/mtree.c @@ -65,9 +65,7 @@ char fullpath[MAXPATHLEN]; static void usage(void); int -main(argc, argv) - int argc; - char *argv[]; +main(int argc, char *argv[]) { int ch; char *dir, *p; diff --git a/usr.sbin/mtree/verify.c b/usr.sbin/mtree/verify.c index 1177f7895b88..d56ee8fdfc8a 100644 --- a/usr.sbin/mtree/verify.c +++ b/usr.sbin/mtree/verify.c @@ -82,8 +82,9 @@ vwalk() register NODE *ep, *level; int specdepth, rval; char *argv[2]; + char dot[] = "."; - argv[0] = "."; + argv[0] = dot; argv[1] = NULL; if ((t = fts_open(argv, ftsoptions, NULL)) == NULL) err(1, "line %d: fts_open", lineno);