From fadcf8aec07657229da55817828591d56390c966 Mon Sep 17 00:00:00 2001 From: Robert Drehmel Date: Thu, 13 Mar 2003 23:34:18 +0000 Subject: [PATCH] - Align the function prototype of the external `crc' function with how `crc' is actually defined. Data type corrections: - Define variables which contain file byte offset values 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'. - Parse the length of a file with sscanf as `intmax_t' (as there is no conversion specifier for `off_t'). Style(9): - Put an empty line between #include directives for system and user header files. --- usr.sbin/ckdist/ckdist.c | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/usr.sbin/ckdist/ckdist.c b/usr.sbin/ckdist/ckdist.c index 3761b7061371..92bcd0d81a43 100644 --- a/usr.sbin/ckdist/ckdist.c +++ b/usr.sbin/ckdist/ckdist.c @@ -32,17 +32,19 @@ static const char rcsid[] = #include #include + #include #include #include #include #include #include +#include #include #include #include -extern int crc(int fd, u_long * cval, u_long * clen); +extern int crc(int fd, uint32_t *cval, off_t *clen); #define DISTMD5 1 /* MD5 format */ #define DISTINF 2 /* .inf format */ @@ -267,7 +269,10 @@ chkinf(FILE * fp, const char *path) char ext[3]; struct stat sb; const char *dname; - u_long sum, len, chk; + off_t len; + u_long sum; + intmax_t sumlen; + uint32_t chk; int rval, error, c, pieces, cnt, fd; char ch; @@ -280,8 +285,8 @@ chkinf(FILE * fp, const char *path) if ((c = sscanf(buf, "Pieces = %d%c", &pieces, &ch)) != 2 || ch != '\n' || pieces < 1) error = E_BADINF; - } else if (((c = sscanf(buf, "cksum.%2s = %lu %lu%c", ext, &sum, - &len, &ch)) != 4 && + } else if (((c = sscanf(buf, "cksum.%2s = %lu %jd%c", ext, &sum, + &sumlen, &ch)) != 4 && (!feof(fp) || c != 3)) || (c == 4 && ch != '\n') || ext[0] != 'a' + cnt / 26 || ext[1] != 'a' + cnt % 26) error = E_BADINF; @@ -292,7 +297,7 @@ chkinf(FILE * fp, const char *path) error = E_ERRNO; else if (fstat(fd, &sb)) error = E_ERRNO; - else if (sb.st_size != (off_t)len) + else if (sb.st_size != (off_t)sumlen) error = E_LENGTH; else if (!opt_exist) { if (crc(fd, &chk, &len))