From a14a5696e1d0361c370da817ed9531f71e5dc3d2 Mon Sep 17 00:00:00 2001 From: Jeffrey Walton Date: Mon, 29 Jun 2015 02:09:02 -0400 Subject: [PATCH] Added GCC_DIAGNOSTIC_AWARE to help suppress some warnings on contemporary compilers. The macro was needed to help with managing old compilers, like GCC 4.2.1, present on OpenBSD --- algparam.h | 10 ++++++++++ basecode.cpp | 5 +++++ config.h | 4 ++++ cryptlib.cpp | 5 +++++ default.cpp | 5 +++++ filters.cpp | 5 +++++ fipstest.cpp | 5 +++++ idea.cpp | 5 +++++ integer.cpp | 5 +++++ misc.h | 10 ++++++++++ randpool.cpp | 5 +++++ wake.cpp | 5 +++++ 12 files changed, 69 insertions(+) diff --git a/algparam.h b/algparam.h index 6a227407..44e0ff35 100644 --- a/algparam.h +++ b/algparam.h @@ -5,6 +5,12 @@ #include "smartptr.h" #include "secblock.h" +#if GCC_DIAGNOSTIC_AWARE +# pragma GCC diagnostic push +# pragma GCC diagnostic ignored "-Wunused-value" +# pragma GCC diagnostic ignored "-Wunused-variable" +#endif + NAMESPACE_BEGIN(CryptoPP) //! used to pass byte array input as part of a NameValuePairs object @@ -396,4 +402,8 @@ AlgorithmParameters MakeParameters(const char *name, const T &value, bool throwI NAMESPACE_END +#if GCC_DIAGNOSTIC_AWARE +# pragma GCC diagnostic pop +#endif + #endif diff --git a/basecode.cpp b/basecode.cpp index 0c98b227..62f9ee87 100644 --- a/basecode.cpp +++ b/basecode.cpp @@ -8,6 +8,11 @@ #include "fltrimpl.h" #include +#if GCC_DIAGNOSTIC_AWARE +# pragma GCC diagnostic ignored "-Wunused-value" +# pragma GCC diagnostic ignored "-Wunused-variable" +#endif + NAMESPACE_BEGIN(CryptoPP) void BaseN_Encoder::IsolatedInitialize(const NameValuePairs ¶meters) diff --git a/config.h b/config.h index 77c34b9e..41e22427 100644 --- a/config.h +++ b/config.h @@ -456,4 +456,8 @@ NAMESPACE_END #define CRYPTOPP_STATIC_TEMPLATE_CLASS CRYPTOPP_EXTERN_STATIC_TEMPLATE_CLASS #endif +// Used to supress some warnings in some header and implmentation files. +// GCC_DIAGNOSTIC_AWARE is used because some platforms, like OpenBSD, use old compilers. +#define GCC_DIAGNOSTIC_AWARE (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 7)) || defined(__clang__) + #endif diff --git a/cryptlib.cpp b/cryptlib.cpp index df138ddb..a9ed2905 100644 --- a/cryptlib.cpp +++ b/cryptlib.cpp @@ -16,6 +16,11 @@ #include +#if GCC_DIAGNOSTIC_AWARE +# pragma GCC diagnostic ignored "-Wunused-value" +# pragma GCC diagnostic ignored "-Wunused-variable" +#endif + NAMESPACE_BEGIN(CryptoPP) CRYPTOPP_COMPILE_ASSERT(sizeof(byte) == 1); diff --git a/default.cpp b/default.cpp index 72940784..9af80f48 100644 --- a/default.cpp +++ b/default.cpp @@ -6,6 +6,11 @@ #include #include +#if GCC_DIAGNOSTIC_AWARE +# pragma GCC diagnostic ignored "-Wunused-value" +# pragma GCC diagnostic ignored "-Wunused-variable" +#endif + NAMESPACE_BEGIN(CryptoPP) static const unsigned int MASH_ITERATIONS = 200; diff --git a/filters.cpp b/filters.cpp index 083dfd36..09f9a956 100644 --- a/filters.cpp +++ b/filters.cpp @@ -11,6 +11,11 @@ #include #include +#if GCC_DIAGNOSTIC_AWARE +# pragma GCC diagnostic ignored "-Wunused-value" +# pragma GCC diagnostic ignored "-Wunused-variable" +#endif + NAMESPACE_BEGIN(CryptoPP) Filter::Filter(BufferedTransformation *attachment) diff --git a/fipstest.cpp b/fipstest.cpp index e882742e..edb75dc7 100644 --- a/fipstest.cpp +++ b/fipstest.cpp @@ -23,6 +23,11 @@ extern "C" {_CRTIMP void __cdecl _CRT_DEBUGGER_HOOK(int);} #include +#if GCC_DIAGNOSTIC_AWARE +# pragma GCC diagnostic ignored "-Wunused-value" +# pragma GCC diagnostic ignored "-Wunused-variable" +#endif + NAMESPACE_BEGIN(CryptoPP) extern PowerUpSelfTestStatus g_powerUpSelfTestStatus; diff --git a/idea.cpp b/idea.cpp index 793f912f..31619786 100644 --- a/idea.cpp +++ b/idea.cpp @@ -4,6 +4,11 @@ #include "idea.h" #include "misc.h" +#if GCC_DIAGNOSTIC_AWARE +# pragma GCC diagnostic ignored "-Wunused-value" +# pragma GCC diagnostic ignored "-Wunused-variable" +#endif + NAMESPACE_BEGIN(CryptoPP) static const int IDEA_KEYLEN=(6*IDEA::ROUNDS+4); // key schedule length in # of word16s diff --git a/integer.cpp b/integer.cpp index f07cce87..23c176ef 100644 --- a/integer.cpp +++ b/integer.cpp @@ -30,6 +30,11 @@ #pragma message("You do not seem to have the Visual C++ Processor Pack installed, so use of SSE2 instructions will be disabled.") #endif +#if GCC_DIAGNOSTIC_AWARE +# pragma GCC diagnostic ignored "-Wunused-value" +# pragma GCC diagnostic ignored "-Wunused-variable" +#endif + #define CRYPTOPP_INTEGER_SSE2 (CRYPTOPP_BOOL_SSE2_ASM_AVAILABLE && CRYPTOPP_BOOL_X86) NAMESPACE_BEGIN(CryptoPP) diff --git a/misc.h b/misc.h index 1998d0ba..009c26e8 100644 --- a/misc.h +++ b/misc.h @@ -41,6 +41,12 @@ #include #endif +#if GCC_DIAGNOSTIC_AWARE +# pragma GCC diagnostic push +# pragma GCC diagnostic ignored "-Wunused-value" +# pragma GCC diagnostic ignored "-Wunused-variable" +#endif + NAMESPACE_BEGIN(CryptoPP) // ************** compile-time assertion *************** @@ -1279,4 +1285,8 @@ inline T SafeLeftShift(T value) NAMESPACE_END +#if GCC_DIAGNOSTIC_AWARE +# pragma GCC diagnostic pop +#endif + #endif diff --git a/randpool.cpp b/randpool.cpp index a063c899..ea7db55a 100644 --- a/randpool.cpp +++ b/randpool.cpp @@ -14,6 +14,11 @@ #include "hrtimer.h" #include +#if GCC_DIAGNOSTIC_AWARE +# pragma GCC diagnostic ignored "-Wunused-value" +# pragma GCC diagnostic ignored "-Wunused-variable" +#endif + NAMESPACE_BEGIN(CryptoPP) RandomPool::RandomPool() diff --git a/wake.cpp b/wake.cpp index e0f194e6..0fd8ca38 100644 --- a/wake.cpp +++ b/wake.cpp @@ -3,6 +3,11 @@ #include "pch.h" #include "wake.h" +#if GCC_DIAGNOSTIC_AWARE +# pragma GCC diagnostic ignored "-Wunused-value" +# pragma GCC diagnostic ignored "-Wunused-variable" +#endif + NAMESPACE_BEGIN(CryptoPP) void WAKE_TestInstantiations()