Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

clang-tidy fixes for Linux/OpenSSL #3407

Merged
merged 2 commits into from
Jan 23, 2025
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion cpp/include/Ice/Proxy.h
Original file line number Diff line number Diff line change
@@ -142,7 +142,7 @@ namespace Ice
*/
[[nodiscard]] Prx ice_encodingVersion(EncodingVersion version) const
{
return fromReference(asPrx()._encodingVersion(std::move(version)));
return fromReference(asPrx()._encodingVersion(version));
}

/**
2 changes: 1 addition & 1 deletion cpp/src/Ice/DynamicLibrary.cpp
Original file line number Diff line number Diff line change
@@ -144,7 +144,7 @@ IceInternal::DynamicLibrary::loadEntryPoint(const string& entryPoint, bool useIc
#else
if (!load(lib))
{
return 0;
return nullptr;
}
#endif

2 changes: 1 addition & 1 deletion cpp/src/Ice/ObjectAdapterFactory.cpp
Original file line number Diff line number Diff line change
@@ -116,7 +116,7 @@ ObjectAdapterPtr
IceInternal::ObjectAdapterFactory::createObjectAdapter(
string name, // NOLINT(performance-unnecessary-value-param)
optional<Ice::RouterPrx> router,
optional<SSL::ServerAuthenticationOptions> serverAuthenticationOptions)
optional<Ice::SSL::ServerAuthenticationOptions> serverAuthenticationOptions)
{
shared_ptr<ObjectAdapterI> adapter;
{
14 changes: 7 additions & 7 deletions cpp/src/Ice/SSL/OpenSSLEngine.cpp
Original file line number Diff line number Diff line change
@@ -36,7 +36,7 @@ extern "C"
{
int Ice_SSL_opensslPasswordCallback(char* buf, int size, int /*flag*/, void* userData)
{
OpenSSL::SSLEngine* p = reinterpret_cast<OpenSSL::SSLEngine*>(userData);
auto* p = reinterpret_cast<OpenSSL::SSLEngine*>(userData);
assert(p);
string passwd = p->password();
int sz = static_cast<int>(passwd.size());
@@ -47,9 +47,9 @@ extern "C"
strncpy(buf, passwd.c_str(), sz);
buf[sz] = '\0';

for (string::iterator i = passwd.begin(); i != passwd.end(); ++i)
for (auto& character : passwd)
{
*i = '\0';
character = '\0';
}

return sz;
@@ -176,7 +176,7 @@ OpenSSL::SSLEngine::initialize()
int success = 0;

const unsigned char* b = reinterpret_cast<unsigned char*>(&buffer[0]);
PKCS12* p12 = d2i_PKCS12(0, &b, static_cast<long>(buffer.size()));
PKCS12* p12 = d2i_PKCS12(nullptr, &b, static_cast<long>(buffer.size()));
if (p12)
{
EVP_PKEY* key = nullptr;
@@ -225,7 +225,7 @@ OpenSSL::SSLEngine::initialize()
// Pop each cert from the stack so we can free the stack later.
// The CTX destruction will take care of the certificates
X509* c = nullptr;
while ((c = sk_X509_pop(chain)) != 0)
while ((c = sk_X509_pop(chain)))
{
if (!SSL_CTX_add_extra_chain_cert(_ctx, c))
{
@@ -429,7 +429,7 @@ OpenSSL::SSLEngine::createClientAuthenticationOptions(const std::string&) const
}
}
}
SSL_set_verify(ssl, SSL_VERIFY_PEER | SSL_VERIFY_FAIL_IF_NO_PEER_CERT, 0);
SSL_set_verify(ssl, SSL_VERIFY_PEER | SSL_VERIFY_FAIL_IF_NO_PEER_CERT, nullptr);
},
.serverCertificateValidationCallback =
[this](bool ok, X509_STORE_CTX* ctx, const Ice::SSL::ConnectionInfoPtr& info)
@@ -464,7 +464,7 @@ OpenSSL::SSLEngine::createServerAuthenticationOptions() const
sslVerifyMode = SSL_VERIFY_PEER | SSL_VERIFY_FAIL_IF_NO_PEER_CERT;
break;
}
SSL_set_verify(ssl, sslVerifyMode, 0);
SSL_set_verify(ssl, sslVerifyMode, nullptr);
},
.clientCertificateValidationCallback =
[this](bool ok, X509_STORE_CTX* ctx, const Ice::SSL::ConnectionInfoPtr& info)
34 changes: 17 additions & 17 deletions cpp/src/Ice/SSL/OpenSSLTransceiverI.cpp
Original file line number Diff line number Diff line change
@@ -26,8 +26,8 @@ extern "C"
{
int Ice_SSL_opensslVerifyCallback(int ok, X509_STORE_CTX* ctx)
{
::SSL* ssl = reinterpret_cast<::SSL*>(X509_STORE_CTX_get_ex_data(ctx, SSL_get_ex_data_X509_STORE_CTX_idx()));
OpenSSL::TransceiverI* p = reinterpret_cast<OpenSSL::TransceiverI*>(SSL_get_ex_data(ssl, 0));
auto* ssl = reinterpret_cast<::SSL*>(X509_STORE_CTX_get_ex_data(ctx, SSL_get_ex_data_X509_STORE_CTX_idx()));
auto* p = reinterpret_cast<OpenSSL::TransceiverI*>(SSL_get_ex_data(ssl, 0));
return p->verifyCallback(ok, ctx);
}
}
@@ -257,7 +257,7 @@ OpenSSL::TransceiverI::initialize(IceInternal::Buffer& readBuffer, IceInternal::
else
{
out << "cipher = " << SSL_CIPHER_get_name(cipher) << "\n";
out << "bits = " << SSL_CIPHER_get_bits(cipher, 0) << "\n";
out << "bits = " << SSL_CIPHER_get_bits(cipher, nullptr) << "\n";
out << "protocol = " << SSL_get_version(_ssl) << "\n";
}
out << toString();
@@ -678,16 +678,16 @@ OpenSSL::TransceiverI::verifyCallback(int ok, X509_STORE_CTX* ctx)
}

