Skip to content

Commit c4f937d

Browse files
authored
Merge pull request #4957 from randombit/jack/fix-clang-tidy-hicpp-explicit-conversions
Enable and fix clang-tidy hicpp-explicit-conversions warning
2 parents bdd1584 + 1850a83 commit c4f937d

87 files changed

Lines changed: 175 additions & 150 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

src/.clang-tidy

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@ Checks: >
2525
-cppcoreguidelines-init-variables,
2626
-cppcoreguidelines-owning-memory,
2727
-cppcoreguidelines-prefer-member-initializer,
28-
-hicpp-explicit-conversions,
2928
-misc-const-correctness,
3029
-misc-include-cleaner,
3130
-misc-redundant-expression,

src/bogo_shim/bogo_shim.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -347,7 +347,7 @@ std::string map_to_bogo_error(const std::string& e) noexcept {
347347

348348
class Shim_Exception final : public std::exception {
349349
public:
350-
Shim_Exception(std::string_view msg, int rc = 1) : m_msg(msg), m_rc(rc) {}
350+
explicit Shim_Exception(std::string_view msg, int rc = 1) : m_msg(msg), m_rc(rc) {}
351351

352352
const char* what() const noexcept override { return m_msg.c_str(); }
353353

@@ -866,7 +866,7 @@ std::unique_ptr<Shim_Arguments> parse_options(char* argv[]) {
866866

867867
class Shim_Policy final : public Botan::TLS::Policy {
868868
public:
869-
Shim_Policy(const Shim_Arguments& args) : m_args(args), m_sessions(0) {}
869+
explicit Shim_Policy(const Shim_Arguments& args) : m_args(args), m_sessions(0) {}
870870

871871
void incr_session_established() { m_sessions += 1; }
872872

@@ -1244,7 +1244,7 @@ std::vector<uint16_t> Shim_Policy::ciphersuite_list(Botan::TLS::Protocol_Version
12441244

12451245
class Shim_Credentials final : public Botan::Credentials_Manager {
12461246
public:
1247-
Shim_Credentials(const Shim_Arguments& args) : m_args(args) {
1247+
explicit Shim_Credentials(const Shim_Arguments& args) : m_args(args) {
12481248
const auto psk_identity = m_args.get_string_opt_or_else("psk-identity", "");
12491249
const auto psk_str = m_args.get_string_opt_or_else("psk", "");
12501250

src/cli/perf_sym.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ namespace Botan_CLI {
4040
#if defined(BOTAN_HAS_BLOCK_CIPHER)
4141
class PerfTest_BlockCipher final : public PerfTest {
4242
public:
43-
PerfTest_BlockCipher(std::string_view alg) : m_alg(alg) {}
43+
explicit PerfTest_BlockCipher(std::string_view alg) : m_alg(alg) {}
4444

4545
void go(const PerfConfig& config) override {
4646
for(const auto& provider : Botan::BlockCipher::providers(m_alg)) {
@@ -104,7 +104,7 @@ class PerfTest_BlockCipher final : public PerfTest {
104104
#if defined(BOTAN_HAS_CIPHER_MODES)
105105
class PerfTest_CipherMode final : public PerfTest {
106106
public:
107-
PerfTest_CipherMode(std::string_view alg) : m_alg(alg) {}
107+
explicit PerfTest_CipherMode(std::string_view alg) : m_alg(alg) {}
108108

109109
void go(const PerfConfig& config) override {
110110
for(const auto& provider : Botan::Cipher_Mode::providers(m_alg)) {
@@ -184,7 +184,7 @@ class PerfTest_CipherMode final : public PerfTest {
184184
#if defined(BOTAN_HAS_STREAM_CIPHER)
185185
class PerfTest_StreamCipher final : public PerfTest {
186186
public:
187-
PerfTest_StreamCipher(std::string_view alg) : m_alg(alg) {}
187+
explicit PerfTest_StreamCipher(std::string_view alg) : m_alg(alg) {}
188188

189189
void go(const PerfConfig& config) override {
190190
for(const auto& provider : Botan::StreamCipher::providers(m_alg)) {
@@ -247,7 +247,7 @@ class PerfTest_StreamCipher final : public PerfTest {
247247
#if defined(BOTAN_HAS_HASH)
248248
class PerfTest_HashFunction final : public PerfTest {
249249
public:
250-
PerfTest_HashFunction(std::string_view alg) : m_alg(alg) {}
250+
explicit PerfTest_HashFunction(std::string_view alg) : m_alg(alg) {}
251251

252252
void go(const PerfConfig& config) override {
253253
for(const auto& provider : Botan::HashFunction::providers(m_alg)) {
@@ -288,7 +288,7 @@ class PerfTest_HashFunction final : public PerfTest {
288288
#if defined(BOTAN_HAS_MAC)
289289
class PerfTest_MessageAuthenticationCode final : public PerfTest {
290290
public:
291-
PerfTest_MessageAuthenticationCode(std::string_view alg) : m_alg(alg) {}
291+
explicit PerfTest_MessageAuthenticationCode(std::string_view alg) : m_alg(alg) {}
292292

293293
void go(const PerfConfig& config) override {
294294
for(const auto& provider : Botan::MessageAuthenticationCode::providers(m_alg)) {
@@ -339,7 +339,7 @@ class PerfTest_MessageAuthenticationCode final : public PerfTest {
339339
#if defined(BOTAN_HAS_XOF)
340340
class PerfTest_XOF final : public PerfTest {
341341
public:
342-
PerfTest_XOF(std::string_view alg) : m_alg(alg) {}
342+
explicit PerfTest_XOF(std::string_view alg) : m_alg(alg) {}
343343

344344
void go(const PerfConfig& config) override {
345345
for(const auto& provider : Botan::XOF::providers(m_alg)) {

src/cli/psk.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,6 @@ namespace Botan_CLI {
1616

1717
class PSK_Tool_Base : public Command {
1818
public:
19-
PSK_Tool_Base(const std::string& spec) : Command(spec) {}
20-
2119
std::string group() const override { return "psk"; }
2220

2321
void go() override {
@@ -31,6 +29,9 @@ class PSK_Tool_Base : public Command {
3129
psk_operation(psk);
3230
}
3331

32+
protected:
33+
explicit PSK_Tool_Base(const std::string& spec) : Command(spec) {}
34+
3435
private:
3536
virtual void psk_operation(Botan::PSK_Database& db) = 0;
3637
};

src/cli/timer.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ class Timer final {
2323
double clock_cycle_ratio,
2424
uint64_t clock_speed);
2525

26-
Timer(std::string_view name) : Timer(name, "", "", 1, 0, 0.0, 0) {}
26+
explicit Timer(std::string_view name) : Timer(name, "", "", 1, 0, 0.0, 0) {}
2727

2828
Timer(std::string_view name, size_t buf_size) : Timer(name, "", "", buf_size, buf_size, 0.0, 0) {}
2929

src/cli/tls_client.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ namespace {
4242

4343
class Callbacks : public Botan::TLS::Callbacks {
4444
public:
45-
Callbacks(TLS_Client& client_command) : m_client_command(client_command), m_peer_closed(false) {}
45+
explicit Callbacks(TLS_Client& client_command) : m_client_command(client_command), m_peer_closed(false) {}
4646

4747
std::ostream& output();
4848
bool flag_set(const std::string& flag_name) const;

src/cli/tls_server.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ namespace {
5151

5252
class Callbacks : public Botan::TLS::Callbacks {
5353
public:
54-
Callbacks(TLS_Server& server_command) : m_server_command(server_command) {}
54+
explicit Callbacks(TLS_Server& server_command) : m_server_command(server_command) {}
5555

5656
std::ostream& output();
5757
void send(std::span<const uint8_t> buffer);

src/examples/fpe_dictionary.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
class Dictionary {
88
public:
9-
Dictionary(const std::string& filename) {
9+
explicit Dictionary(const std::string& filename) {
1010
std::ifstream in(filename);
1111

1212
while(in.good()) {

src/examples/tls_ssl_key_log_file.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ class BotanTLSCallbacksProxy : public Botan::TLS::Callbacks {
111111
Botan::TLS::Callbacks& parent;
112112

113113
public:
114-
BotanTLSCallbacksProxy(Botan::TLS::Callbacks& callbacks) : parent(callbacks) {}
114+
explicit BotanTLSCallbacksProxy(Botan::TLS::Callbacks& callbacks) : parent(callbacks) {}
115115

116116
void tls_emit_data(std::span<const uint8_t> data) override { parent.tls_emit_data(data); }
117117

src/examples/tls_stream_client.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ class client {
4444
std::make_shared<Botan::AutoSeeded_RNG>(),
4545
std::make_shared<Botan::TLS::Session_Manager_Noop>(),
4646
std::make_shared<Botan::TLS::Policy>(),
47-
host)),
47+
Botan::TLS::Server_Information(host))),
4848
m_stream(io_context, m_ctx) {
4949
boost::asio::async_connect(m_stream.lowest_layer(),
5050
endpoints.begin(),

0 commit comments

Comments
 (0)