From 7cff3c8d051529f5186685c7cf883e2992f446ff Mon Sep 17 00:00:00 2001 From: Jeffrey Walton Date: Sun, 24 Jan 2016 19:52:39 -0500 Subject: Cleared -Wcast-align (Issue 122) --- camellia.cpp | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) (limited to 'camellia.cpp') diff --git a/camellia.cpp b/camellia.cpp index 1c37d4e8..8d0b4d4e 100644 --- a/camellia.cpp +++ b/camellia.cpp @@ -91,11 +91,15 @@ void Camellia::Base::UncheckedSetKey(const byte *key, unsigned int keylen, const kwl = (word64(k0) << 32) | k1; \ kwr = (word64(k2) << 32) | k3 #define KS_ROUND_0(i) \ - *(word64*)CALC_ADDR(ks32, i+EFI(0)) = kwl; \ - *(word64*)CALC_ADDR(ks32, i+EFI(1)) = kwr + assert(IsAlignedOn(CALC_ADDR(ks32, i+EFI(0)),GetAlignmentOf())); \ + assert(IsAlignedOn(CALC_ADDR(ks32, i+EFI(1)),GetAlignmentOf())); \ + *(word64*)(void*)CALC_ADDR(ks32, i+EFI(0)) = kwl; \ + *(word64*)(void*)CALC_ADDR(ks32, i+EFI(1)) = kwr #define KS_ROUND(i, r, which) \ - if (which & (1<> (64 - (r%64))); \ - if (which & (1<64))) *(word64*)CALC_ADDR(ks32, i+EFI(r>64)) = (kwl << (r%64)) | (kwr >> (64 - (r%64))) + assert(IsAlignedOn(CALC_ADDR(ks32, i+EFI(r<64)),GetAlignmentOf())); \ + assert(IsAlignedOn(CALC_ADDR(ks32, i+EFI(r>64)),GetAlignmentOf())); \ + if (which & (1<> (64 - (r%64))); \ + if (which & (1<64))) *(word64*)(void*)CALC_ADDR(ks32, i+EFI(r>64)) = (kwl << (r%64)) | (kwr >> (64 - (r%64))) #else // SSE2 version is 30% faster on Intel Core 2. Doesn't seem worth the hassle of maintenance, but left here // #if'd out in case someone needs it. @@ -216,9 +220,11 @@ void Camellia::Base::ProcessAndXorBlock(const byte *inBlock, const byte *xorBloc const int cacheLineSize = GetCacheLineSize(); unsigned int i; word32 u = 0; + + assert(IsAlignedOn(s1,GetAlignmentOf())); for (i=0; i<256; i+=cacheLineSize) - u &= *(const word32 *)(s1+i); - u &= *(const word32 *)(s1+252); + u &= *(const word32 *)(void*)(s1+i); + u &= *(const word32 *)(void*)(s1+252); lh |= u; ll |= u; SLOW_ROUND(lh, ll, rh, rl, KS(1,0), KS(1,1)) -- cgit v1.2.1