tech-pkg archive

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

improving pkgtools/digest



The following patch does the following:
   - remove unused configure tests for vprintf/_doprnt
   - remove pointless configure tests for memcpy/memset/bcopy/bzero
   - correct signed/unsigned issues in the sha2 and whirlpool code

I've removed the diffs caused by regenerating with autoconf as they're
large and uninteresting.

The resulting package builds if you use the wrappers to inject -Wall
-Werror, which was not previously the case.

I would like to commit this after the freeze (if I commit it now, it
will cause pbulk to start everyone's builds over from scratch, which
isn't a good idea) if nobody objects.

Judging by diff results it might also be a good idea to update some or
all of the hash function .c files from base, but I haven't done this
or looked into it in any detail.

The bcopy/bzero leftovers could also be tidied up further afterwards;
perhaps I'll do that after committing.


Index: files/configure.ac
===================================================================
RCS file: /cvsroot/pkgsrc/pkgtools/digest/files/configure.ac,v
retrieving revision 1.17
diff -u -p -r1.17 configure.ac
--- files/configure.ac  4 Nov 2011 23:58:14 -0000       1.17
+++ files/configure.ac  20 Dec 2012 20:37:44 -0000
@@ -1,7 +1,7 @@
 dnl $Id: configure.ac,v 1.17 2011/11/04 23:58:14 cheusov Exp $
 dnl Process this file with autoconf to produce a configure script.
 AC_PREREQ(2.57)
-AC_INIT([nbsd-digest],[20111104],[agc%netbsd.org@localhost])
+AC_INIT([nbsd-digest],[20121220],[agc%netbsd.org@localhost])
 AC_CONFIG_SRCDIR([digest.c])
 AC_CONFIG_HEADER(config.h)
 AC_ARG_PROGRAM
@@ -37,8 +37,7 @@ AC_C_BIGENDIAN
 
 # Checks for library functions.
 AC_FUNC_STRERROR_R
-AC_FUNC_VPRINTF
-AC_CHECK_FUNCS([bcopy bzero memset memcpy setlocale])
+AC_CHECK_FUNCS([setlocale])
 #
 AH_BOTTOM([
 #ifdef HAVE_SYS_CDEFS_H
@@ -93,25 +92,8 @@ AH_BOTTOM([
 #include <sys/param.h>
 #endif
 
-#if defined(HAVE_MEMSET)
 #define MEMSET_BZERO(p,l)      memset((p), 0, (l))
-#else
-# if defined(HAVE_BZERO)
-#define MEMSET_BZERO(p,l)      bzero((p), (l))
-# else
-#error You need either memset or bzero
-# endif
-#endif
-
-#if defined(HAVE_MEMCPY)
 #define MEMCPY_BCOPY(d,s,l)    memcpy((d), (s), (l))
-#else
-# if defined(HAVE_BCOPY)
-#define MEMCPY_BCOPY(d,s,l)    bcopy((s), (d), (l))
-# else
-#error You need either memcpy or bcopy
-# endif
-#endif
 ])
 
 AC_CONFIG_FILES([Makefile])
Index: files/md5c.c
===================================================================
RCS file: /cvsroot/pkgsrc/pkgtools/digest/files/md5c.c,v
retrieving revision 1.5
diff -u -p -r1.5 md5c.c
--- files/md5c.c        21 Sep 2007 18:44:36 -0000      1.5
+++ files/md5c.c        20 Dec 2012 20:37:44 -0000
@@ -45,15 +45,7 @@
 #include <md5.h>
 #endif /* _KERNEL || _STANDALONE */
 
-#if defined(HAVE_MEMSET)
 #define        ZEROIZE(d, l)           memset((d), 0, (l))
-#else
-# if defined(HAVE_BZERO)
-#define ZEROIZE(d, l)          bzero((d), (l))
-# else
-#error You need either memset or bzero
-# endif
-#endif
 
 typedef unsigned char *POINTER;
 typedef uint16_t UINT2;
Index: files/rmd160.c
===================================================================
RCS file: /cvsroot/pkgsrc/pkgtools/digest/files/rmd160.c,v
retrieving revision 1.7
diff -u -p -r1.7 rmd160.c
--- files/rmd160.c      21 Sep 2007 18:44:37 -0000      1.7
+++ files/rmd160.c      20 Dec 2012 20:37:44 -0000
@@ -40,15 +40,7 @@ __RCSID("$NetBSD: rmd160.c,v 1.7 2007/09
 #define _DIAGASSERT(cond)      assert(cond)
 #endif
 
-#if defined(HAVE_MEMSET)
 #define ZEROIZE(d, l)           memset((d), 0, (l)) 
-#else 
-# if defined(HAVE_BZERO)
-#define ZEROIZE(d, l)           bzero((d), (l))
-# else
-#error You need either memset or bzero 
-# endif 
-#endif
 
 #if 0
 #if !defined(_KERNEL) && defined(__weak_alias)
Index: files/sha2.h
===================================================================
RCS file: /cvsroot/pkgsrc/pkgtools/digest/files/sha2.h,v
retrieving revision 1.9
diff -u -p -r1.9 sha2.h
--- files/sha2.h        23 Jan 2010 13:25:12 -0000      1.9
+++ files/sha2.h        20 Dec 2012 20:37:44 -0000
@@ -86,8 +86,8 @@ typedef SHA512_CTX SHA384_CTX;
 void SHA256_Init(SHA256_CTX *);
 void SHA256_Update(SHA256_CTX*, const uint8_t*, size_t);
 void SHA256_Final(uint8_t[SHA256_DIGEST_LENGTH], SHA256_CTX*);
-char* SHA256_End(SHA256_CTX*, uint8_t[SHA256_DIGEST_STRING_LENGTH]);
-char* SHA256_Data(const uint8_t*, size_t, uint8_t *);
+char* SHA256_End(SHA256_CTX*, char[SHA256_DIGEST_STRING_LENGTH]);
+char* SHA256_Data(const uint8_t*, size_t, char[SHA256_DIGEST_STRING_LENGTH]);
 char *SHA256_File(char *, char *);
 
 void SHA384_Init(SHA384_CTX*);
Index: files/sha2hl.c
===================================================================
RCS file: /cvsroot/pkgsrc/pkgtools/digest/files/sha2hl.c,v
retrieving revision 1.7
diff -u -p -r1.7 sha2hl.c
--- files/sha2hl.c      21 Sep 2007 18:44:38 -0000      1.7
+++ files/sha2hl.c      20 Dec 2012 20:37:45 -0000
@@ -105,10 +105,10 @@ SHA256_File(char *filename, char *buf)
 
 
 char *
-SHA256_End(SHA256_CTX *ctx, uint8_t *buffer)
+SHA256_End(SHA256_CTX *ctx, char *buffer)
 {
        uint8_t         digest[SHA256_DIGEST_LENGTH], *d = digest;
-       uint8_t        *ret;
+       char           *ret;
        int             i;
 
        /* Sanity check: */
@@ -131,7 +131,7 @@ SHA256_End(SHA256_CTX *ctx, uint8_t *buf
 }
 
 char *
-SHA256_Data(const uint8_t * data, size_t len, uint8_t *digest)
+SHA256_Data(const uint8_t * data, size_t len, char *digest)
 {
        SHA256_CTX      ctx;
 
@@ -169,7 +169,7 @@ char *
 SHA384_End(SHA384_CTX * ctx, char buffer[])
 {
        uint8_t         digest[SHA384_DIGEST_LENGTH], *d = digest;
-       uint8_t        *ret;
+       char           *ret;
        int             i;
 
        /* Sanity check: */
@@ -230,7 +230,7 @@ char *
 SHA512_End(SHA512_CTX * ctx, char buffer[])
 {
        uint8_t         digest[SHA512_DIGEST_LENGTH], *d = digest;
-       uint8_t        *ret;
+       char           *ret;
        int             i;
 
        /* Sanity check: */
Index: files/whirlpool.c
===================================================================
RCS file: /cvsroot/pkgsrc/pkgtools/digest/files/whirlpool.c,v
retrieving revision 1.6
diff -u -p -r1.6 whirlpool.c
--- files/whirlpool.c   2 Aug 2007 13:54:34 -0000       1.6
+++ files/whirlpool.c   20 Dec 2012 20:37:50 -0000
@@ -1552,14 +1552,14 @@ whirlpool_update(whirlpool_context_t *st
  * This method uses the invariant: bufferBits < WHIRLPOOL_DIGEST_BITS
  */
 static void
-whirlpool_finalize(unsigned char *result, whirlpool_context_t *structpointer)
+whirlpool_finalize(char *result, whirlpool_context_t *structpointer)
 {
     int i;
     u8 *buffer      = structpointer->buffer;
     u8 *bitLength   = structpointer->bitLength;
     int bufferBits  = structpointer->bufferBits;
     int bufferPos   = structpointer->bufferPos;
-    u8 *digest      = result;
+    char *digest    = result;
 
     /*
      * append a '1'-bit:


-- 
David A. Holland
dholland%netbsd.org@localhost


Home | Main Index | Thread Index | Old Index