[PATCH 4/4] random-csprng: fix compiler warnings on ARM

Jussi Kivilinna jussi.kivilinna at iki.fi
Tue Dec 23 16:36:36 CET 2014


* random/random-csprng.c (_gcry_rngcsprng_update_seed_file)
(read_pool): Cast keypool and rndpool to 'unsigned long *' through
'void *'.
--

Patch fixes 'cast increases required alignment' warnings seen on GCC:

random-csprng.c: In function '_gcry_rngcsprng_update_seed_file':
random-csprng.c:867:15: warning: cast increases required alignment of target type [-Wcast-align]
   for (i=0,dp=(unsigned long*)keypool, sp=(unsigned long*)rndpool;
               ^
random-csprng.c:867:43: warning: cast increases required alignment of target type [-Wcast-align]
   for (i=0,dp=(unsigned long*)keypool, sp=(unsigned long*)rndpool;
                                           ^
random-csprng.c: In function 'read_pool':
random-csprng.c:1023:14: warning: cast increases required alignment of target type [-Wcast-align]
   for(i=0,dp=(unsigned long*)keypool, sp=(unsigned long*)rndpool;
              ^
random-csprng.c:1023:42: warning: cast increases required alignment of target type [-Wcast-align]
   for(i=0,dp=(unsigned long*)keypool, sp=(unsigned long*)rndpool;
                                          ^

Signed-off-by: Jussi Kivilinna <jussi.kivilinna at iki.fi>
---
 random/random-csprng.c |    4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/random/random-csprng.c b/random/random-csprng.c
index 429c84f..332744b 100644
--- a/random/random-csprng.c
+++ b/random/random-csprng.c
@@ -864,7 +864,7 @@ _gcry_rngcsprng_update_seed_file (void)
 
 
   /* Copy the entropy pool to a scratch pool and mix both of them. */
-  for (i=0,dp=(unsigned long*)keypool, sp=(unsigned long*)rndpool;
+  for (i=0,dp=(unsigned long*)(void*)keypool, sp=(unsigned long*)(void*)rndpool;
        i < POOLWORDS; i++, dp++, sp++ )
     {
       *dp = *sp + ADD_VALUE;
@@ -1020,7 +1020,7 @@ read_pool (byte *buffer, size_t length, int level)
     }
 
   /* Create a new pool. */
-  for(i=0,dp=(unsigned long*)keypool, sp=(unsigned long*)rndpool;
+  for(i=0,dp=(unsigned long*)(void*)keypool, sp=(unsigned long*)(void*)rndpool;
       i < POOLWORDS; i++, dp++, sp++ )
     *dp = *sp + ADD_VALUE;
 




More information about the Gcrypt-devel mailing list