Cleared "unused function" warning when using GCC with -Wall

pull/35/head
Jeffrey Walton 2015-07-23 14:21:06 -04:00
parent b2d9be1b80
commit 07e8319478
3 changed files with 33 additions and 14 deletions

25
cpu.cpp
View File

@ -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)
{

View File

@ -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[] = {

8
misc.h
View File

@ -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