talons

Fork of Claws Mail https://www.claws-mail
Log | Files | Refs | README | LICENSE

commit aae5f092920ad17752f3a9bd3e7ca514318d5139
parent b1255f92efda7d84a483f825bd0ff04cf1b09b7f
Author: Jonathan Boeing <jonathan@claws-mail.org>
Date:   Sun, 27 Nov 2022 14:36:49 -0700

Replace u32 with guint32

Diffstat:
Mconfigure.ac | 1-
Dm4/gnupg-check-typedef.m4 | 21---------------------
Msrc/common/md5.c | 29++++++++++++++++++-----------
Msrc/common/md5.h | 14--------------
4 files changed, 18 insertions(+), 47 deletions(-)

diff --git a/configure.ac b/configure.ac @@ -443,7 +443,6 @@ AC_TYPE_PID_T AC_TYPE_SIZE_T AC_STRUCT_TM -GNUPG_CHECK_TYPEDEF(u32, HAVE_U32_TYPEDEF, Used to test for a u32 typedef) AC_CHECK_SIZEOF(unsigned short, 2) AC_CHECK_SIZEOF(unsigned int, 4) AC_CHECK_SIZEOF(unsigned long, 4) diff --git a/m4/gnupg-check-typedef.m4 b/m4/gnupg-check-typedef.m4 @@ -1,21 +0,0 @@ -dnl GNUPG_CHECK_TYPEDEF(TYPE, HAVE_NAME [, COMMENT]) -dnl Check whether a typedef exists and create a #define $2 if it exists -dnl Copyright (C) 2003 Free Software Foundation, Inc. -dnl This file is free software; the Free Software Foundation -dnl gives unlimited permission to copy and/or distribute it, -dnl with or without modifications, as long as this notice is preserved. -dnl -AC_DEFUN([GNUPG_CHECK_TYPEDEF], - [ AC_MSG_CHECKING(for $1 typedef) - AC_CACHE_VAL(gnupg_cv_typedef_$1, - [AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <stdlib.h> - #include <sys/types.h>]], [[ - #undef $1 - int a = sizeof($1); - ]])],[gnupg_cv_typedef_$1=yes],[gnupg_cv_typedef_$1=no ])]) - AC_MSG_RESULT($gnupg_cv_typedef_$1) - if test "$gnupg_cv_typedef_$1" = yes; then - AC_DEFINE($2, 1, $3) - fi - ]) - diff --git a/src/common/md5.c b/src/common/md5.c @@ -48,8 +48,8 @@ * Rotate a 32 bit integer by n bytes */ #if defined(__GNUC__) && defined(__i386__) -static inline u32 -rol( u32 x, int n) +static inline guint32 +rol( guint32 x, int n) { __asm__("roll %%cl,%0" :"=r" (x) @@ -60,6 +60,13 @@ rol( u32 x, int n) #define rol(x,n) ( ((x) << (n)) | ((x) >> (32-(n))) ) #endif +typedef struct { + guint32 A,B,C,D; + guint32 nblocks; + unsigned char buf[64]; + int count; + int finalized; +} MD5_CONTEXT; static void md5_init(MD5_CONTEXT *ctx) @@ -90,12 +97,12 @@ md5_init(MD5_CONTEXT *ctx) static void transform(MD5_CONTEXT *ctx, const unsigned char *data) { - u32 correct_words[16]; - u32 A = ctx->A; - u32 B = ctx->B; - u32 C = ctx->C; - u32 D = ctx->D; - u32 *cwp = correct_words; + guint32 correct_words[16]; + guint32 A = ctx->A; + guint32 B = ctx->B; + guint32 C = ctx->C; + guint32 D = ctx->D; + guint32 *cwp = correct_words; #ifdef BIG_ENDIAN_HOST { @@ -263,7 +270,7 @@ md5_update(MD5_CONTEXT *hd, const unsigned char *inbuf, size_t inlen) static void do_final(MD5_CONTEXT *hd) { - u32 t, msb, lsb; + guint32 t, msb, lsb; unsigned char *p; md5_update(hd, NULL, 0); /* flush */ @@ -309,10 +316,10 @@ do_final(MD5_CONTEXT *hd) #define X(a) do { *p++ = hd->a ; *p++ = hd->a >> 8; \ *p++ = hd->a >> 16; *p++ = hd->a >> 24; } while(0) #else /* little endian */ - /*#define X(a) do { *(u32*)p = hd->##a ; p += 4; } while(0)*/ + /*#define X(a) do { *(guint32*)p = hd->##a ; p += 4; } while(0)*/ /* Unixware's cpp doesn't like the above construct so we do it his way: * (reported by Allan Clark) */ -#define X(a) do { *(u32*)p = (*hd).a ; p += 4; } while(0) +#define X(a) do { *(guint32*)p = (*hd).a ; p += 4; } while(0) #endif X(A); X(B); diff --git a/src/common/md5.h b/src/common/md5.h @@ -23,20 +23,6 @@ #include "utils.h" -#ifndef HAVE_U32_TYPEDEF - #undef u32 /* maybe there is a macro with this name */ - typedef guint32 u32; - #define HAVE_U32_TYPEDEF -#endif - -typedef struct { /* Hmm, should be private */ - u32 A,B,C,D; - u32 nblocks; - unsigned char buf[64]; - int count; - int finalized; -} MD5_CONTEXT; - void md5_hex_digest(char *hexdigest, const unsigned char *s); int md5_hex_digest_file(char *hexdigest, const unsigned char *file); void md5_hex_hmac(char *hexdigest,