Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/usr.bin/cksum Avoid defining max. hash length ugliness simpl...



details:   https://anonhg.NetBSD.org/src/rev/8f727eae3911
branches:  trunk
changeset: 583978:8f727eae3911
user:      elad <elad%NetBSD.org@localhost>
date:      Fri Sep 02 17:39:23 2005 +0000

description:
Avoid defining max. hash length ugliness simply by passing NULL for the
buffer to the File routines.

Noted by pooka@.

diffstat:

 usr.bin/cksum/cksum.c  |  11 +++++++----
 usr.bin/cksum/extern.h |   5 +----
 2 files changed, 8 insertions(+), 8 deletions(-)

diffs (59 lines):

diff -r f25f47d9bf8c -r 8f727eae3911 usr.bin/cksum/cksum.c
--- a/usr.bin/cksum/cksum.c     Fri Sep 02 17:12:38 2005 +0000
+++ b/usr.bin/cksum/cksum.c     Fri Sep 02 17:39:23 2005 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: cksum.c,v 1.29 2005/09/02 16:52:34 elad Exp $  */
+/*     $NetBSD: cksum.c,v 1.30 2005/09/02 17:39:23 elad Exp $  */
 
 /*-
  * Copyright (c) 1991, 1993
@@ -81,7 +81,7 @@
 #if 0
 static char sccsid[] = "@(#)cksum.c    8.2 (Berkeley) 4/28/95";
 #endif
-__RCSID("$NetBSD: cksum.c,v 1.29 2005/09/02 16:52:34 elad Exp $");
+__RCSID("$NetBSD: cksum.c,v 1.30 2005/09/02 17:39:23 elad Exp $");
 #endif /* not lint */
 
 #include <sys/cdefs.h>
@@ -350,9 +350,9 @@
 int
 hash_digest_file(char *fn, struct hash *hash, int normal)
 {
-       char buf[MAXHASHLEN + 1], *cp;
+       char *cp;
 
-       cp = hash->filefunc(fn, buf);
+       cp = hash->filefunc(fn, NULL);
        if (cp == NULL)
                return 1;
 
@@ -360,6 +360,9 @@
                printf("%s %s\n", cp, fn);
        else
                printf("%s (%s) = %s\n", hash->hashname, fn, cp);
+
+       free(cp);
+
        return 0;
 }
 
diff -r f25f47d9bf8c -r 8f727eae3911 usr.bin/cksum/extern.h
--- a/usr.bin/cksum/extern.h    Fri Sep 02 17:12:38 2005 +0000
+++ b/usr.bin/cksum/extern.h    Fri Sep 02 17:39:23 2005 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: extern.h,v 1.17 2005/09/02 16:52:03 elad Exp $ */
+/*     $NetBSD: extern.h,v 1.18 2005/09/02 17:39:23 elad Exp $ */
 
 /*-
  * Copyright (c) 1991, 1993
@@ -37,9 +37,6 @@
 
 #include <sys/cdefs.h>
 
-/* Max. length of hash -- update when adding new algorithms. */
-#define        MAXHASHLEN      128 /* SHA512 */
-
 __BEGIN_DECLS
 int    crc(int, u_int32_t *, off_t *);
 void   pcrc(char *, u_int32_t, off_t);



Home | Main Index | Thread Index | Old Index