WARNS=2 fixup.

kill 'register' keyword.
This commit is contained in:
Mark Murray 2001-12-02 12:54:40 +00:00
parent 59aff5fcf3
commit 3fa15ce5d8
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=87212
7 changed files with 44 additions and 34 deletions

View File

@ -1,8 +1,9 @@
# @(#)Makefile 8.2 (Berkeley) 4/28/95
# $FreeBSD$
PROG= cksum
CFLAGS+=-Wall
SRCS= cksum.c crc.c print.c sum1.c sum2.c crc32.c
WARNS?= 2
LINKS= ${BINDIR}/cksum ${BINDIR}/sum
MLINKS= cksum.1 sum.1

View File

@ -66,7 +66,7 @@ main(argc, argv)
int argc;
char **argv;
{
register int ch, fd, rval;
int ch, fd, rval;
u_int32_t len, val;
char *fn, *p;
int (*cfncn) __P((int, u_int32_t *, u_int32_t *));

View File

@ -45,6 +45,8 @@ static const char rcsid[] =
#include <sys/types.h>
#include <unistd.h>
#include "extern.h"
static const u_int32_t crctab[] = {
0x0,
0x04c11db7, 0x09823b6e, 0x0d4326d9, 0x130476dc, 0x17c56b6b,
@ -110,21 +112,21 @@ u_int32_t crc_total = ~0; /* The crc over a number of files. */
int
crc(fd, cval, clen)
register int fd;
int fd;
u_int32_t *cval, *clen;
{
register u_char *p;
register int nr;
register u_int32_t crc, len;
u_char *p;
int nr;
u_int32_t lcrc, len;
u_char buf[16 * 1024];
#define COMPUTE(var, ch) (var) = (var) << 8 ^ crctab[(var) >> 24 ^ (ch)]
crc = len = 0;
lcrc = len = 0;
crc_total = ~crc_total;
while ((nr = read(fd, buf, sizeof(buf))) > 0)
for (len += nr, p = buf; nr--; ++p) {
COMPUTE(crc, *p);
COMPUTE(lcrc, *p);
COMPUTE(crc_total, *p);
}
if (nr < 0)
@ -134,11 +136,11 @@ crc(fd, cval, clen)
/* Include the length of the file. */
for (; len != 0; len >>= 8) {
COMPUTE(crc, len & 0xff);
COMPUTE(lcrc, len & 0xff);
COMPUTE(crc_total, len & 0xff);
}
*cval = ~crc;
*cval = ~lcrc;
crc_total = ~crc_total;
return (0);
}

View File

@ -18,6 +18,8 @@ static const char rcsid[] =
#include <sys/types.h>
#include "extern.h"
#define CRC(crc, ch) (crc = (crc >> 8) ^ crctab[(crc ^ (ch)) & 0xff])
/* generated using the AUTODIN II polynomial
@ -99,10 +101,10 @@ u_int32_t crc32_total = 0 ;
int
crc32(fd, cval, clen)
register int fd;
int fd;
u_int32_t *cval, *clen;
{
u_int32_t crc = ~0;
u_int32_t lcrc = ~0;
char buf[BUFSIZ], *p ;
int len, nr ;
@ -110,14 +112,14 @@ crc32(fd, cval, clen)
crc32_total = ~crc32_total ;
while ((nr = read(fd, buf, sizeof(buf))) > 0)
for (len += nr, p = buf; nr--; ++p) {
CRC(crc, *p) ;
CRC(lcrc, *p) ;
CRC(crc32_total, *p) ;
}
if (nr < 0)
return 1 ;
*clen = len ;
*cval = ~crc ;
*cval = ~lcrc ;
crc32_total = ~crc32_total ;
return 0 ;
}

View File

@ -31,6 +31,7 @@
* SUCH DAMAGE.
*
* @(#)extern.h 8.1 (Berkeley) 6/6/93
* $FreeBSD$
*/
#include <sys/cdefs.h>

View File

@ -42,32 +42,34 @@ static const char rcsid[] =
#include <sys/types.h>
#include <unistd.h>
#include "extern.h"
int
csum1(fd, cval, clen)
register int fd;
int fd;
u_int32_t *cval, *clen;
{
register u_int32_t total;
register int nr;
register u_int crc;
register u_char *p;
u_int32_t total;
int nr;
u_int lcrc;
u_char *p;
u_char buf[8192];
/*
* 16-bit checksum, rotating right before each addition;
* overflow is discarded.
*/
crc = total = 0;
lcrc = total = 0;
while ((nr = read(fd, buf, sizeof(buf))) > 0)
for (total += nr, p = buf; nr--; ++p) {
if (crc & 1)
crc |= 0x10000;
crc = ((crc >> 1) + *p) & 0xffff;
if (lcrc & 1)
lcrc |= 0x10000;
lcrc = ((lcrc >> 1) + *p) & 0xffff;
}
if (nr < 0)
return(1);
*cval = crc;
*cval = lcrc;
*clen = total;
return(0);
}

View File

@ -42,14 +42,16 @@ static const char rcsid[] =
#include <sys/types.h>
#include <unistd.h>
#include "extern.h"
int
csum2(fd, cval, clen)
register int fd;
int fd;
u_int32_t *cval, *clen;
{
register u_int32_t crc, total;
register int nr;
register u_char *p;
u_int32_t lcrc, total;
int nr;
u_char *p;
u_char buf[8192];
/*
@ -57,19 +59,19 @@ csum2(fd, cval, clen)
*
* s = sum of all bytes
* r = s % 2^16 + (s % 2^32) / 2^16
* crc = (r % 2^16) + r / 2^16
* lcrc = (r % 2^16) + r / 2^16
*/
crc = total = 0;
lcrc = total = 0;
while ((nr = read(fd, buf, sizeof(buf))) > 0)
for (total += nr, p = buf; nr--; ++p)
crc += *p;
lcrc += *p;
if (nr < 0)
return(1);
crc = (crc & 0xffff) + (crc >> 16);
crc = (crc & 0xffff) + (crc >> 16);
lcrc = (lcrc & 0xffff) + (lcrc >> 16);
lcrc = (lcrc & 0xffff) + (lcrc >> 16);
*cval = crc;
*cval = lcrc;
*clen = total;
return(0);
}