Clear clang-tidy warnings

This commit is contained in:
Jeffrey Walton 2018-01-24 15:35:45 -05:00
parent 85993b2529
commit 30bcc7022d
No known key found for this signature in database
GPG Key ID: B36AB348921B1838
2 changed files with 24 additions and 31 deletions

View File

@ -3645,32 +3645,24 @@ std::istream& operator>>(std::istream& in, Integer &a)
return in;
}
// Ensure base 10 is default
inline int FlagToBase(long f) {
return f == std::ios::hex ? 16 : (f == std::ios::oct ? 8 : 10);
}
inline char FlagToSuffix(long f) {
return f == std::ios::hex ? 'h' : (f == std::ios::oct ? 'o' : '.');
}
// Ensure base 10 is default
std::ostream& operator<<(std::ostream& out, const Integer &a)
{
// Get relevant conversion specifications from ostream.
const long f = out.flags() & std::ios::basefield; // Get base digits.
int base, block;
char suffix;
switch(f)
{
case std::ios::oct :
base = 8;
block = 8;
suffix = 'o';
break;
case std::ios::hex :
base = 16;
block = 4;
suffix = 'h';
break;
default :
base = 10;
block = 3;
suffix = '.';
}
const long f = out.flags() & std::ios::basefield;
const int base = FlagToBase(f);
const char suffix = FlagToSuffix(f);
Integer temp1=a, temp2;
if (a.IsNegative())
{
out << '-';
@ -3698,8 +3690,6 @@ std::ostream& operator<<(std::ostream& out, const Integer &a)
while (i--)
{
out << s[i];
// if (i && !(i%block))
// out << ",";
}
#ifdef CRYPTOPP_USE_STD_SHOWBASE
@ -3873,7 +3863,7 @@ void PositiveSubtract(Integer &diff, const Integer &a, const Integer& b)
word borrow = Subtract(diff.reg, a.reg, b.reg, bSize);
CopyWords(diff.reg+bSize, a.reg+bSize, aSize-bSize);
borrow = Decrement(diff.reg+bSize, aSize-bSize, borrow);
CRYPTOPP_ASSERT(!borrow);
CRYPTOPP_ASSERT(!borrow); CRYPTOPP_UNUSED(borrow);
diff.sign = Integer::POSITIVE;
}
else if (aSize == bSize)
@ -3894,7 +3884,7 @@ void PositiveSubtract(Integer &diff, const Integer &a, const Integer& b)
word borrow = Subtract(diff.reg, b.reg, a.reg, aSize);
CopyWords(diff.reg+aSize, b.reg+aSize, bSize-aSize);
borrow = Decrement(diff.reg+aSize, bSize-aSize, borrow);
CRYPTOPP_ASSERT(!borrow);
CRYPTOPP_ASSERT(!borrow); CRYPTOPP_UNUSED(borrow);
diff.sign = Integer::NEGATIVE;
}
}

15
tea.cpp
View File

@ -9,6 +9,9 @@ NAMESPACE_BEGIN(CryptoPP)
static const word32 DELTA = 0x9e3779b9;
typedef BlockGetAndPut<word32, BigEndian> Block;
#define UINT32_CAST(x) ((word32*)(void*)(x))
#define CONST_UINT32_CAST(x) ((const word32*)(const void*)(x))
void TEA::Base::UncheckedSetKey(const byte *userKey, unsigned int length, const NameValuePairs &params)
{
AssertValidKeyLength(length);
@ -98,10 +101,10 @@ void BTEA::Enc::ProcessAndXorBlock(const byte *inBlock, const byte *xorBlock, by
CRYPTOPP_ASSERT(IsAlignedOn(outBlock,GetAlignmentOf<word32>()));
unsigned int n = m_blockSize / 4;
word32 *v = (word32*)(void *)outBlock;
ConditionalByteReverse(BIG_ENDIAN_ORDER, v, (const word32*)(void *)inBlock, m_blockSize);
word32 *v = UINT32_CAST(outBlock);
ConditionalByteReverse(BIG_ENDIAN_ORDER, v, CONST_UINT32_CAST(inBlock), m_blockSize);
word32 y = v[0], z = v[n-1], e;
word32 y, z = v[n-1], e;
word32 p, q = 6+52/n;
word32 sum = 0;
@ -128,10 +131,10 @@ void BTEA::Dec::ProcessAndXorBlock(const byte *inBlock, const byte *xorBlock, by
CRYPTOPP_ASSERT(IsAlignedOn(outBlock,GetAlignmentOf<word32>()));
unsigned int n = m_blockSize / 4;
word32 *v = (word32*)(void *)outBlock;
ConditionalByteReverse(BIG_ENDIAN_ORDER, v, (const word32*)(void *)inBlock, m_blockSize);
word32 *v = UINT32_CAST(outBlock);
ConditionalByteReverse(BIG_ENDIAN_ORDER, v, CONST_UINT32_CAST(inBlock), m_blockSize);
word32 y = v[0], z = v[n-1], e;
word32 y = v[0], z, e;
word32 p, q = 6+52/n;
word32 sum = q * DELTA;