From f0edd7ef8f286a7c5bbe22a375e7cd4dfc9b8c08 Mon Sep 17 00:00:00 2001 From: robert Date: Thu, 13 Mar 2003 23:35:30 +0000 Subject: - Align the function prototype of the external `crc' function with how `crc' is actually defined. - Remove an unnecessary `extern' variable declaration. Data type corrections: - Define a variable which contains a file byte offset value as type off_t as required by the `crc' function. - Change the type of a variable carrying a CRC checksum from `u_long' to `uint32_t'. - Substitute the wrong `extern' variable declaration of `crc_total' by putting a correct one in the shared header extern.h. `crc_total' is defined as an `uint32_t', thus fixing incorrect mtree checksums on big-endian LP64 machines. --- usr.sbin/mtree/compare.c | 6 +++--- usr.sbin/mtree/create.c | 8 ++++---- usr.sbin/mtree/extern.h | 3 ++- usr.sbin/mtree/mtree.c | 4 +--- usr.sbin/mtree/verify.c | 3 +-- 5 files changed, 11 insertions(+), 13 deletions(-) (limited to 'usr.sbin/mtree') diff --git a/usr.sbin/mtree/compare.c b/usr.sbin/mtree/compare.c index a0de667..9aa768f 100644 --- a/usr.sbin/mtree/compare.c +++ b/usr.sbin/mtree/compare.c @@ -79,9 +79,9 @@ compare(name, s, p) register NODE *s; register FTSENT *p; { - extern int uflag; - u_long len, val; + uint32_t val; int fd, label; + off_t len; char *cp; const char *tab = ""; char *fflags; @@ -211,7 +211,7 @@ typeerr: LABEL; if (s->cksum != val) { LABEL; (void)printf("%scksum expected %lu found %lu\n", - tab, s->cksum, val); + tab, s->cksum, (unsigned long)val); tab = "\t"; } } diff --git a/usr.sbin/mtree/create.c b/usr.sbin/mtree/create.c index ae82966..7e50be3 100644 --- a/usr.sbin/mtree/create.c +++ b/usr.sbin/mtree/create.c @@ -68,7 +68,6 @@ static const char rcsid[] = #define INDENTNAMELEN 15 #define MAXLINELEN 80 -extern long int crc_total; extern int ftsoptions; extern int dflag, iflag, nflag, sflag; extern u_int keys; @@ -142,7 +141,7 @@ cwalk() } (void)fts_close(t); if (sflag && keys & F_CKSUM) - warnx("%s checksum: %lu", fullpath, crc_total); + warnx("%s checksum: %lu", fullpath, (unsigned long)crc_total); } static void @@ -152,7 +151,8 @@ statf(indent, p) { struct group *gr; struct passwd *pw; - u_long len, val; + uint32_t val; + off_t len; int fd, offset; char *fflags; char *escaped_name; @@ -218,7 +218,7 @@ statf(indent, p) crc(fd, &val, &len)) err(1, "line %d: %s", lineno, p->fts_accpath); (void)close(fd); - output(indent, &offset, "cksum=%lu", val); + output(indent, &offset, "cksum=%lu", (unsigned long)val); } #ifdef MD5 if (keys & F_MD5 && S_ISREG(p->fts_statp->st_mode)) { diff --git a/usr.sbin/mtree/extern.h b/usr.sbin/mtree/extern.h index 68c13aa..f1630af 100644 --- a/usr.sbin/mtree/extern.h +++ b/usr.sbin/mtree/extern.h @@ -33,9 +33,10 @@ * @(#)extern.h 8.1 (Berkeley) 6/6/93 * $FreeBSD$ */ +extern uint32_t crc_total; int compare(char *, NODE *, FTSENT *); -int crc(int, u_long *, u_long *); +int crc(int, uint32_t *, off_t *); void cwalk(void); char *flags_to_string(u_long); diff --git a/usr.sbin/mtree/mtree.c b/usr.sbin/mtree/mtree.c index c2c4710..c4ea315 100644 --- a/usr.sbin/mtree/mtree.c +++ b/usr.sbin/mtree/mtree.c @@ -55,8 +55,6 @@ static const char rcsid[] = #include "mtree.h" #include "extern.h" -extern long int crc_total; - int ftsoptions = FTS_PHYSICAL; int cflag, dflag, eflag, iflag, nflag, qflag, rflag, sflag, uflag, Uflag; u_int keys; @@ -126,7 +124,7 @@ main(int argc, char *argv[]) break; case 's': sflag = 1; - crc_total = ~strtol(optarg, &p, 0); + crc_total = ~strtoul(optarg, &p, 0); if (*p) errx(1, "illegal seed value -- %s", optarg); case 'U': diff --git a/usr.sbin/mtree/verify.c b/usr.sbin/mtree/verify.c index d56ee8f..49e2142 100644 --- a/usr.sbin/mtree/verify.c +++ b/usr.sbin/mtree/verify.c @@ -51,7 +51,6 @@ static const char rcsid[] = #include "mtree.h" #include "extern.h" -extern long int crc_total; extern int ftsoptions; extern int dflag, eflag, qflag, rflag, sflag, uflag; extern char fullpath[MAXPATHLEN]; @@ -155,7 +154,7 @@ extra: } (void)fts_close(t); if (sflag) - warnx("%s checksum: %lu", fullpath, crc_total); + warnx("%s checksum: %lu", fullpath, (unsigned long)crc_total); return (rval); } -- cgit v1.1