From be491ef0073a752a52efa6067fe8e29a2e530d69 Mon Sep 17 00:00:00 2001 From: Jeffrey Walton Date: Mon, 25 Jan 2016 09:48:26 -0500 Subject: [PATCH] Cleared -Wcast-align (Issue 122) --- panama.cpp | 4 +++- shark.cpp | 6 ++++-- socketft.cpp | 3 ++- 3 files changed, 9 insertions(+), 4 deletions(-) diff --git a/panama.cpp b/panama.cpp index 9f9c51a0..c763b175 100644 --- a/panama.cpp +++ b/panama.cpp @@ -500,8 +500,10 @@ template void PanamaCipherPolicy::OperateKeystream(KeystreamOperation operation, byte *output, const byte *input, size_t iterationCount) { #if (CRYPTOPP_BOOL_SSE2_ASM_AVAILABLE || defined(CRYPTOPP_X64_MASM_AVAILABLE)) && !defined(CRYPTOPP_DISABLE_PANAMA_ASM) + assert(IsAlignedOn(input,GetAlignmentOf())); + assert(IsAlignedOn(output,GetAlignmentOf())); if (B::ToEnum() == LITTLE_ENDIAN_ORDER && HasSSE2()) - Panama_SSE2_Pull(iterationCount, this->m_state, (word32 *)output, (const word32 *)input); + Panama_SSE2_Pull(iterationCount, this->m_state, (word32 *)(void *)output, (const word32 *)(void *)input); else #endif this->Iterate(iterationCount, NULL, output, input, operation); diff --git a/shark.cpp b/shark.cpp index 990ed0c6..592d0d91 100644 --- a/shark.cpp +++ b/shark.cpp @@ -96,7 +96,8 @@ template struct SharkProcessAndXorBlock{ // VC60 workaround: problem with template functions inline SharkProcessAndXorBlock(const word64 *roundKeys, unsigned int rounds, const byte *inBlock, const byte *xorBlock, byte *outBlock) { - word64 tmp = *(word64 *)inBlock ^ roundKeys[0]; + assert(IsAlignedOn(input,GetAlignmentOf())); + word64 tmp = *(word64 *)(void *)inBlock ^ roundKeys[0]; ByteOrder order = GetNativeByteOrder(); tmp = cbox[0][GetByte(order, tmp, 0)] ^ cbox[1][GetByte(order, tmp, 1)] @@ -124,7 +125,8 @@ inline SharkProcessAndXorBlock(const word64 *roundKeys, unsigned int rounds, con (sbox[GETBYTE(tmp, 1)]) (sbox[GETBYTE(tmp, 0)]); - *(word64 *)outBlock ^= roundKeys[rounds]; + assert(IsAlignedOn(output,GetAlignmentOf())); + *(word64 *)(void *)outBlock ^= roundKeys[rounds]; }}; void SHARK::Enc::ProcessAndXorBlock(const byte *inBlock, const byte *xorBlock, byte *outBlock) const diff --git a/socketft.cpp b/socketft.cpp index 1ec4cf07..4ebc7f54 100644 --- a/socketft.cpp +++ b/socketft.cpp @@ -158,7 +158,8 @@ bool Socket::Connect(const char *addr, unsigned int port) } else { - sa.sin_addr.s_addr = ((in_addr *)lphost->h_addr)->s_addr; + assert(IsAlignedOn(lphost->h_addr,GetAlignmentOf())); + sa.sin_addr.s_addr = ((in_addr *)(void *)lphost->h_addr)->s_addr; } }