This is an automated email from the git hooks/post-receive script.

guillem pushed a commit to branch master
in repository dpkg.

commit 0d9c18d163ca37ef4c0c2127f8ec901f721d1473
Author: Guillem Jover <[email protected]>
Date:   Sat Mar 24 19:37:51 2018 +0100

    libcompat: Convert md5 module to use C99 int types
    
    In commit 1f4d0354fc4a8c80c6463b9aaebd93822247341b we opted to map the
    BSD int types to the C99 to avoid modifying the imported code. But we
    had to modify it anyway, those types are legacy and we require the C99
    ones for the rest of the codebase. So let's just switch to them, and
    get rid of the type compatibility mapping.
---
 configure.ac     |  1 -
 debian/changelog |  2 ++
 lib/compat/md5.c | 20 ++++++++++----------
 lib/compat/md5.h | 14 ++++++++------
 m4/dpkg-types.m4 | 20 --------------------
 5 files changed, 20 insertions(+), 37 deletions(-)

diff --git a/configure.ac b/configure.ac
index f6dff9f..2e09c63 100644
--- a/configure.ac
+++ b/configure.ac
@@ -124,7 +124,6 @@ AC_C_VOLATILE
 AC_TYPE_MODE_T
 AC_TYPE_PID_T
 AC_TYPE_SIZE_T
-DPKG_TYPES_U_INT_T
 DPKG_TYPE_PTRDIFF_T
 AC_CHECK_SIZEOF([unsigned int])
 AC_CHECK_SIZEOF([unsigned long])
diff --git a/debian/changelog b/debian/changelog
index d23a352..15e1355 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -44,6 +44,8 @@ dpkg (1.19.1) UNRELEASED; urgency=medium
   * Portability:
     - Add libcompat md5 module to the libcompat-test library, so that we
       always make sure it builds, even when we use an external implementation.
+    - Convert libcompat md5 module to use C99 int types, instead of mapping
+      them from the BSD types at configure time.
   * Perl modules:
     - Check that $tarname is defined before use in Dpkg::Source::Package::V1.
       Thanks to Christoph Biedl <[email protected]>.
diff --git a/lib/compat/md5.c b/lib/compat/md5.c
index 3da18c9..7da9746 100644
--- a/lib/compat/md5.c
+++ b/lib/compat/md5.c
@@ -41,7 +41,7 @@
        (cp)[1] = (value) >> 8;                                         \
        (cp)[0] = (value); } while (0)
 
