aboutsummaryrefslogtreecommitdiffstats
path: root/src/lib/utils
diff options
context:
space:
mode:
authorDaniel Neus <[email protected]>2016-01-11 21:52:38 +0100
committerDaniel Neus <[email protected]>2016-03-05 12:10:39 +0100
commitfbdc39de29a0efbcd13ad169c844189168d2110d (patch)
treeffadbfd29b164ce81a6628773a1f5f8216ab8fb6 /src/lib/utils
parent4424af469bd2bfe05b9ac1cd4e156383f23ae9e4 (diff)
cppcheck fixes: Class 'X' has a constructor with 1 argument that is not explicit.
Diffstat (limited to 'src/lib/utils')
-rw-r--r--src/lib/utils/data_src.h6
-rw-r--r--src/lib/utils/database.h2
-rw-r--r--src/lib/utils/exceptn.h34
-rw-r--r--src/lib/utils/semaphore.h2
-rw-r--r--src/lib/utils/simd/simd_sse2/simd_sse2.h28
5 files changed, 36 insertions, 36 deletions
diff --git a/src/lib/utils/data_src.h b/src/lib/utils/data_src.h
index 0a6ce0a8c..6a100ce63 100644
--- a/src/lib/utils/data_src.h
+++ b/src/lib/utils/data_src.h
@@ -108,7 +108,7 @@ class BOTAN_DLL DataSource_Memory : public DataSource
* Construct a memory source that reads from a string
* @param in the string to read from
*/
- DataSource_Memory(const std::string& in);
+ explicit DataSource_Memory(const std::string& in);
/**
* Construct a memory source that reads from a byte array
@@ -122,14 +122,14 @@ class BOTAN_DLL DataSource_Memory : public DataSource
* Construct a memory source that reads from a secure_vector
* @param in the MemoryRegion to read from
*/
- DataSource_Memory(const secure_vector<byte>& in) :
+ explicit DataSource_Memory(const secure_vector<byte>& in) :
m_source(in), m_offset(0) {}
/**
* Construct a memory source that reads from a std::vector
* @param in the MemoryRegion to read from
*/
- DataSource_Memory(const std::vector<byte>& in) :
+ explicit DataSource_Memory(const std::vector<byte>& in) :
m_source(in.begin(), in.end()), m_offset(0) {}
size_t get_bytes_read() const override { return m_offset; }
diff --git a/src/lib/utils/database.h b/src/lib/utils/database.h
index 4d8b90d0c..4cc0989b1 100644
--- a/src/lib/utils/database.h
+++ b/src/lib/utils/database.h
@@ -23,7 +23,7 @@ class BOTAN_DLL SQL_Database
class BOTAN_DLL SQL_DB_Error : public Exception
{
public:
- SQL_DB_Error(const std::string& what) : Exception("SQL database", what) {}
+ explicit SQL_DB_Error(const std::string& what) : Exception("SQL database", what) {}
};
class BOTAN_DLL Statement
diff --git a/src/lib/utils/exceptn.h b/src/lib/utils/exceptn.h
index 1e9cd68d5..b6797f0f6 100644
--- a/src/lib/utils/exceptn.h
+++ b/src/lib/utils/exceptn.h
@@ -21,7 +21,7 @@ namespace Botan {
class BOTAN_DLL Exception : public std::exception
{
public:
- Exception(const std::string& msg) : m_msg(msg) {}
+ explicit Exception(const std::string& msg) : m_msg(msg) {}
Exception(const char* prefix, const std::string& msg) : m_msg(std::string(prefix) + " " + msg) {}
const char* what() const BOTAN_NOEXCEPT override { return m_msg.c_str(); }
private:
@@ -34,7 +34,7 @@ class BOTAN_DLL Exception : public std::exception
class BOTAN_DLL Invalid_Argument : public Exception
{
public:
- Invalid_Argument(const std::string& msg) :
+ explicit Invalid_Argument(const std::string& msg) :
Exception("Invalid argument", msg) {}
};
@@ -46,7 +46,7 @@ class BOTAN_DLL Invalid_Argument : public Exception
*/
struct BOTAN_DLL Unsupported_Argument : public Invalid_Argument
{
- Unsupported_Argument(const std::string& msg) : Invalid_Argument(msg) {}
+ explicit Unsupported_Argument(const std::string& msg) : Invalid_Argument(msg) {}
};
/**
@@ -54,7 +54,7 @@ struct BOTAN_DLL Unsupported_Argument : public Invalid_Argument
*/
struct BOTAN_DLL Invalid_State : public Exception
{
- Invalid_State(const std::string& err) :
+ explicit Invalid_State(const std::string& err) :
Exception(err)
{}
};
@@ -64,7 +64,7 @@ struct BOTAN_DLL Invalid_State : public Exception
*/
struct BOTAN_DLL Lookup_Error : public Exception
{
- Lookup_Error(const std::string& err) :
+ explicit Lookup_Error(const std::string& err) :
Exception(err)
{}
};
@@ -74,7 +74,7 @@ struct BOTAN_DLL Lookup_Error : public Exception
*/
struct BOTAN_DLL Internal_Error : public Exception
{
- Internal_Error(const std::string& err) :
+ explicit Internal_Error(const std::string& err) :
Exception("Internal error: " + err)
{}
};
@@ -106,7 +106,7 @@ struct BOTAN_DLL Invalid_IV_Length : public Invalid_Argument
*/
struct BOTAN_DLL PRNG_Unseeded : public Invalid_State
{
- PRNG_Unseeded(const std::string& algo) :
+ explicit PRNG_Unseeded(const std::string& algo) :
Invalid_State("PRNG not seeded: " + algo)
{}
};
@@ -116,7 +116,7 @@ struct BOTAN_DLL PRNG_Unseeded : public Invalid_State
*/
struct BOTAN_DLL Policy_Violation : public Invalid_State
{
- Policy_Violation(const std::string& err) :
+ explicit Policy_Violation(const std::string& err) :
Invalid_State("Policy violation: " + err)
{}
};
@@ -126,7 +126,7 @@ struct BOTAN_DLL Policy_Violation : public Invalid_State
*/
struct BOTAN_DLL Algorithm_Not_Found : public Lookup_Error
{
- Algorithm_Not_Found(const std::string& name) :
+ explicit Algorithm_Not_Found(const std::string& name) :
Lookup_Error("Could not find any algorithm named \"" + name + "\"")
{}
};
@@ -136,7 +136,7 @@ struct BOTAN_DLL Algorithm_Not_Found : public Lookup_Error
*/
struct BOTAN_DLL No_Provider_Found : public Exception
{
- No_Provider_Found(const std::string& name) :
+ explicit No_Provider_Found(const std::string& name) :
Exception("Could not find any provider for algorithm named \"" + name + "\"")
{}
};
@@ -146,7 +146,7 @@ struct BOTAN_DLL No_Provider_Found : public Exception
*/
struct BOTAN_DLL Invalid_Algorithm_Name : public Invalid_Argument
{
- Invalid_Algorithm_Name(const std::string& name):
+ explicit Invalid_Algorithm_Name(const std::string& name):
Invalid_Argument("Invalid algorithm name: " + name)
{}
};
@@ -156,7 +156,7 @@ struct BOTAN_DLL Invalid_Algorithm_Name : public Invalid_Argument
*/
struct BOTAN_DLL Encoding_Error : public Invalid_Argument
{
- Encoding_Error(const std::string& name) :
+ explicit Encoding_Error(const std::string& name) :
Invalid_Argument("Encoding error: " + name) {}
};
@@ -165,7 +165,7 @@ struct BOTAN_DLL Encoding_Error : public Invalid_Argument
*/
struct BOTAN_DLL Decoding_Error : public Invalid_Argument
{
- Decoding_Error(const std::string& name) :
+ explicit Decoding_Error(const std::string& name) :
Invalid_Argument("Decoding error: " + name) {}
};
@@ -174,7 +174,7 @@ struct BOTAN_DLL Decoding_Error : public Invalid_Argument
*/
struct BOTAN_DLL Integrity_Failure : public Exception
{
- Integrity_Failure(const std::string& msg) :
+ explicit Integrity_Failure(const std::string& msg) :
Exception("Integrity failure: " + msg) {}
};
@@ -183,7 +183,7 @@ struct BOTAN_DLL Integrity_Failure : public Exception
*/
struct BOTAN_DLL Invalid_OID : public Decoding_Error
{
- Invalid_OID(const std::string& oid) :
+ explicit Invalid_OID(const std::string& oid) :
Decoding_Error("Invalid ASN.1 OID: " + oid) {}
};
@@ -192,7 +192,7 @@ struct BOTAN_DLL Invalid_OID : public Decoding_Error
*/
struct BOTAN_DLL Stream_IO_Error : public Exception
{
- Stream_IO_Error(const std::string& err) :
+ explicit Stream_IO_Error(const std::string& err) :
Exception("I/O error: " + err)
{}
};
@@ -210,7 +210,7 @@ struct BOTAN_DLL No_Filesystem_Access : public Exception
*/
struct BOTAN_DLL Self_Test_Failure : public Internal_Error
{
- Self_Test_Failure(const std::string& err) :
+ explicit Self_Test_Failure(const std::string& err) :
Internal_Error("Self test failed: " + err)
{}
};
diff --git a/src/lib/utils/semaphore.h b/src/lib/utils/semaphore.h
index 3495043e5..994a15f21 100644
--- a/src/lib/utils/semaphore.h
+++ b/src/lib/utils/semaphore.h
@@ -16,7 +16,7 @@ namespace Botan {
class Semaphore
{
public:
- Semaphore(int value = 0) : m_value(value), m_wakeups(0) {}
+ explicit Semaphore(int value = 0) : m_value(value), m_wakeups(0) {}
void acquire();
diff --git a/src/lib/utils/simd/simd_sse2/simd_sse2.h b/src/lib/utils/simd/simd_sse2/simd_sse2.h
index 1757b5976..551e9189c 100644
--- a/src/lib/utils/simd/simd_sse2/simd_sse2.h
+++ b/src/lib/utils/simd/simd_sse2/simd_sse2.h
@@ -18,7 +18,7 @@ namespace Botan {
class SIMD_SSE2
{
public:
- SIMD_SSE2(const u32bit B[4])
+ explicit SIMD_SSE2(const u32bit B[4])
{
m_reg = _mm_loadu_si128(reinterpret_cast<const __m128i*>(B));
}
@@ -28,14 +28,14 @@ class SIMD_SSE2
m_reg = _mm_set_epi32(B0, B1, B2, B3);
}
- SIMD_SSE2(u32bit B)
+ explicit SIMD_SSE2(u32bit B)
{
m_reg = _mm_set1_epi32(B);
}
static SIMD_SSE2 load_le(const void* in)
{
- return _mm_loadu_si128(reinterpret_cast<const __m128i*>(in));
+ return SIMD_SSE2(_mm_loadu_si128(reinterpret_cast<const __m128i*>(in)));
}
static SIMD_SSE2 load_be(const void* in)
@@ -71,7 +71,7 @@ class SIMD_SSE2
SIMD_SSE2 operator+(const SIMD_SSE2& other) const
{
- return _mm_add_epi32(m_reg, other.m_reg);
+ return SIMD_SSE2(_mm_add_epi32(m_reg, other.m_reg));
}
void operator-=(const SIMD_SSE2& other)
@@ -81,7 +81,7 @@ class SIMD_SSE2
SIMD_SSE2 operator-(const SIMD_SSE2& other) const
{
- return _mm_sub_epi32(m_reg, other.m_reg);
+ return SIMD_SSE2(_mm_sub_epi32(m_reg, other.m_reg));
}
void operator^=(const SIMD_SSE2& other)
@@ -91,7 +91,7 @@ class SIMD_SSE2
SIMD_SSE2 operator^(const SIMD_SSE2& other) const
{
- return _mm_xor_si128(m_reg, other.m_reg);
+ return SIMD_SSE2(_mm_xor_si128(m_reg, other.m_reg));
}
void operator|=(const SIMD_SSE2& other)
@@ -101,7 +101,7 @@ class SIMD_SSE2
SIMD_SSE2 operator&(const SIMD_SSE2& other)
{
- return _mm_and_si128(m_reg, other.m_reg);
+ return SIMD_SSE2(_mm_and_si128(m_reg, other.m_reg));
}
void operator&=(const SIMD_SSE2& other)
@@ -111,23 +111,23 @@ class SIMD_SSE2
SIMD_SSE2 operator<<(size_t shift) const
{
- return _mm_slli_epi32(m_reg, static_cast<int>(shift));
+ return SIMD_SSE2(_mm_slli_epi32(m_reg, static_cast<int>(shift)));
}
SIMD_SSE2 operator>>(size_t shift) const
{
- return _mm_srli_epi32(m_reg, static_cast<int>(shift));
+ return SIMD_SSE2(_mm_srli_epi32(m_reg, static_cast<int>(shift)));
}
SIMD_SSE2 operator~() const
{
- return _mm_xor_si128(m_reg, _mm_set1_epi32(0xFFFFFFFF));
+ return SIMD_SSE2(_mm_xor_si128(m_reg, _mm_set1_epi32(0xFFFFFFFF)));
}
// (~reg) & other
SIMD_SSE2 andc(const SIMD_SSE2& other)
{
- return _mm_andnot_si128(m_reg, other.m_reg);
+ return SIMD_SSE2(_mm_andnot_si128(m_reg, other.m_reg));
}
SIMD_SSE2 bswap() const
@@ -137,8 +137,8 @@ class SIMD_SSE2
T = _mm_shufflehi_epi16(T, _MM_SHUFFLE(2, 3, 0, 1));
T = _mm_shufflelo_epi16(T, _MM_SHUFFLE(2, 3, 0, 1));
- return _mm_or_si128(_mm_srli_epi16(T, 8),
- _mm_slli_epi16(T, 8));
+ return SIMD_SSE2(_mm_or_si128(_mm_srli_epi16(T, 8),
+ _mm_slli_epi16(T, 8)));
}
static void transpose(SIMD_SSE2& B0, SIMD_SSE2& B1,
@@ -155,7 +155,7 @@ class SIMD_SSE2
}
private:
- SIMD_SSE2(__m128i in) { m_reg = in; }
+ explicit SIMD_SSE2(__m128i in) { m_reg = in; }
__m128i m_reg;
};