Update to keep file lengths in appropriate data types (off_t, as opposed

to u_int32_t).
This commit is contained in:
kleink 2003-12-20 23:41:38 +00:00
parent 1895548280
commit 4bd5e026a4
6 changed files with 47 additions and 36 deletions

View File

@ -1,4 +1,4 @@
/* $NetBSD: cksum.c,v 1.18 2003/08/07 11:13:20 agc Exp $ */
/* $NetBSD: cksum.c,v 1.19 2003/12/20 23:41:38 kleink Exp $ */
/*-
* Copyright (c) 1991, 1993
@ -77,7 +77,7 @@ __COPYRIGHT("@(#) Copyright (c) 1991, 1993\n\
#if 0
static char sccsid[] = "@(#)cksum.c 8.2 (Berkeley) 4/28/95";
#endif
__RCSID("$NetBSD: cksum.c,v 1.18 2003/08/07 11:13:20 agc Exp $");
__RCSID("$NetBSD: cksum.c,v 1.19 2003/12/20 23:41:38 kleink Exp $");
#endif /* not lint */
#include <sys/cdefs.h>
@ -145,11 +145,12 @@ main(argc, argv)
char **argv;
{
register int ch, fd, rval, dosum, pflag, nohashstdin;
u_int32_t len, val;
u_int32_t val;
off_t len;
char *fn;
const char *progname;
int (*cfncn) __P((int, u_int32_t *, u_int32_t *));
void (*pfncn) __P((char *, u_int32_t, u_int32_t));
int (*cfncn) __P((int, u_int32_t *, off_t *));
void (*pfncn) __P((char *, u_int32_t, off_t));
struct hash *hash;
int normal;

View File

@ -1,4 +1,4 @@
/* $NetBSD: crc.c,v 1.13 2003/08/07 11:13:20 agc Exp $ */
/* $NetBSD: crc.c,v 1.14 2003/12/20 23:41:38 kleink Exp $ */
/*-
* Copyright (c) 1991, 1993
@ -37,7 +37,7 @@
#if 0
static char sccsid[] = "@(#)crc.c 8.1 (Berkeley) 6/17/93";
#else
__RCSID("$NetBSD: crc.c,v 1.13 2003/08/07 11:13:20 agc Exp $");
__RCSID("$NetBSD: crc.c,v 1.14 2003/12/20 23:41:38 kleink Exp $");
#endif
#endif /* not lint */
@ -110,16 +110,19 @@ static const u_int32_t crctab[] = {
int
crc(fd, cval, clen)
register int fd;
u_int32_t *cval, *clen;
u_int32_t *cval;
off_t *clen;
{
register u_char *p;
register int nr;
register u_int32_t thecrc, len;
register u_int32_t thecrc;
off_t len;
u_char buf[16 * 1024];
#define COMPUTE(var, ch) (var) = (var) << 8 ^ crctab[(var) >> 24 ^ (ch)]
thecrc = len = 0;
thecrc = 0;
len = 0;
while ((nr = read(fd, buf, sizeof(buf))) > 0)
for (len += nr, p = buf; nr--; ++p) {
COMPUTE(thecrc, *p);

View File

@ -1,4 +1,4 @@
/* $NetBSD: extern.h,v 1.12 2003/10/27 00:12:43 lukem Exp $ */
/* $NetBSD: extern.h,v 1.13 2003/12/20 23:41:38 kleink Exp $ */
/*-
* Copyright (c) 1991, 1993
@ -38,12 +38,12 @@
#include <sys/cdefs.h>
__BEGIN_DECLS
int crc __P((int, u_int32_t *, u_int32_t *));
void pcrc __P((char *, u_int32_t, u_int32_t));
void psum1 __P((char *, u_int32_t, u_int32_t));
void psum2 __P((char *, u_int32_t, u_int32_t));
int csum1 __P((int, u_int32_t *, u_int32_t *));
int csum2 __P((int, u_int32_t *, u_int32_t *));
int crc __P((int, u_int32_t *, off_t *));
void pcrc __P((char *, u_int32_t, off_t));
void psum1 __P((char *, u_int32_t, off_t));
void psum2 __P((char *, u_int32_t, off_t));
int csum1 __P((int, u_int32_t *, off_t *));
int csum2 __P((int, u_int32_t *, off_t *));
int md5 __P((int, u_int32_t *, u_int32_t *));
void MD2String __P((const char *));

View File

@ -1,4 +1,4 @@
/* $NetBSD: print.c,v 1.8 2003/08/07 11:13:20 agc Exp $ */
/* $NetBSD: print.c,v 1.9 2003/12/20 23:41:38 kleink Exp $ */
/*-
* Copyright (c) 1991, 1993
@ -34,7 +34,7 @@
#if 0
static char sccsid[] = "@(#)print.c 8.1 (Berkeley) 6/6/93";
#else
__RCSID("$NetBSD: print.c,v 1.8 2003/08/07 11:13:20 agc Exp $");
__RCSID("$NetBSD: print.c,v 1.9 2003/12/20 23:41:38 kleink Exp $");
#endif
#endif /* not lint */
@ -45,9 +45,10 @@ __RCSID("$NetBSD: print.c,v 1.8 2003/08/07 11:13:20 agc Exp $");
void
pcrc(fn, val, len)
char *fn;
u_int32_t val, len;
u_int32_t val;
off_t len;
{
(void)printf("%lu %lu", (unsigned long)val, (unsigned long)len);
(void)printf("%lu %lld", (unsigned long)val, (long long)len);
if (fn)
(void)printf(" %s", fn);
(void)printf("\n");
@ -56,10 +57,11 @@ pcrc(fn, val, len)
void
psum1(fn, val, len)
char *fn;
u_int32_t val, len;
u_int32_t val;
off_t len;
{
(void)printf("%lu %lu", (unsigned long)val,
(unsigned long)(len + 1023) / 1024);
(void)printf("%lu %lld", (unsigned long)val,
(long long)(len + 1023) / 1024);
if (fn)
(void)printf(" %s", fn);
(void)printf("\n");
@ -68,10 +70,11 @@ psum1(fn, val, len)
void
psum2(fn, val, len)
char *fn;
u_int32_t val, len;
u_int32_t val;
off_t len;
{
(void)printf("%lu %lu", (unsigned long)val,
(unsigned long)(len + 511) / 512);
(void)printf("%lu %lld", (unsigned long)val,
(long long)(len + 511) / 512);
if (fn)
(void)printf(" %s", fn);
(void)printf("\n");

View File

@ -1,4 +1,4 @@
/* $NetBSD: sum1.c,v 1.9 2003/08/07 11:13:21 agc Exp $ */
/* $NetBSD: sum1.c,v 1.10 2003/12/20 23:41:38 kleink Exp $ */
/*-
* Copyright (c) 1991, 1993
@ -34,7 +34,7 @@
#if 0
static char sccsid[] = "@(#)sum1.c 8.1 (Berkeley) 6/6/93";
#else
__RCSID("$NetBSD: sum1.c,v 1.9 2003/08/07 11:13:21 agc Exp $");
__RCSID("$NetBSD: sum1.c,v 1.10 2003/12/20 23:41:38 kleink Exp $");
#endif
#endif /* not lint */
@ -46,9 +46,10 @@ __RCSID("$NetBSD: sum1.c,v 1.9 2003/08/07 11:13:21 agc Exp $");
int
csum1(fd, cval, clen)
register int fd;
u_int32_t *cval, *clen;
u_int32_t *cval;
off_t *clen;
{
register u_int32_t total;
register off_t total;
register int nr;
register u_int thecrc;
register u_char *p;

View File

@ -1,4 +1,4 @@
/* $NetBSD: sum2.c,v 1.9 2003/08/07 11:13:21 agc Exp $ */
/* $NetBSD: sum2.c,v 1.10 2003/12/20 23:41:38 kleink Exp $ */
/*-
* Copyright (c) 1991, 1993
@ -34,7 +34,7 @@
#if 0
static char sccsid[] = "@(#)sum2.c 8.1 (Berkeley) 6/6/93";
#else
__RCSID("$NetBSD: sum2.c,v 1.9 2003/08/07 11:13:21 agc Exp $");
__RCSID("$NetBSD: sum2.c,v 1.10 2003/12/20 23:41:38 kleink Exp $");
#endif
#endif /* not lint */
@ -46,9 +46,11 @@ __RCSID("$NetBSD: sum2.c,v 1.9 2003/08/07 11:13:21 agc Exp $");
int
csum2(fd, cval, clen)
register int fd;
u_int32_t *cval, *clen;
u_int32_t *cval;
off_t *clen;
{
register u_int32_t thecrc, total;
register u_int32_t thecrc;
register off_t total;
register int nr;
register u_char *p;
u_char buf[8192];
@ -60,7 +62,8 @@ csum2(fd, cval, clen)
* r = s % 2^16 + (s % 2^32) / 2^16
* thecrc = (r % 2^16) + r / 2^16
*/
thecrc = total = 0;
thecrc = 0;
total = 0;
while ((nr = read(fd, buf, sizeof(buf))) > 0)
for (total += nr, p = buf; nr--; ++p)
thecrc += *p;