From 6cdb141c5a74a495550a376835ee9b98a5c3af08 Mon Sep 17 00:00:00 2001 From: Jeffrey Walton Date: Mon, 25 Jan 2016 11:37:22 -0500 Subject: [PATCH] Cleared -Wcast-align (Issue 122) --- rdrand.cpp | 8 ++++---- validat1.cpp | 3 ++- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/rdrand.cpp b/rdrand.cpp index fbfb7eec..55fde3ab 100644 --- a/rdrand.cpp +++ b/rdrand.cpp @@ -261,9 +261,9 @@ static int GCC_RRA_GenerateBlock(byte *output, size_t size, unsigned int safety) if (size >= sizeof(val)) { #if defined(CRYPTOPP_ALLOW_UNALIGNED_DATA_ACCESS) && (CRYPTOPP_BOOL_X64 || CRYPTOPP_BOOL_X32) - *((word64*)output) = val; + *((word64*)(void *)output) = val; #elif defined(CRYPTOPP_ALLOW_UNALIGNED_DATA_ACCESS) && (CRYPTOPP_BOOL_X86) - *((word32*)output) = val; + *((word32*)(void *)output) = val; #else memcpy(output, &val, sizeof(val)); #endif @@ -442,9 +442,9 @@ static int GCC_RSA_GenerateBlock(byte *output, size_t size, unsigned int safety) if (size >= sizeof(val)) { #if defined(CRYPTOPP_ALLOW_UNALIGNED_DATA_ACCESS) && (CRYPTOPP_BOOL_X64 || CRYPTOPP_BOOL_X32) - *((word64*)output) = val; + *((word64*)(void *)output) = val; #elif defined(CRYPTOPP_ALLOW_UNALIGNED_DATA_ACCESS) && (CRYPTOPP_BOOL_X86) - *((word32*)output) = val; + *((word32*)(void *)output) = val; #else memcpy(output, &val, sizeof(val)); #endif diff --git a/validat1.cpp b/validat1.cpp index 892dcc81..952d3ccf 100644 --- a/validat1.cpp +++ b/validat1.cpp @@ -197,8 +197,9 @@ bool TestSettings() } #ifdef CRYPTOPP_ALLOW_UNALIGNED_DATA_ACCESS + // Don't assert the alignment of testvals. That's what this test is for. byte testvals[10] = {1,2,2,3,3,3,3,2,2,1}; - if (*(word32 *)(testvals+3) == 0x03030303 && *(word64 *)(testvals+1) == W64LIT(0x0202030303030202)) + if (*(word32 *)(void *)(testvals+3) == 0x03030303 && *(word64 *)(void *)(testvals+1) == W64LIT(0x0202030303030202)) cout << "passed: Your machine allows unaligned data access.\n"; else {