OpenSSL::TransceiverI::TransceiverI(
const InstancePtr& instance,
const IceInternal::TransceiverPtr& delegate,
const string& adapterName,
InstancePtr instance,
IceInternal::TransceiverPtr delegate,
string adapterName,
const ServerAuthenticationOptions& serverAuthenticationOptions)
: _instance(instance),
_engine(dynamic_pointer_cast<OpenSSL::SSLEngine>(instance->engine())),
: _instance(std::move(instance)),
_engine(dynamic_pointer_cast<OpenSSL::SSLEngine>(_instance->engine())),
_host(""),
_adapterName(adapterName),
_adapterName(std::move(adapterName)),
_incoming(true),
_delegate(delegate),
_delegate(std::move(delegate)),
_connected(false),
_peerCertificate(nullptr),
_ssl(nullptr),
@@ -709,16 +709,16 @@ OpenSSL::TransceiverI::TransceiverI(
}

OpenSSL::TransceiverI::TransceiverI(
const InstancePtr& instance,
const IceInternal::TransceiverPtr& delegate,
const string& host,
InstancePtr instance,
IceInternal::TransceiverPtr delegate,
string host,
const ClientAuthenticationOptions& clientAuthenticationOptions)
: _instance(instance),
_engine(dynamic_pointer_cast<OpenSSL::SSLEngine>(instance->engine())),
_host(host),
: _instance(std::move(instance)),
_engine(dynamic_pointer_cast<OpenSSL::SSLEngine>(_instance->engine())),
_host(std::move(host)),
_adapterName(""),
_incoming(false),
_delegate(delegate),
_delegate(std::move(delegate)),
_connected(false),
_peerCertificate(nullptr),
_ssl(nullptr),
16 changes: 8 additions & 8 deletions cpp/src/Ice/SSL/OpenSSLTransceiverI.h
Original file line number Diff line number Diff line change
@@ -15,23 +15,23 @@

#include <openssl/ssl.h>

typedef struct ssl_st SSL;
typedef struct bio_st BIO;
using SSL = struct ssl_st;
using BIO = struct bio_st;

