Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/usr.bin/cksum Update to keep file lengths in appropriate dat...
details: https://anonhg.NetBSD.org/src/rev/95b3dc0fcb5f
branches: trunk
changeset: 556574:95b3dc0fcb5f
user: kleink <kleink%NetBSD.org@localhost>
date: Sat Dec 20 23:41:38 2003 +0000
description:
Update to keep file lengths in appropriate data types (off_t, as opposed
to u_int32_t).
diffstat:
usr.bin/cksum/cksum.c | 11 ++++++-----
usr.bin/cksum/crc.c | 13 ++++++++-----
usr.bin/cksum/extern.h | 14 +++++++-------
usr.bin/cksum/print.c | 23 +++++++++++++----------
usr.bin/cksum/sum1.c | 9 +++++----
usr.bin/cksum/sum2.c | 13 ++++++++-----
6 files changed, 47 insertions(+), 36 deletions(-)
diffs (237 lines):
diff -r b2eb78e4c68d -r 95b3dc0fcb5f usr.bin/cksum/cksum.c
--- a/usr.bin/cksum/cksum.c Sat Dec 20 22:12:21 2003 +0000
+++ b/usr.bin/cksum/cksum.c Sat Dec 20 23:41:38 2003 +0000
@@ -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 @@
#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 @@
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;
diff -r b2eb78e4c68d -r 95b3dc0fcb5f usr.bin/cksum/crc.c
--- a/usr.bin/cksum/crc.c Sat Dec 20 22:12:21 2003 +0000
+++ b/usr.bin/cksum/crc.c Sat Dec 20 23:41:38 2003 +0000
@@ -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 @@
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);
diff -r b2eb78e4c68d -r 95b3dc0fcb5f usr.bin/cksum/extern.h
--- a/usr.bin/cksum/extern.h Sat Dec 20 22:12:21 2003 +0000
+++ b/usr.bin/cksum/extern.h Sat Dec 20 23:41:38 2003 +0000
@@ -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 *));
diff -r b2eb78e4c68d -r 95b3dc0fcb5f usr.bin/cksum/print.c
--- a/usr.bin/cksum/print.c Sat Dec 20 22:12:21 2003 +0000
+++ b/usr.bin/cksum/print.c Sat Dec 20 23:41:38 2003 +0000
@@ -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 @@
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 @@
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 @@
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");
diff -r b2eb78e4c68d -r 95b3dc0fcb5f usr.bin/cksum/sum1.c
--- a/usr.bin/cksum/sum1.c Sat Dec 20 22:12:21 2003 +0000
+++ b/usr.bin/cksum/sum1.c Sat Dec 20 23:41:38 2003 +0000
@@ -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 @@
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;
diff -r b2eb78e4c68d -r 95b3dc0fcb5f usr.bin/cksum/sum2.c
--- a/usr.bin/cksum/sum2.c Sat Dec 20 22:12:21 2003 +0000
+++ b/usr.bin/cksum/sum2.c Sat Dec 20 23:41:38 2003 +0000
@@ -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 @@
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 @@
* 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;
Home |
Main Index |
Thread Index |
Old Index