Cleared -Wcast-align (Issue 122)

pull/136/head
Jeffrey Walton 2016-01-25 11:37:22 -05:00
parent 9e92f79932
commit 6cdb141c5a
2 changed files with 6 additions and 5 deletions

View File

@ -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

View File

@ -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
{