summaryrefslogtreecommitdiff
path: root/usr.bin/cksum/sum1.c
diff options
context:
space:
mode:
authorMark Murray <markm@FreeBSD.org>2001-12-02 12:54:40 +0000
committerMark Murray <markm@FreeBSD.org>2001-12-02 12:54:40 +0000
commit3fa15ce5d8c2bff56d3e11f1a47e264ae30514d3 (patch)
tree04f28aca583e7284fff26b2676ada73eb15ca363 /usr.bin/cksum/sum1.c
parent59aff5fcf3f4302800908f8014877379bc32e250 (diff)
downloadsrc-test2-3fa15ce5d8c2bff56d3e11f1a47e264ae30514d3.tar.gz
src-test2-3fa15ce5d8c2bff56d3e11f1a47e264ae30514d3.zip
Notes
Diffstat (limited to 'usr.bin/cksum/sum1.c')
-rw-r--r--usr.bin/cksum/sum1.c22
1 files changed, 12 insertions, 10 deletions
diff --git a/usr.bin/cksum/sum1.c b/usr.bin/cksum/sum1.c
index bcdeb30df5a7..aaba1e8cbccd 100644
--- a/usr.bin/cksum/sum1.c
+++ b/usr.bin/cksum/sum1.c
@@ -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);
}