Silence select conversion warnings (Issue 340)

pull/347/head
Jeffrey Walton 2016-12-02 14:47:31 -05:00
parent 3fff6251aa
commit 6eb2792bc2
No known key found for this signature in database
GPG Key ID: B36AB348921B1838
8 changed files with 89 additions and 7 deletions

12
asn.h
View File

@ -13,6 +13,13 @@
#include "queue.h"
#include "misc.h"
// Issue 340
#if CRYPTOPP_GCC_DIAGNOSTIC_AVAILABLE
# pragma GCC diagnostic push
# pragma GCC diagnostic ignored "-Wconversion"
# pragma GCC diagnostic ignored "-Wsign-conversion"
#endif
NAMESPACE_BEGIN(CryptoPP)
//! \brief ASN.1 types
@ -543,4 +550,9 @@ inline ::CryptoPP::OID operator+(const ::CryptoPP::OID &lhs, unsigned long rhs)
NAMESPACE_END
// Issue 340
#if CRYPTOPP_GCC_DIAGNOSTIC_AVAILABLE
# pragma GCC diagnostic pop
#endif
#endif

12
cpu.h
View File

@ -9,6 +9,13 @@
#include "config.h"
// Issue 340
#if CRYPTOPP_GCC_DIAGNOSTIC_AVAILABLE
# pragma GCC diagnostic push
# pragma GCC diagnostic ignored "-Wconversion"
# pragma GCC diagnostic ignored "-Wsign-conversion"
#endif
// ARM32/ARM64 Headers
#if (CRYPTOPP_BOOL_ARM32 || CRYPTOPP_BOOL_ARM64)
# if defined(__GNUC__)
@ -602,4 +609,9 @@ inline int GetCacheLineSize()
NAMESPACE_END
// Issue 340
#if CRYPTOPP_GCC_DIAGNOSTIC_AVAILABLE
# pragma GCC diagnostic pop
#endif
#endif // CRYPTOPP_CPU_H

View File