namespace Ice::SSL::OpenSSL
{
class TransceiverI final : public IceInternal::Transceiver
{
public:
TransceiverI(
const InstancePtr&,
const IceInternal::TransceiverPtr&,
const std::string&,
InstancePtr,
IceInternal::TransceiverPtr,
std::string,
const Ice::SSL::ServerAuthenticationOptions&);
TransceiverI(
const InstancePtr&,
const IceInternal::TransceiverPtr&,
const std::string&,
InstancePtr,
IceInternal::TransceiverPtr,
std::string,
const Ice::SSL::ClientAuthenticationOptions&);

~TransceiverI();
4 changes: 2 additions & 2 deletions cpp/src/Ice/SSL/SSLUtil.cpp
Original file line number Diff line number Diff line change
@@ -480,7 +480,7 @@ namespace
vector<pair<int, string>> convertGeneralNames(GENERAL_NAMES* gens)
{
vector<pair<int, string>> alt;
if (gens == 0)
if (gens == nullptr)
{
return alt;
}
@@ -639,7 +639,7 @@ vector<pair<int, string>>
Ice::SSL::getSubjectAltNames(X509* certificate)
{
return convertGeneralNames(
reinterpret_cast<GENERAL_NAMES*>(X509_get_ext_d2i(certificate, NID_subject_alt_name, 0, 0)));
reinterpret_cast<GENERAL_NAMES*>(X509_get_ext_d2i(certificate, NID_subject_alt_name, nullptr, nullptr)));
}

string
2 changes: 1 addition & 1 deletion cpp/src/Ice/SSL/SSLUtil.h
Original file line number Diff line number Diff line change
@@ -92,7 +92,7 @@ namespace Ice::SSL
public:
ScopedCertificate(X509* certificate) : _certificate(certificate) {}
~ScopedCertificate();
X509* get() const { return _certificate; }
[[nodiscard]] X509* get() const { return _certificate; }

private:
X509* _certificate;
8 changes: 4 additions & 4 deletions cpp/src/Ice/Selector.cpp
Original file line number Diff line number Diff line change
@@ -190,7 +190,7 @@ Selector::Selector(InstancePtr instance) : _instance(std::move(instance)), _inte

epoll_event event;
memset(&event, 0, sizeof(epoll_event));
event.data.ptr = 0;
event.data.ptr = nullptr;
event.events = EPOLLIN;
if (epoll_ctl(_queueFd, EPOLL_CTL_ADD, _fdIntrRead, &event) != 0)
{
@@ -296,8 +296,8 @@ Selector::enable(EventHandler* handler, SocketOperation status)
{
# if defined(ICE_USE_EPOLL)
SOCKET fd = nativeInfo->fd();
SocketOperation previous = static_cast<SocketOperation>(handler->_registered & ~(handler->_disabled | status));
SocketOperation newStatus = static_cast<SocketOperation>(handler->_registered & ~handler->_disabled);
auto previous = static_cast<SocketOperation>(handler->_registered & ~(handler->_disabled | status));
auto newStatus = static_cast<SocketOperation>(handler->_registered & ~handler->_disabled);
epoll_event event;
memset(&event, 0, sizeof(epoll_event));
event.data.ptr = handler;
@@ -351,7 +351,7 @@ Selector::disable(EventHandler* handler, SocketOperation status)
{
# if defined(ICE_USE_EPOLL)
SOCKET fd = nativeInfo->fd();
SocketOperation newStatus = static_cast<SocketOperation>(handler->_registered & ~handler->_disabled);
auto newStatus = static_cast<SocketOperation>(handler->_registered & ~handler->_disabled);
epoll_event event;
memset(&event, 0, sizeof(epoll_event));
event.data.ptr = handler;
2 changes: 1 addition & 1 deletion cpp/src/Ice/WSEndpoint.cpp
Original file line number Diff line number Diff line change
@@ -234,7 +234,7 @@ IceInternal::WSEndpoint::connectorsAsync(
AcceptorPtr
IceInternal::WSEndpoint::acceptor(
const string& adapterName,
const optional<SSL::ServerAuthenticationOptions>& serverAuthenticationOptions) const
const optional<Ice::SSL::ServerAuthenticationOptions>& serverAuthenticationOptions) const
{
AcceptorPtr acceptor = _delegate->acceptor(adapterName, serverAuthenticationOptions);
return make_shared<WSAcceptor>(const_cast<WSEndpoint*>(this)->shared_from_this(), _instance, acceptor);