summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJeffrey Walton <noloader@gmail.com>2015-07-23 14:21:06 -0400
committerJeffrey Walton <noloader@gmail.com>2015-07-23 14:21:06 -0400
commit07e831947832804cbe7bc22756dd6c8403f24f36 (patch)
treeaf3f5de03c4e1fe9cc2b5b75f9b201bcdeba73ee
parentb2d9be1b80a66b939af3921f52a760c28859df8f (diff)
downloadcryptopp-git-07e831947832804cbe7bc22756dd6c8403f24f36.tar.gz
Cleared "unused function" warning when using GCC with -Wall
-rw-r--r--cpu.cpp25
-rw-r--r--eccrypto.cpp14
-rw-r--r--misc.h8
3 files changed, 33 insertions, 14 deletions
diff --git a/cpu.cpp b/cpu.cpp
index b052c9d7..8d784262 100644
--- a/cpu.cpp
+++ b/cpu.cpp
@@ -33,21 +33,26 @@ bool CpuId(word32 input, word32 *output)
#ifndef CRYPTOPP_MS_STYLE_INLINE_ASSEMBLY
extern "C" {
-typedef void (*SigHandler)(int);
+ typedef void (*SigHandler)(int);
-static jmp_buf s_jmpNoCPUID;
-static void SigIllHandlerCPUID(int)
-{
+ static jmp_buf s_jmpNoCPUID;
+ static jmp_buf s_jmpNoSSE2;
+
+ // Declare it so we can attach the attribute
+ static void SigIllHandlerCPUID(int) CRYPTOPP_UNUSED_FUNCTION;
+ static void SigIllHandlerCPUID(int)
+ {
longjmp(s_jmpNoCPUID, 1);
-}
+ }
-static jmp_buf s_jmpNoSSE2;
-static void SigIllHandlerSSE2(int)
-{
+ // Declare it so we can attach the attribute
+ static void SigIllHandlerSSE2(int) CRYPTOPP_UNUSED_FUNCTION;
+ static void SigIllHandlerSSE2(int)
+ {
longjmp(s_jmpNoSSE2, 1);
+ }
}
-}
-#endif
+#endif // CRYPTOPP_MS_STYLE_INLINE_ASSEMBLY
bool CpuId(word32 input, word32 *output)
{
diff --git a/eccrypto.cpp b/eccrypto.cpp
index fe77d2bc..66c978b8 100644
--- a/eccrypto.cpp
+++ b/eccrypto.cpp
@@ -11,6 +11,7 @@
#include "argnames.h"
#include "ec2n.h"
#include "misc.h"
+#include "trap.h"
#if GCC_DIAGNOSTIC_AWARE
# pragma GCC diagnostic ignored "-Wunused-function"
@@ -32,8 +33,7 @@ static void ECDSA_TestInstantiations()
}
#endif
-// VC60 workaround: complains when these functions are put into an anonymous namespace
-static Integer ConvertToInteger(const PolynomialMod2 &x)
+static inline Integer ConvertToInteger(const PolynomialMod2 &x)
{
unsigned int l = x.ByteCount();
SecByteBlock temp(l);
@@ -118,7 +118,10 @@ struct OIDLessThan
inline bool operator()(const EcRecommendedParameters<T>& a, const EcRecommendedParameters<T>& b) {return a.oid < b.oid;}
};
-static void GetRecommendedParameters(const EcRecommendedParameters<EC2N> *&begin, const EcRecommendedParameters<EC2N> *&end)
+// Declare it so we can attach the attribute
+static void GetRecommendedParameters(const EcRecommendedParameters<EC2N> *&begin, const EcRecommendedParameters<EC2N> *&end) CRYPTOPP_UNUSED_FUNCTION;
+
+void GetRecommendedParameters(const EcRecommendedParameters<EC2N> *&begin, const EcRecommendedParameters<EC2N> *&end)
{
// this array must be sorted by OID
static const EcRecommendedParameters<EC2N> rec[] = {
@@ -253,7 +256,10 @@ static void GetRecommendedParameters(const EcRecommendedParameters<EC2N> *&begin
end = rec + COUNTOF(rec);
}
-static void GetRecommendedParameters(const EcRecommendedParameters<ECP> *&begin, const EcRecommendedParameters<ECP> *&end)
+// Declare it so we can attach the unused attribute
+static void GetRecommendedParameters(const EcRecommendedParameters<ECP> *&begin, const EcRecommendedParameters<ECP> *&end) CRYPTOPP_UNUSED_FUNCTION;
+
+void GetRecommendedParameters(const EcRecommendedParameters<ECP> *&begin, const EcRecommendedParameters<ECP> *&end)
{
// this array must be sorted by OID
static const EcRecommendedParameters<ECP> rec[] = {
diff --git a/misc.h b/misc.h
index 8c709631..15206561 100644
--- a/misc.h
+++ b/misc.h
@@ -95,6 +95,14 @@ struct CompileAssert
// Cast to void. Portable way to suppress warning
#define CRYPTOPP_UNUSED(x) ((void)x)
+// ************** unused function suppression ***************
+// Not portable, but nearly as old as GCC itself
+#ifdef __GNUC__
+# define CRYPTOPP_UNUSED_FUNCTION __attribute__ ((unused))
+#else
+# define CRYPTOPP_UNUSED_FUNCTION
+#endif
+
// ************** counting elements in an array ***************
// VS2005 added _countof macro, fails on pointers
#ifndef COUNTOF