diff options
author | robert <robert@FreeBSD.org> | 2003-03-13 23:32:28 +0000 |
---|---|---|
committer | robert <robert@FreeBSD.org> | 2003-03-13 23:32:28 +0000 |
commit | 0ddc4b17e7abc81a103d45cac7cff2cf55b25d66 (patch) | |
tree | 7ef3584e3d42073e216cde88c80a8ac51e19b5ff /usr.bin/cksum/crc.c | |
parent | 2939d783ece3a33d37be2601d6d3937a31059179 (diff) | |
download | FreeBSD-src-0ddc4b17e7abc81a103d45cac7cff2cf55b25d66.zip FreeBSD-src-0ddc4b17e7abc81a103d45cac7cff2cf55b25d66.tar.gz |
- For variables holding offset values, use off_t rather than
int, long int or u_int32_t. This changes the interface of
all the CRC calculation and output functions from cksum.
- Print variables of type off_t as intmax_t using a cast and %jd.
- Use the standardized uint32_t type instead of u_int32_t.
To have uint32_t defined, include <stdint.h> where necessary.
Style(9):
- Move #include directives where they belong (esp. crc32.c).
- Add empty lines between #include directives of system headers,
standard library headers and local headers.
- Test a pointer value against NULL.
- Put a space after the return keyword.
PR: bin/48424
Diffstat (limited to 'usr.bin/cksum/crc.c')
-rw-r--r-- | usr.bin/cksum/crc.c | 13 |
1 files changed, 8 insertions, 5 deletions
diff --git a/usr.bin/cksum/crc.c b/usr.bin/cksum/crc.c index da0bc72..d1f42f2 100644 --- a/usr.bin/cksum/crc.c +++ b/usr.bin/cksum/crc.c @@ -43,11 +43,13 @@ static char sccsid[] = "@(#)crc.c 8.1 (Berkeley) 6/17/93"; __FBSDID("$FreeBSD$"); #include <sys/types.h> + +#include <stdint.h> #include <unistd.h> #include "extern.h" -static const u_int32_t crctab[] = { +static const uint32_t crctab[] = { 0x0, 0x04c11db7, 0x09823b6e, 0x0d4326d9, 0x130476dc, 0x17c56b6b, 0x1a864db2, 0x1e475005, 0x2608edb8, 0x22c9f00f, 0x2f8ad6d6, @@ -108,14 +110,15 @@ static const u_int32_t crctab[] = { * locations to store the crc and the number of bytes read. It returns 0 on * success and 1 on failure. Errno is set on failure. */ -u_int32_t crc_total = ~0; /* The crc over a number of files. */ +uint32_t crc_total = ~0; /* The crc over a number of files. */ int -crc(int fd, u_int32_t *cval, u_int32_t *clen) +crc(int fd, uint32_t *cval, off_t *clen) { - u_char *p; + uint32_t lcrc; int nr; - u_int32_t lcrc, len; + off_t len; + u_char *p; u_char buf[16 * 1024]; #define COMPUTE(var, ch) (var) = (var) << 8 ^ crctab[(var) >> 24 ^ (ch)] |