-static u_int8_t PADDING[MD5_BLOCK_LENGTH] = {
+static uint8_t PADDING[MD5_BLOCK_LENGTH] = {
        0x80, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
        0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
        0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
@@ -75,7 +75,7 @@ MD5Update(MD5_CTX *ctx, const unsigned char *input, size_t 
len)
        need = MD5_BLOCK_LENGTH - have;
 
        /* Update bitcount */
-       ctx->count += (u_int64_t)len << 3;
+       ctx->count += (uint64_t)len << 3;
 
        if (len >= need) {
                if (have != 0) {
@@ -106,7 +106,7 @@ MD5Update(MD5_CTX *ctx, const unsigned char *input, size_t 
len)
 void
 MD5Pad(MD5_CTX *ctx)
 {
-       u_int8_t count[8];
+       uint8_t count[8];
        size_t padlen;
 
        /* Convert count to 8 bytes in little endian order. */
@@ -156,19 +156,19 @@ MD5Final(unsigned char digest[MD5_DIGEST_LENGTH], MD5_CTX 
*ctx)
  * the data and converts bytes into longwords for this routine.
  */
 void
-MD5Transform(u_int32_t state[4], const u_int8_t block[MD5_BLOCK_LENGTH])
+MD5Transform(uint32_t state[4], const uint8_t block[MD5_BLOCK_LENGTH])
 {
-       u_int32_t a, b, c, d, in[MD5_BLOCK_LENGTH / 4];
+       uint32_t a, b, c, d, in[MD5_BLOCK_LENGTH / 4];
 
 #ifndef WORDS_BIGENDIAN
        memcpy(in, block, sizeof(in));
 #else
        for (a = 0; a < MD5_BLOCK_LENGTH / 4; a++) {
-               in[a] = (u_int32_t)(
-                   (u_int32_t)(block[a * 4 + 0]) |
-                   (u_int32_t)(block[a * 4 + 1]) <<  8 |
-                   (u_int32_t)(block[a * 4 + 2]) << 16 |
-                   (u_int32_t)(block[a * 4 + 3]) << 24);
+               in[a] = (uint32_t)(
+                   (uint32_t)(block[a * 4 + 0]) |
+                   (uint32_t)(block[a * 4 + 1]) <<  8 |
+                   (uint32_t)(block[a * 4 + 2]) << 16 |
+                   (uint32_t)(block[a * 4 + 3]) << 24);
        }
 #endif
 
diff --git a/lib/compat/md5.h b/lib/compat/md5.h
index f624360..b5247d5 100644
--- a/lib/compat/md5.h
+++ b/lib/compat/md5.h
@@ -15,20 +15,22 @@
 #ifndef _MD5_H_
 #define _MD5_H_
 
+#include <stdint.h>
+
 #define        MD5_BLOCK_LENGTH                64
 #define        MD5_DIGEST_LENGTH               16
 #define        MD5_DIGEST_STRING_LENGTH        (MD5_DIGEST_LENGTH * 2 + 1)
 
 typedef struct MD5Context {
-       u_int32_t state[4];                     /* state */
-       u_int64_t count;                        /* number of bits, mod 2^64 */
-       u_int8_t buffer[MD5_BLOCK_LENGTH];      /* input buffer */
+       uint32_t state[4];                      /* state */
+       uint64_t count;                 /* number of bits, mod 2^64 */
+       uint8_t buffer[MD5_BLOCK_LENGTH];       /* input buffer */
 } MD5_CTX;
 
 void    MD5Init(MD5_CTX *);
-void    MD5Update(MD5_CTX *, const u_int8_t *, size_t);
+void    MD5Update(MD5_CTX *, const uint8_t *, size_t);
 void    MD5Pad(MD5_CTX *);
-void    MD5Final(u_int8_t [MD5_DIGEST_LENGTH], MD5_CTX *);
-void    MD5Transform(u_int32_t [4], const u_int8_t [MD5_BLOCK_LENGTH]);
+void    MD5Final(uint8_t [MD5_DIGEST_LENGTH], MD5_CTX *);
+void    MD5Transform(uint32_t [4], const uint8_t [MD5_BLOCK_LENGTH]);
 
 #endif /* _MD5_H_ */
diff --git a/m4/dpkg-types.m4 b/m4/dpkg-types.m4
index 7fbbd2a..5355f5a 100644
--- a/m4/dpkg-types.m4
+++ b/m4/dpkg-types.m4
@@ -11,26 +11,6 @@ AC_DEFUN([DPKG_TYPE_PTRDIFF_T], [
   ])
 ])# DPKG_TYPE_PTRDIFF_T
 
-# DPKG_TYPE_U_INT_T(N)
-# --------------------
-# Check for u_intN_t BSD type, defining to C99 type if not.
-AC_DEFUN([DPKG_TYPE_U_INT_T], [
-  AC_CHECK_TYPE([u_int$1_t], [], [
-    AC_DEFINE_UNQUOTED([u_int$1_t], [uint$1_t],
-      [Define to 'uint$1_t' if not defined.])
-  ])
-])
-
-# DPKG_TYPES_U_INT_T
-# ------------------
-# Check for u_int(8|16|32|64)_t BSD types, defining to C99 types if not.
-AC_DEFUN([DPKG_TYPES_U_INT_T], [
-  DPKG_TYPE_U_INT_T([8])
-  DPKG_TYPE_U_INT_T([16])
-  DPKG_TYPE_U_INT_T([32])
-  DPKG_TYPE_U_INT_T([64])
-])
-
 # DPKG_DECL_SYS_SIGLIST
 # ---------------------
 # Check for the sys_siglist variable in either signal.h or unistd.h

-- 
Alioth's /usr/local/bin/git-commit-notice on 
/srv/git.debian.org/git/dpkg/dpkg.git

Reply via email to