@@ -37,8 +37,8 @@ detectEndianess()
3737 int nl = 0x12345678 ;
3838 short ns = 0x1234 ;
3939
40- unsigned char * p = (unsigned char * )(& nl );
41- unsigned char * sp = (unsigned char * )(& ns );
40+ const unsigned char * p = (unsigned char * )(& nl );
41+ const unsigned char * sp = (unsigned char * )(& ns );
4242
4343 if (g_endianessDetected ) return ;
4444 if ( p [0 ] == 0x12 && p [1 ] == 0x34 && p [2 ] == 0x56 && p [3 ] == 0x78 )
@@ -60,11 +60,9 @@ detectEndianess()
6060static void
6161byteSwap (UWORD32 * buf , unsigned words )
6262{
63- md5byte * p ;
64-
6563 if (!g_bigEndian ) return ;
6664
67- p = (md5byte * )buf ;
65+ md5byte * p = (md5byte * )buf ;
6866
6967 do {
7068 * buf ++ = (UWORD32 )((unsigned )p [3 ] << 8 | p [2 ]) << 16 |
@@ -98,11 +96,9 @@ MD5Init(struct MD5Context *ctx)
9896void
9997MD5Update (struct MD5Context * ctx , md5byte const * buf , unsigned len )
10098{
101- UWORD32 t ;
102-
10399 /* Update byte count */
104100
105- t = ctx -> bytes [0 ];
101+ UWORD32 t = ctx -> bytes [0 ];
106102 if ((ctx -> bytes [0 ] = t + len ) < t )
107103 ctx -> bytes [1 ]++ ; /* Carry from low to high */
108104
@@ -189,12 +185,10 @@ MD5Final(md5byte digest[16], struct MD5Context *ctx)
189185void
190186MD5Transform (UWORD32 buf [4 ], UWORD32 const in [16 ])
191187{
192- UWORD32 a , b , c , d ;
193-
194- a = buf [0 ];
195- b = buf [1 ];
196- c = buf [2 ];
197- d = buf [3 ];
188+ UWORD32 a = buf [0 ];
189+ UWORD32 b = buf [1 ];
190+ UWORD32 c = buf [2 ];
191+ UWORD32 d = buf [3 ];
198192
199193 MD5STEP (F1 , a , b , c , d , in [0 ] + 0xd76aa478 , 7 );
200194 MD5STEP (F1 , d , a , b , c , in [1 ] + 0xe8c7b756 , 12 );
@@ -284,24 +278,18 @@ void MD5Buffer (const char *buf,unsigned int len,unsigned char sig[16])
284278
285279void MD5SigToString (unsigned char signature [16 ],char str [33 ])
286280{
287- unsigned char * sig_p ;
288- char * str_p ;
289- unsigned int high , low ;
281+ char * str_p = str ;
290282
291- str_p = str ;
292-
293- for (sig_p = (unsigned char * )signature ;
283+ for (unsigned char * sig_p = (unsigned char * )signature ;
294284 sig_p < (unsigned char * )signature + 16 ;
295285 sig_p ++ )
296286 {
297- high = * sig_p / 16 ;
298- low = * sig_p % 16 ;
287+ unsigned int high = * sig_p / 16 ;
288+ unsigned int low = * sig_p % 16 ;
299289 /* account for 2 chars */
300290 * str_p ++ = HEX_STRING [high ];
301291 * str_p ++ = HEX_STRING [low ];
302292 }
303293 /* account for 1 terminator */
304294 * str_p ++ = '\0' ;
305295}
306-
307-
0 commit comments