@ -131,13 +131,13 @@ void SimpleKeyingInterface::ThrowIfInvalidIV(const byte *iv)
size_t SimpleKeyingInterface::ThrowIfInvalidIVLength(int size)
{
if (size < 0)
return IVSize();
return (size_t)IVSize();
else if ((size_t)size < MinIVLength())
throw InvalidArgument(GetAlgorithm().AlgorithmName() + ": IV length " + IntToString(size) + " is less than the minimum of " + IntToString(MinIVLength()));
else if ((size_t)size > MaxIVLength())
throw InvalidArgument(GetAlgorithm().AlgorithmName() + ": IV length " + IntToString(size) + " exceeds the maximum of " + IntToString(MaxIVLength()));
else
return size;
return (size_t)size;
}
const byte * SimpleKeyingInterface::GetIVAndThrowIfInvalid(const NameValuePairs &params, size_t &size)
@ -298,7 +298,7 @@ byte RandomNumberGenerator::GenerateByte()
word32 RandomNumberGenerator::GenerateWord32(word32 min, word32 max)
{
const word32 range = max-min;
const int maxBits = BitPrecision(range);
const unsigned int maxBits = BitPrecision(range);
word32 value;
@ -721,6 +721,13 @@ size_t BufferedTransformation::PutWord32(word32 value, ByteOrder order, bool blo
return ChannelPutWord32(DEFAULT_CHANNEL, value, order, blocking);
}
// Issue 340
#if CRYPTOPP_GCC_DIAGNOSTIC_AVAILABLE
# pragma GCC diagnostic push
# pragma GCC diagnostic ignored "-Wconversion"
# pragma GCC diagnostic ignored "-Wsign-conversion"
#endif
size_t BufferedTransformation::PeekWord16(word16 &value, ByteOrder order) const
{
byte buf[2] = {0, 0};
@ -747,6 +754,11 @@ size_t BufferedTransformation::PeekWord32(word32 &value, ByteOrder order) const
return len;
}
// Issue 340
#if CRYPTOPP_GCC_DIAGNOSTIC_AVAILABLE
# pragma GCC diagnostic pop
#endif
size_t BufferedTransformation::GetWord16(word16 &value, ByteOrder order)
{
return (size_t)Skip(PeekWord16(value, order));

View File

@ -18,6 +18,12 @@
#include <iostream>
// Issue 340
#if CRYPTOPP_GCC_DIAGNOSTIC_AVAILABLE
# pragma GCC diagnostic ignored "-Wconversion"
# pragma GCC diagnostic ignored "-Wsign-conversion"
#endif
NAMESPACE_BEGIN(CryptoPP)
PolynomialMod2::PolynomialMod2()

View File

@ -13,6 +13,12 @@
# pragma GCC diagnostic ignored "-Wunused-but-set-variable"
#endif
// Issue 340
#if CRYPTOPP_GCC_DIAGNOSTIC_AVAILABLE
# pragma GCC diagnostic ignored "-Wconversion"
# pragma GCC diagnostic ignored "-Wsign-conversion"
#endif
#ifndef CRYPTOPP_IMPORTS
#include "integer.h"

11
misc.h
View File

@ -19,6 +19,13 @@
# endif
#endif
// Issue 340
#if CRYPTOPP_GCC_DIAGNOSTIC_AVAILABLE
# pragma GCC diagnostic push
# pragma GCC diagnostic ignored "-Wconversion"
# pragma GCC diagnostic ignored "-Wsign-conversion"
#endif
#include "cryptlib.h"
#include "stdcpp.h"
#include "smartptr.h"
@ -2428,4 +2435,8 @@ NAMESPACE_END
# pragma warning(pop)
#endif
#if CRYPTOPP_GCC_DIAGNOSTIC_AVAILABLE
# pragma GCC diagnostic pop
#endif
#endif

12
modes.h
View File

@ -13,6 +13,13 @@
#include "argnames.h"
#include "algparam.h"
// Issue 340
#if CRYPTOPP_GCC_DIAGNOSTIC_AVAILABLE
# pragma GCC diagnostic push
# pragma GCC diagnostic ignored "-Wconversion"
# pragma GCC diagnostic ignored "-Wsign-conversion"
#endif
NAMESPACE_BEGIN(CryptoPP)
//! \class CipherModeDocumentation
@ -482,4 +489,9 @@ typedef CTR_Mode_ExternalCipher::Encryption CounterMode;
NAMESPACE_END
// Issue 340
#if CRYPTOPP_GCC_DIAGNOSTIC_AVAILABLE
# pragma GCC diagnostic pop
#endif
#endif

View File

@ -1,21 +1,27 @@
// seckey.h - written and placed in the public domain by Wei Dai
//! \file
//! \file seckey.h
//! \brief Classes and functions for implementing secret key algorithms.
#ifndef CRYPTOPP_SECKEY_H
#define CRYPTOPP_SECKEY_H
#include "config.h"
#include "cryptlib.h"
#include "misc.h"
#include "simple.h"
#if CRYPTOPP_MSC_VERSION
# pragma warning(push)
# pragma warning(disable: 4189)
#endif
#include "cryptlib.h"
#include "misc.h"
#include "simple.h"
// Issue 340
#if CRYPTOPP_GCC_DIAGNOSTIC_AVAILABLE
# pragma GCC diagnostic push
# pragma GCC diagnostic ignored "-Wconversion"
# pragma GCC diagnostic ignored "-Wsign-conversion"
#endif
NAMESPACE_BEGIN(CryptoPP)
@ -442,4 +448,9 @@ NAMESPACE_END
# pragma warning(pop)
#endif
// Issue 340
#if CRYPTOPP_GCC_DIAGNOSTIC_AVAILABLE
# pragma GCC diagnostic pop
#endif
#endif