Suppressed false positives on -Wcast-align warning

pull/116/head
Jeffrey Walton 2016-01-14 19:08:56 -05:00
parent 58b7d1c413
commit 2b7dba4fa6
4 changed files with 35 additions and 2 deletions

View File

@ -99,7 +99,11 @@ class RandomNumberGenerator;
class BufferedTransformation;
//! \brief Specifies a direction for a cipher to operate
enum CipherDir {ENCRYPTION, DECRYPTION};
enum CipherDir {
//! \brief the cipher is performing encryption
ENCRYPTION,
//! \brief the cipher is performing decryption
DECRYPTION};
//! \brief Represents infinite time
const unsigned long INFINITE_TIME = ULONG_MAX;
@ -113,7 +117,12 @@ struct EnumToType
};
//! \brief Provides the byte ordering
enum ByteOrder {LITTLE_ENDIAN_ORDER = 0, BIG_ENDIAN_ORDER = 1};
enum ByteOrder {
//! \brief byte order is little-endian
LITTLE_ENDIAN_ORDER = 0,
//! \brief byte order is big-endian
BIG_ENDIAN_ORDER = 1};
//! \brief Provides a constant for LittleEndian
typedef EnumToType<ByteOrder, LITTLE_ENDIAN_ORDER> LittleEndian;
//! \brief Provides a constant for BigEndian

View File

@ -10,6 +10,10 @@
# endif
#endif
#if CRYPTOPP_GCC_DIAGNOSTIC_AVAILABLE
# pragma GCC diagnostic ignored "-Wcast-align"
#endif
#ifndef CRYPTOPP_IMPORTS
#include "misc.h"

9
misc.h
View File

@ -1047,6 +1047,11 @@ template<> inline void SecureWipeBuffer(word64 *buf, size_t n)
template <class T>
inline void SecureWipeArray(T *buf, size_t n)
{
#if CRYPTOPP_GCC_DIAGNOSTIC_AVAILABLE
# pragma GCC diagnostic push
# pragma GCC diagnostic ignored "-Wcast-align"
#endif
if (sizeof(T) % 8 == 0 && GetAlignmentOf<T>() % GetAlignmentOf<word64>() == 0)
SecureWipeBuffer((word64 *)buf, n * (sizeof(T)/8));
else if (sizeof(T) % 4 == 0 && GetAlignmentOf<T>() % GetAlignmentOf<word32>() == 0)
@ -1055,6 +1060,10 @@ inline void SecureWipeArray(T *buf, size_t n)
SecureWipeBuffer((word16 *)buf, n * (sizeof(T)/2));
else
SecureWipeBuffer((byte *)buf, n * sizeof(T));
#if CRYPTOPP_GCC_DIAGNOSTIC_AVAILABLE
# pragma GCC diagnostic pop
#endif
}
//! \brief Converts a wide character C-string to a multibyte string

View File

@ -408,6 +408,12 @@ public:
size_type max_size() const {return STDMAX(m_fallbackAllocator.max_size(), S);}
private:
#if CRYPTOPP_GCC_DIAGNOSTIC_AVAILABLE
# pragma GCC diagnostic push
# pragma GCC diagnostic ignored "-Wcast-align"
#endif
#ifdef __BORLANDC__
T* GetAlignedArray() {return m_array;}
T m_array[S];
@ -415,6 +421,11 @@ private:
T* GetAlignedArray() {return (CRYPTOPP_BOOL_ALIGN16 && T_Align16) ? (T*)(((byte *)m_array) + (0-(size_t)m_array)%16) : m_array;}
CRYPTOPP_ALIGN_DATA(8) T m_array[(CRYPTOPP_BOOL_ALIGN16 && T_Align16) ? S+8/sizeof(T) : S];
#endif
#if CRYPTOPP_GCC_DIAGNOSTIC_AVAILABLE
# pragma GCC diagnostic pop
#endif
A m_fallbackAllocator;
bool m_allocated;
};