From 410837526c940f5ad1c84d60960cdbcb40d97019 Mon Sep 17 00:00:00 2001 From: Popkornium18 Date: Wed, 1 Jul 2020 23:52:34 +0200 Subject: [PATCH 1/6] REFAC(server): replace NULL with nullptr This changes all occurances of NULL in the murmur source dir to nullptr. Additionally explicit comparisons with NULL were removed. --- src/murmur/BonjourServer.cpp | 4 ++-- src/murmur/Cert.cpp | 12 +++++----- src/murmur/DBus.cpp | 12 +++++----- src/murmur/Messages.cpp | 14 ++++++------ src/murmur/Meta.cpp | 12 +++++----- src/murmur/Meta.h | 2 +- src/murmur/MurmurGRPCImpl.cpp | 6 ++--- src/murmur/MurmurIce.cpp | 24 ++++++++++---------- src/murmur/PBKDF2.cpp | 4 ++-- src/murmur/Server.cpp | 42 +++++++++++++++++------------------ src/murmur/Server.h | 16 ++++++------- src/murmur/ServerDB.cpp | 8 +++---- src/murmur/ServerUser.cpp | 2 +- src/murmur/Tray.cpp | 6 ++--- src/murmur/UnixMurmur.cpp | 12 +++++----- src/murmur/main.cpp | 28 +++++++++++------------ 16 files changed, 102 insertions(+), 102 deletions(-) diff --git a/src/murmur/BonjourServer.cpp b/src/murmur/BonjourServer.cpp index 97a53a186..de54465a4 100644 --- a/src/murmur/BonjourServer.cpp +++ b/src/murmur/BonjourServer.cpp @@ -8,13 +8,13 @@ #include "BonjourServiceRegister.h" BonjourServer::BonjourServer() { - bsrRegister = NULL; + bsrRegister = nullptr; #ifdef Q_OS_WIN static bool bDelayLoadFailed = false; if (bDelayLoadFailed) return; HMODULE hLib = LoadLibrary(L"DNSSD.DLL"); - if (hLib == NULL) { + if (!hLib) { bDelayLoadFailed = true; qWarning("Bonjour: Failed to load dnssd.dll"); return; diff --git a/src/murmur/Cert.cpp b/src/murmur/Cert.cpp index 17ceab5f6..52adf638c 100644 --- a/src/murmur/Cert.cpp +++ b/src/murmur/Cert.cpp @@ -28,20 +28,20 @@ bool Server::isKeyForCert(const QSslKey &key, const QSslCertificate &cert) { QByteArray qbaKey = key.toDer(); QByteArray qbaCert = cert.toDer(); - X509 *x509 = NULL; - EVP_PKEY *pkey = NULL; - BIO *mem = NULL; + X509 *x509 = nullptr; + EVP_PKEY *pkey = nullptr; + BIO *mem = nullptr; mem = BIO_new_mem_buf(qbaKey.data(), qbaKey.size()); Q_UNUSED(BIO_set_close(mem, BIO_NOCLOSE)); - pkey = d2i_PrivateKey_bio(mem, NULL); + pkey = d2i_PrivateKey_bio(mem, nullptr); BIO_free(mem); mem = BIO_new_mem_buf(qbaCert.data(), qbaCert.size()); Q_UNUSED(BIO_set_close(mem, BIO_NOCLOSE)); - x509 = d2i_X509_bio(mem, NULL); + x509 = d2i_X509_bio(mem, nullptr); BIO_free(mem); - mem = NULL; + mem = nullptr; if (x509 && pkey && X509_check_private_key(x509, pkey)) { EVP_PKEY_free(pkey); diff --git a/src/murmur/DBus.cpp b/src/murmur/DBus.cpp index fdd486ce3..db00c3d50 100644 --- a/src/murmur/DBus.cpp +++ b/src/murmur/DBus.cpp @@ -169,7 +169,7 @@ void MurmurDBus::registerTypes() { qDBusRegisterMetaType >(); } -QDBusConnection *MurmurDBus::qdbc = NULL; +QDBusConnection *MurmurDBus::qdbc = nullptr; MurmurDBus::MurmurDBus(Server *srv) : QDBusAbstractAdaptor(srv) { server = srv; @@ -299,7 +299,7 @@ void MurmurDBus::authenticateSlot(int &res, QString &uname, int sessionId, const } } if (ok && (msg.arguments().count() >= 3)) { - server->setTempGroups(uid, sessionId, NULL, msg.arguments().at(2).toStringList()); + server->setTempGroups(uid, sessionId, nullptr, msg.arguments().at(2).toStringList()); } if (ok) { server->log(QString("DBus Authenticate success for %1: %2").arg(uname).arg(uid)); @@ -380,13 +380,13 @@ void MurmurDBus::setPlayerState(const PlayerInfo &npi, const QDBusMessage &msg) void MurmurDBus::sendMessage(unsigned int session, const QString &text, const QDBusMessage &msg) { PLAYER_SETUP; - server->sendTextMessage(NULL, pUser, false, text); + server->sendTextMessage(nullptr, pUser, false, text); } void MurmurDBus::sendMessageChannel(int id, bool tree, const QString &text, const QDBusMessage &msg) { CHANNEL_SETUP_VAR(id); - server->sendTextMessage(cChannel, NULL, tree, text); + server->sendTextMessage(cChannel, nullptr, tree, text); } void MurmurDBus::addChannel(const QString &name, int chanparent, const QDBusMessage &msg, int &newid) { @@ -454,7 +454,7 @@ void MurmurDBus::getACL(int id, const QDBusMessage &msg, QList &acls, Q if ((p == cChannel) || (p->bInheritACL)) p = p->cParent; else - p =NULL; + p =nullptr; } inherit = cChannel->bInheritACL; @@ -476,7 +476,7 @@ void MurmurDBus::getACL(int id, const QDBusMessage &msg, QList &acls, Q QString name; foreach(name, allnames) { Group *g = cChannel->qhGroups.value(name); - Group *pg = p ? Group::getGroup(p, name) : NULL; + Group *pg = p ? Group::getGroup(p, name) : nullptr; if (!g && ! pg) continue; GroupInfo gi(g ? g : pg); diff --git a/src/murmur/Messages.cpp b/src/murmur/Messages.cpp index dfabd73eb..3a72bbb66 100644 --- a/src/murmur/Messages.cpp +++ b/src/murmur/Messages.cpp @@ -213,7 +213,7 @@ void Server::msgAuthenticate(ServerUser *uSource, MumbleProto::Authenticate &msg ok = true; } - ServerUser *uOld = NULL; + ServerUser *uOld = nullptr; foreach(ServerUser *u, qhUsers) { if (u == uSource) continue; @@ -320,7 +320,7 @@ void Server::msgAuthenticate(ServerUser *uSource, MumbleProto::Authenticate &msg sendMessage(uSource, mpcv); if (!bOpus && uSource->bOpus && fake_celt_support) { - sendTextMessage(NULL, uSource, false, QLatin1String("WARNING: Your client doesn't support the CELT codec, you won't be able to talk to or hear most clients. Please make sure your client was built with CELT support.")); + sendTextMessage(nullptr, uSource, false, QLatin1String("WARNING: Your client doesn't support the CELT codec, you won't be able to talk to or hear most clients. Please make sure your client was built with CELT support.")); } // Transmit channel tree @@ -1032,8 +1032,8 @@ void Server::msgUserRemove(ServerUser *uSource, MumbleProto::UserRemove &msg) { void Server::msgChannelState(ServerUser *uSource, MumbleProto::ChannelState &msg) { MSG_SETUP(ServerUser::Authenticated); - Channel *c = NULL; - Channel *p = NULL; + Channel *c = nullptr; + Channel *p = nullptr; // If this message relates to an existing channel check if the id is really valid if (msg.has_channel_id()) { @@ -1534,7 +1534,7 @@ void Server::msgACL(ServerUser *uSource, MumbleProto::ACL &msg) { if ((p==c) || p->bInheritACL) p = p->cParent; else - p = NULL; + p = nullptr; } while (! chans.isEmpty()) { @@ -1561,13 +1561,13 @@ void Server::msgACL(ServerUser *uSource, MumbleProto::ACL &msg) { QSet allnames=Group::groupNames(c); foreach(const QString &name, allnames) { Group *g = c->qhGroups.value(name); - Group *pg = p ? Group::getGroup(p, name) : NULL; + Group *pg = p ? Group::getGroup(p, name) : nullptr; MumbleProto::ACL_ChanGroup *group = msg.add_groups(); group->set_name(u8(name)); group->set_inherit(g ? g->bInherit : true); group->set_inheritable(g ? g->bInheritable : true); - group->set_inherited((pg != NULL) && pg->bInheritable); + group->set_inherited(pg && pg->bInheritable); if (g) { foreach(int id, g->qsAdd) { qsId.insert(id); diff --git a/src/murmur/Meta.cpp b/src/murmur/Meta.cpp index a408c516d..b36c7f1c2 100644 --- a/src/murmur/Meta.cpp +++ b/src/murmur/Meta.cpp @@ -43,7 +43,7 @@ MetaParams Meta::mp; #ifdef Q_OS_WIN -HANDLE Meta::hQoS = NULL; +HANDLE Meta::hQoS = nullptr; #endif MetaParams::MetaParams() { @@ -104,7 +104,7 @@ MetaParams::MetaParams() { bLogGroupChanges = false; bLogACLChanges = false; - qsSettings = NULL; + qsSettings = nullptr; } MetaParams::~MetaParams() { @@ -129,7 +129,7 @@ template T MetaParams::typeCheckedFromSettings(const QString &name, const T &defaultValue, QSettings *settings) { // Use qsSettings unless a specific QSettings instance // is requested. - if (settings == NULL) { + if (!settings) { settings = qsSettings; } @@ -648,10 +648,10 @@ Meta::Meta() { qvVer.MajorVersion = 1; qvVer.MinorVersion = 0; - hQoS = NULL; + hQoS = nullptr; HMODULE hLib = LoadLibrary(L"qWave.dll"); - if (hLib == NULL) { + if (!hLib) { qWarning("Meta: Failed to load qWave.dll, no QoS available"); } else { FreeLibrary(hLib); @@ -667,7 +667,7 @@ Meta::~Meta() { #ifdef Q_OS_WIN if (hQoS) { QOSCloseHandle(hQoS); - Connection::setQoS(NULL); + Connection::setQoS(nullptr); } #endif } diff --git a/src/murmur/Meta.h b/src/murmur/Meta.h index 9720180fb..6fd4c951d 100644 --- a/src/murmur/Meta.h +++ b/src/murmur/Meta.h @@ -162,7 +162,7 @@ public: private: template - T typeCheckedFromSettings(const QString &name, const T &variable, QSettings *settings = NULL); + T typeCheckedFromSettings(const QString &name, const T &variable, QSettings *settings = nullptr); }; class Meta : public QObject { diff --git a/src/murmur/MurmurGRPCImpl.cpp b/src/murmur/MurmurGRPCImpl.cpp index cb275062c..a555bccd1 100644 --- a/src/murmur/MurmurGRPCImpl.cpp +++ b/src/murmur/MurmurGRPCImpl.cpp @@ -531,7 +531,7 @@ void MurmurRPCImpl::authenticateSlot(int &res, QString &uname, int sessionId, co } } if (!qsl.isEmpty()) { - s->setTempGroups(res, sessionId, NULL, qsl); + s->setTempGroups(res, sessionId, nullptr, qsl); } } break; @@ -1856,7 +1856,7 @@ void V1_ACLGet::impl(bool) { if ((p == channel) || p->bInheritACL) { p = p->cParent; } else { - p = NULL; + p = nullptr; } } @@ -1877,7 +1877,7 @@ void V1_ACLGet::impl(bool) { const QSet allnames = ::Group::groupNames(channel); foreach(const QString &name, allnames) { ::Group *g = channel->qhGroups.value(name); - ::Group *pg = p ? ::Group::getGroup(p, name) : NULL; + ::Group *pg = p ? ::Group::getGroup(p, name) : nullptr; if (!g && ! pg) { continue; } diff --git a/src/murmur/MurmurIce.cpp b/src/murmur/MurmurIce.cpp index 9597f95b9..76211f06a 100644 --- a/src/murmur/MurmurIce.cpp +++ b/src/murmur/MurmurIce.cpp @@ -34,7 +34,7 @@ using namespace std; using namespace Murmur; -static MurmurIce *mi = NULL; +static MurmurIce *mi = nullptr; static Ice::ObjectPtr iopServer; static Ice::PropertiesPtr ippProperties; @@ -48,7 +48,7 @@ void IceStart() { void IceStop() { delete mi; - mi = NULL; + mi = nullptr; } /// Remove all NUL bytes from |s|. @@ -294,10 +294,10 @@ MurmurIce::~MurmurIce() { communicator->shutdown(); communicator->waitForShutdown(); communicator->destroy(); - communicator=NULL; + communicator=nullptr; qWarning("MurmurIce: Shutdown complete"); } - iopServer = NULL; + iopServer = nullptr; } void MurmurIce::customEvent(QEvent *evt) { @@ -707,7 +707,7 @@ void MurmurIce::authenticateSlot(int &res, QString &uname, int sessionId, const qsl << u8(str); } if (! qsl.isEmpty()) - server->setTempGroups(res, sessionId, NULL, qsl); + server->setTempGroups(res, sessionId, nullptr, qsl); } } @@ -866,7 +866,7 @@ void ServerI::ice_ping(const Ice::Current ¤t) const { #define ACCESS_Server_isRunning_READ static void impl_Server_isRunning(const ::Murmur::AMD_Server_isRunningPtr cb, int server_id) { NEED_SERVER_EXISTS; - cb->ice_response(server != NULL); + cb->ice_response(server != nullptr); } static void impl_Server_start(const ::Murmur::AMD_Server_startPtr cb, int server_id) { @@ -1139,7 +1139,7 @@ static void impl_Server_sendMessage(const ::Murmur::AMD_Server_sendMessagePtr cb NEED_SERVER; NEED_PLAYER; - server->sendTextMessage(NULL, user, false, u8(text)); + server->sendTextMessage(nullptr, user, false, u8(text)); cb->ice_response(); } @@ -1250,7 +1250,7 @@ static void impl_Server_sendMessageChannel(const ::Murmur::AMD_Server_sendMessag NEED_SERVER; NEED_CHANNEL; - server->sendTextMessage(channel, NULL, tree, u8(text)); + server->sendTextMessage(channel, nullptr, tree, u8(text)); cb->ice_response(); } @@ -1268,7 +1268,7 @@ static void impl_Server_setChannelState(const ::Murmur::AMD_Server_setChannelSta int channelid = state.id; NEED_SERVER; NEED_CHANNEL; - ::Channel *np = NULL; + ::Channel *np = nullptr; if (channel->iId != 0) { NEED_CHANNEL_VAR(np, state.parent); } @@ -1347,7 +1347,7 @@ static void impl_Server_getACL(const ::Murmur::AMD_Server_getACLPtr cb, int serv if ((p == channel) || (p->bInheritACL)) p = p->cParent; else - p = NULL; + p = nullptr; } bool inherit = channel->bInheritACL; @@ -1369,7 +1369,7 @@ static void impl_Server_getACL(const ::Murmur::AMD_Server_getACLPtr cb, int serv const QSet allnames = ::Group::groupNames(channel); foreach(const QString &name, allnames) { ::Group *g = channel->qhGroups.value(name); - ::Group *pg = p ? ::Group::getGroup(p, name) : NULL; + ::Group *pg = p ? ::Group::getGroup(p, name) : nullptr; if (!g && ! pg) continue; ::Murmur::Group mg; @@ -1789,7 +1789,7 @@ static void impl_Meta_getSliceChecksums(const ::Murmur::AMD_Meta_getSliceChecksu static void impl_Meta_getServer(const ::Murmur::AMD_Meta_getServerPtr cb, const Ice::ObjectAdapterPtr adapter, ::Ice::Int id) { QList server_list = ServerDB::getAllServers(); if (! server_list.contains(id)) - cb->ice_response(NULL); + cb->ice_response(nullptr); else cb->ice_response(idToProxy(id, adapter)); } diff --git a/src/murmur/PBKDF2.cpp b/src/murmur/PBKDF2.cpp index 6a79f48d5..e7bc01619 100644 --- a/src/murmur/PBKDF2.cpp +++ b/src/murmur/PBKDF2.cpp @@ -98,7 +98,7 @@ QString PBKDF2::getHash(const QString &hexSalt, const QString &password, int ite iterationCount, EVP_sha384(), DERIVED_KEY_LENGTH, reinterpret_cast(hash.data())) == 0) { - qFatal("PBKDF2: PKCS5_PBKDF2_HMAC failed: %s", ERR_error_string(ERR_get_error(), NULL)); + qFatal("PBKDF2: PKCS5_PBKDF2_HMAC failed: %s", ERR_error_string(ERR_get_error(), nullptr)); return QString(); } @@ -110,7 +110,7 @@ QString PBKDF2::getSalt() { QByteArray salt(SALT_LENGTH, 0); if (RAND_bytes(reinterpret_cast(salt.data()), salt.size()) != 1) { - qFatal("PBKDF2: RAND_bytes for salt failed: %s", ERR_error_string(ERR_get_error(), NULL)); + qFatal("PBKDF2: RAND_bytes for salt failed: %s", ERR_error_string(ERR_get_error(), nullptr)); return QString(); } diff --git a/src/murmur/Server.cpp b/src/murmur/Server.cpp index 141cc691e..1ddcebe5d 100644 --- a/src/murmur/Server.cpp +++ b/src/murmur/Server.cpp @@ -85,7 +85,7 @@ bool SslServer::hasDualStackSupport() { return false; } - SOCKET s = ::WSASocket(AF_INET6, SOCK_STREAM, IPPROTO_TCP, NULL, 0, WSA_FLAG_OVERLAPPED); + SOCKET s = ::WSASocket(AF_INET6, SOCK_STREAM, IPPROTO_TCP, nullptr, 0, WSA_FLAG_OVERLAPPED); if (s != INVALID_SOCKET) { const int ipv6only = 0; if (setsockopt(s, IPPROTO_IPV6, IPV6_V6ONLY, reinterpret_cast(&ipv6only), sizeof(ipv6only)) == 0) { @@ -106,7 +106,7 @@ void SslServer::incomingConnection(qintptr v) { QSslSocket *SslServer::nextPendingSSLConnection() { if (qlSockets.isEmpty()) - return NULL; + return nullptr; return qlSockets.takeFirst(); } @@ -114,14 +114,14 @@ Server::Server(int snum, QObject *p) : QThread(p) { bValid = true; iServerNum = snum; #ifdef USE_BONJOUR - bsRegistration = NULL; + bsRegistration = nullptr; #endif bUsingMetaCert = false; #ifdef Q_OS_UNIX aiNotify[0] = aiNotify[1] = -1; #else - hNotify = NULL; + hNotify = nullptr; #endif qtTimeout = new QTimer(this); @@ -129,7 +129,7 @@ Server::Server(int snum, QObject *p) : QThread(p) { bPreferAlpha = false; bOpus = true; - qnamNetwork = NULL; + qnamNetwork = nullptr; readParams(); initialize(); @@ -176,10 +176,10 @@ Server::Server(int snum, QObject *p) : QThread(p) { #ifndef SIO_UDP_CONNRESET #define SIO_UDP_CONNRESET _WSAIOW(IOC_VENDOR,12) #endif - SOCKET sock = ::WSASocket(addr.ss_family, SOCK_DGRAM, IPPROTO_UDP, NULL, 0, WSA_FLAG_OVERLAPPED); + SOCKET sock = ::WSASocket(addr.ss_family, SOCK_DGRAM, IPPROTO_UDP, nullptr, 0, WSA_FLAG_OVERLAPPED); DWORD dwBytesReturned = 0; BOOL bNewBehaviour = FALSE; - if (WSAIoctl(sock, SIO_UDP_CONNRESET, &bNewBehaviour, sizeof(bNewBehaviour), NULL, 0, &dwBytesReturned, NULL, NULL) == SOCKET_ERROR) { + if (WSAIoctl(sock, SIO_UDP_CONNRESET, &bNewBehaviour, sizeof(bNewBehaviour), nullptr, 0, &dwBytesReturned, nullptr, nullptr) == SOCKET_ERROR) { log(QString("Failed to set SIO_UDP_CONNRESET: %1").arg(WSAGetLastError())); } #endif @@ -241,7 +241,7 @@ Server::Server(int snum, QObject *p) : QThread(p) { return; } #else - hNotify = CreateEvent(NULL, FALSE, FALSE, NULL); + hNotify = CreateEvent(nullptr, FALSE, FALSE, nullptr); #endif connect(this, SIGNAL(tcpTransmit(QByteArray, unsigned int)), this, SLOT(tcpTransmitData(QByteArray, unsigned int)), Qt::QueuedConnection); @@ -642,7 +642,7 @@ void Server::initBonjour() { void Server::removeBonjour() { delete bsRegistration; - bsRegistration = NULL; + bsRegistration = nullptr; log("Stopped announcing server via bonjour"); } #endif @@ -738,7 +738,7 @@ void Server::run() { STACKVAR(HANDLE, events, nfds+1); for (int i=0;i &errors) { // Because abort() tears down a lot of internal state // of the QSslSocket, inlcuding the 'SSL *' object // associated with the socket, this is fatal and leads - // to crashes, such as attempting to derefernce a NULL + // to crashes, such as attempting to derefernce a nullptr // 'SSL *' object. // // To avoid this, we use a non-forceful disconnect @@ -1609,7 +1609,7 @@ void Server::connectionClosed(QAbstractSocket::SocketError err, const QString &r } void Server::message(unsigned int uiType, const QByteArray &qbaMsg, ServerUser *u) { - if (u == NULL) { + if (!u) { u = static_cast(sender()); } @@ -1726,7 +1726,7 @@ void Server::sendProtoMessage(ServerUser *u, const ::google::protobuf::Message & } void Server::sendProtoAll(const ::google::protobuf::Message &msg, unsigned int msgType, unsigned int version) { - sendProtoExcept(NULL, msg, msgType, version); + sendProtoExcept(nullptr, msg, msgType, version); } void Server::sendProtoExcept(ServerUser *u, const ::google::protobuf::Message &msg, unsigned int msgType, unsigned int version) { @@ -1747,12 +1747,12 @@ void Server::removeChannel(Channel *chan, Channel *dest) { Channel *c; User *p; - if (dest == NULL) + if (!dest) dest = chan->cParent; { QWriteLocker wl(&qrwlVoiceThread); - chan->unlink(NULL); + chan->unlink(nullptr); } foreach(c, chan->qlChannels) { @@ -1855,7 +1855,7 @@ void Server::userEnterChannel(User *p, Channel *c, MumbleProto::UserState &mpus) QWriteLocker wl(&qrwlVoiceThread); c->addUser(p); - bool mayspeak = ChanACL::hasPermission(static_cast(p), c, ChanACL::Speak, NULL); + bool mayspeak = ChanACL::hasPermission(static_cast(p), c, ChanACL::Speak, nullptr); bool sup = p->bSuppress; if (mayspeak == sup) { @@ -2076,7 +2076,7 @@ void Server::recheckCodecVersions(ServerUser *connectingUser) { iCodecBeta = version; } else if (bOpus == enableOpus) { if (bOpus && connectingUser && !connectingUser->bOpus) { - sendTextMessage(NULL, connectingUser, false, QLatin1String("WARNING: Your client doesn't support the Opus codec the server is using, you won't be able to talk or hear anyone. Please upgrade to a client with Opus support.")); + sendTextMessage(nullptr, connectingUser, false, QLatin1String("WARNING: Your client doesn't support the Opus codec the server is using, you won't be able to talk or hear anyone. Please upgrade to a client with Opus support.")); } return; } @@ -2096,7 +2096,7 @@ void Server::recheckCodecVersions(ServerUser *connectingUser) { // Only authenticated users and the currently connecting user (if recheck is called in that context) have a reliable u->bOpus. if((u->sState == ServerUser::Authenticated || u == connectingUser) && !u->bOpus) { - sendTextMessage(NULL, u, false, QLatin1String("WARNING: Your client doesn't support the Opus codec the server is switching to, you won't be able to talk or hear anyone. Please upgrade to a client with Opus support.")); + sendTextMessage(nullptr, u, false, QLatin1String("WARNING: Your client doesn't support the Opus codec the server is switching to, you won't be able to talk or hear anyone. Please upgrade to a client with Opus support.")); } } } diff --git a/src/murmur/Server.h b/src/murmur/Server.h index 92fc1d240..7f448713f 100644 --- a/src/murmur/Server.h +++ b/src/murmur/Server.h @@ -68,7 +68,7 @@ class SslServer : public QTcpServer { void incomingConnection(qintptr) Q_DECL_OVERRIDE; public: QSslSocket *nextPendingSSLConnection(); - SslServer(QObject *parent = NULL); + SslServer(QObject *parent = nullptr); /// Checks whether the AF_INET6 socket on this system has dual-stack support. static bool hasDualStackSupport(); @@ -199,7 +199,7 @@ class Server : public QThread { void newClient(); void connectionClosed(QAbstractSocket::SocketError, const QString &); void sslError(const QList &); - void message(unsigned int, const QByteArray &, ServerUser *cCon = NULL); + void message(unsigned int, const QByteArray &, ServerUser *cCon = nullptr); void checkTimeout(); void tcpTransmitData(QByteArray, unsigned int); void doSync(unsigned int); @@ -296,7 +296,7 @@ class Server : public QThread { QFlags effectivePermissions(ServerUser *p, Channel *c); void sendClientPermission(ServerUser *u, Channel *c, bool updatelast = false); void flushClientPermissionCache(ServerUser *u, MumbleProto::PermissionQuery &mpqq); - void clearACLCache(User *p = NULL); + void clearACLCache(User *p = nullptr); void clearWhisperTargetCache(); void sendProtoAll(const ::google::protobuf::Message &msg, unsigned int msgType, unsigned int minversion); @@ -325,14 +325,14 @@ class Server : public QThread { void log(ServerUser *u, const QString &) const; void removeChannel(int id); - void removeChannel(Channel *c, Channel *dest = NULL); + void removeChannel(Channel *c, Channel *dest = nullptr); void userEnterChannel(User *u, Channel *c, MumbleProto::UserState &mpus); bool unregisterUser(int id); - Server(int snum, QObject *parent = NULL); + Server(int snum, QObject *parent = nullptr); ~Server(); - bool canNest(Channel *newParent, Channel *channel = NULL) const; + bool canNest(Channel *newParent, Channel *channel = nullptr) const; // RPC functions. Implementation in RPC.cpp void connectAuthenticator(QObject *p); @@ -340,7 +340,7 @@ class Server : public QThread { void connectListener(QObject *p); void disconnectListener(QObject *p); void setTempGroups(int userid, int sessionId, Channel *cChannel, const QStringList &groups); - void clearTempGroups(User *user, Channel *cChannel = NULL, bool recurse = true); + void clearTempGroups(User *user, Channel *cChannel = nullptr, bool recurse = true); void startListeningToChannel(ServerUser *user, Channel *cChannel); void stopListeningToChannel(ServerUser *user, Channel *cChannel); signals: @@ -403,7 +403,7 @@ class Server : public QThread { int authenticate(QString &name, const QString &pw, int sessionId = 0, const QStringList &emails = QStringList(), const QString &certhash = QString(), bool bStrongCert = false, const QList & = QList()); Channel *addChannel(Channel *c, const QString &name, bool temporary = false, int position = 0, unsigned int maxUsers = 0); void removeChannelDB(const Channel *c); - void readChannels(Channel *p = NULL); + void readChannels(Channel *p = nullptr); void readLinks(); void updateChannel(const Channel *c); void readChannelPrivs(Channel *c); diff --git a/src/murmur/ServerDB.cpp b/src/murmur/ServerDB.cpp index 14b7cb281..536bc73be 100644 --- a/src/murmur/ServerDB.cpp +++ b/src/murmur/ServerDB.cpp @@ -62,7 +62,7 @@ class TransactionHolder { } }; -QSqlDatabase *ServerDB::db = NULL; +QSqlDatabase *ServerDB::db = nullptr; Timer ServerDB::tLogClean; QString ServerDB::qsUpgradeSuffix; @@ -692,7 +692,7 @@ ServerDB::ServerDB() { ServerDB::~ServerDB() { db->close(); delete db; - db = NULL; + db = nullptr; } bool ServerDB::prepare(QSqlQuery &query, const QString &str, bool fatal, bool warn) { @@ -1483,7 +1483,7 @@ void ServerDB::setSUPW(int srvnum, const QString &pw) { } void ServerDB::disableSU(int srvnum) { - writeSUPW(srvnum, QString(), QString(), QVariant()); // NULL, NULL, NULL + writeSUPW(srvnum, QString(), QString(), QVariant()); // nullptr, nullptr, nullptr } QString ServerDB::getLegacySHA1Hash(const QString &password) { @@ -2003,7 +2003,7 @@ void Server::dumpChannel(const Channel *c) { ChanACL *acl; int pid; - if (c == NULL) { + if (!c) { c = qhChannels.value(0); } diff --git a/src/murmur/ServerUser.cpp b/src/murmur/ServerUser.cpp index 9eab92440..d55845166 100644 --- a/src/murmur/ServerUser.cpp +++ b/src/murmur/ServerUser.cpp @@ -12,7 +12,7 @@ # include "Utils.h" #endif -ServerUser::ServerUser(Server *p, QSslSocket *socket) : Connection(p, socket), User(), s(NULL), leakyBucket(p->iMessageLimit, p->iMessageBurst) { +ServerUser::ServerUser(Server *p, QSslSocket *socket) : Connection(p, socket), User(), s(nullptr), leakyBucket(p->iMessageLimit, p->iMessageBurst) { sState = ServerUser::Connected; sUdpSocket = INVALID_SOCKET; diff --git a/src/murmur/Tray.cpp b/src/murmur/Tray.cpp index bb3664f9c..6c5a876a8 100644 --- a/src/murmur/Tray.cpp +++ b/src/murmur/Tray.cpp @@ -38,7 +38,7 @@ Tray::Tray(QObject *p, LogEmitter *logger) : QObject(p) { // Can't construct a QMenu which decends from QObject, and qsti is a QObject. // Qt bug? - qm = new QMenu(tr("Murmur"), NULL); + qm = new QMenu(tr("Murmur"), nullptr); qm->addAction(qaShowLog); qm->addSeparator(); qm->addAction(qaAbout); @@ -59,13 +59,13 @@ void Tray::on_Tray_activated(QSystemTrayIcon::ActivationReason r) { } void Tray::on_Quit_triggered() { - if (QMessageBox::question(NULL, tr("Murmur"), tr("Are you sure you want to quit Murmur?"), QMessageBox::Yes | QMessageBox::No, QMessageBox::No) == QMessageBox::Yes) { + if (QMessageBox::question(nullptr, tr("Murmur"), tr("Are you sure you want to quit Murmur?"), QMessageBox::Yes | QMessageBox::No, QMessageBox::No) == QMessageBox::Yes) { qApp->quit(); } } void Tray::on_About_triggered() { - AboutDialog ad(NULL); + AboutDialog ad(nullptr); ad.exec(); } diff --git a/src/murmur/UnixMurmur.cpp b/src/murmur/UnixMurmur.cpp index baec20a31..954e4f2a5 100644 --- a/src/murmur/UnixMurmur.cpp +++ b/src/murmur/UnixMurmur.cpp @@ -135,21 +135,21 @@ UnixMurmur::UnixMurmur() { sigemptyset(&hup.sa_mask); hup.sa_flags = SA_RESTART; - if (sigaction(SIGHUP, &hup, NULL)) + if (sigaction(SIGHUP, &hup, nullptr)) qFatal("Failed to install SIGHUP handler"); term.sa_handler = termSignalHandler; sigemptyset(&term.sa_mask); term.sa_flags = SA_RESTART; - if (sigaction(SIGTERM, &term, NULL)) + if (sigaction(SIGTERM, &term, nullptr)) qFatal("Failed to install SIGTERM handler"); usr1.sa_handler = usr1SignalHandler; sigemptyset(&usr1.sa_mask); usr1.sa_flags = SA_RESTART; - if (sigaction(SIGUSR1, &usr1, NULL)) + if (sigaction(SIGUSR1, &usr1, nullptr)) qFatal("Failed to install SIGUSR1 handler"); umask(S_IRWXO); @@ -160,9 +160,9 @@ UnixMurmur::~UnixMurmur() { delete qsnTerm; delete qsnUsr1; - qsnHup = NULL; - qsnTerm = NULL; - qsnUsr1 = NULL; + qsnHup = nullptr; + qsnTerm = nullptr; + qsnUsr1 = nullptr; close(iHupFd[0]); close(iHupFd[1]); diff --git a/src/murmur/main.cpp b/src/murmur/main.cpp index a24b77356..0d81dfb44 100644 --- a/src/murmur/main.cpp +++ b/src/murmur/main.cpp @@ -43,7 +43,7 @@ # include #endif -QFile *qfLog = NULL; +QFile *qfLog = nullptr; static bool bVerbose = false; #ifdef QT_NO_DEBUG @@ -53,10 +53,10 @@ static bool detach = false; #endif #ifdef Q_OS_UNIX -static UnixMurmur *unixMurmur = NULL; +static UnixMurmur *unixMurmur = nullptr; #endif -Meta *meta = NULL; +Meta *meta = nullptr; static LogEmitter le; @@ -145,7 +145,7 @@ static void murmurMessageOutputQString(QtMsgType type, const QString &msg) { fprintf(stderr, "%s", qPrintable(m)); } #else - ::MessageBoxA(NULL, qPrintable(m), "Murmur", MB_OK | MB_ICONWARNING); + ::MessageBoxA(nullptr, qPrintable(m), "Murmur", MB_OK | MB_ICONWARNING); #endif exit(1); } @@ -176,7 +176,7 @@ int main(int argc, char **argv) { #define MMXSSE 0x02800000 if ((cpuinfo[3] & MMXSSE) != MMXSSE) { - ::MessageBoxA(NULL, "Mumble requires a SSE capable processor (Pentium 3 / Ahtlon-XP)", "Mumble", MB_OK | MB_ICONERROR); + ::MessageBoxA(nullptr, "Mumble requires a SSE capable processor (Pentium 3 / Ahtlon-XP)", "Mumble", MB_OK | MB_ICONERROR); exit(0); } @@ -252,7 +252,7 @@ int main(int argc, char **argv) { qInstallMessageHandler(murmurMessageOutputWithContext); #ifdef Q_OS_WIN - Tray tray(NULL, &le); + Tray tray(nullptr, &le); #endif QStringList args = a.arguments(); @@ -311,7 +311,7 @@ int main(int argc, char **argv) { return 0; } else if (args.at(i) == QLatin1String("-license") || args.at(i) == QLatin1String("--license")) { #ifdef Q_OS_WIN - AboutDialog ad(NULL, AboutDialogOptionsShowLicense); + AboutDialog ad(nullptr, AboutDialogOptionsShowLicense); ad.exec(); return 0; #else @@ -320,7 +320,7 @@ int main(int argc, char **argv) { #endif } else if (args.at(i) == QLatin1String("-authors") || args.at(i) == QLatin1String("--authors")) { #ifdef Q_OS_WIN - AboutDialog ad(NULL, AboutDialogOptionsShowAuthors); + AboutDialog ad(nullptr, AboutDialogOptionsShowAuthors); ad.exec(); return 0; #else @@ -329,7 +329,7 @@ int main(int argc, char **argv) { #endif } else if (args.at(i) == QLatin1String("-third-party-licenses") || args.at(i) == QLatin1String("--third-party-licenses")) { #ifdef Q_OS_WIN - AboutDialog ad(NULL, AboutDialogOptionsShowThirdPartyLicenses); + AboutDialog ad(nullptr, AboutDialogOptionsShowThirdPartyLicenses); ad.exec(); return 0; #else @@ -422,7 +422,7 @@ int main(int argc, char **argv) { qfLog = new QFile(Meta::mp.qsLogfile); if (! qfLog->open(QIODevice::WriteOnly | QIODevice::Append | QIODevice::Text)) { delete qfLog; - qfLog = NULL; + qfLog = nullptr; #ifdef Q_OS_UNIX fprintf(stderr, "murmurd: failed to open logfile %s: no logging will be done\n", qPrintable(Meta::mp.qsLogfile)); #else @@ -463,7 +463,7 @@ int main(int argc, char **argv) { char *p; printf("Password: "); - fflush(NULL); + fflush(nullptr); if (fgets(password, 255, stdin) != password) qFatal("No password provided"); p = strchr(password, '\r'); @@ -616,7 +616,7 @@ int main(int argc, char **argv) { #ifdef USE_DBUS delete MurmurDBus::qdbc; - MurmurDBus::qdbc = NULL; + MurmurDBus::qdbc = nullptr; #endif #ifdef USE_ICE @@ -628,11 +628,11 @@ int main(int argc, char **argv) { #endif delete qfLog; - qfLog = NULL; + qfLog = nullptr; delete meta; - qInstallMessageHandler(NULL); + qInstallMessageHandler(nullptr); #ifdef Q_OS_UNIX if (! Meta::mp.qsPid.isEmpty()) { From e098a038b6242b4d2dd752753d2b18fe88fb59af Mon Sep 17 00:00:00 2001 From: Popkornium18 Date: Wed, 1 Jul 2020 23:58:10 +0200 Subject: [PATCH 2/6] REFAC(tests): replace NULL with nullptr This changes all occurances of NULL in the tests source dir to nullptr. Additionally explicit comparisons with NULL were removed. --- src/tests/Emit.cpp | 2 +- src/tests/Lock.cpp | 2 +- src/tests/OverlayTest.cpp | 12 ++++++------ src/tests/Resample.cpp | 2 +- src/tests/TestCrypt/TestCrypt.cpp | 2 +- src/tests/TestLink.cpp | 14 +++++++------- 6 files changed, 17 insertions(+), 17 deletions(-) diff --git a/src/tests/Emit.cpp b/src/tests/Emit.cpp index 6d0e7660f..533c31fda 100644 --- a/src/tests/Emit.cpp +++ b/src/tests/Emit.cpp @@ -6,7 +6,7 @@ class Slotter : public QObject { Q_OBJECT; public: - Slotter(QObject *p = NULL) : QObject(p) {}; + Slotter(QObject *p = nullptr) : QObject(p) {}; public Q_SLOTS: virtual void slottest(int &res) { res+= 1; diff --git a/src/tests/Lock.cpp b/src/tests/Lock.cpp index 6f25c1a56..22b83d0ea 100644 --- a/src/tests/Lock.cpp +++ b/src/tests/Lock.cpp @@ -49,7 +49,7 @@ class PosixLock { }; PosixLock::PosixLock() { - pthread_mutex_init(&m, NULL); + pthread_mutex_init(&m, nullptr); } void PosixLock::lock() { diff --git a/src/tests/OverlayTest.cpp b/src/tests/OverlayTest.cpp index 1665da844..f909af245 100644 --- a/src/tests/OverlayTest.cpp +++ b/src/tests/OverlayTest.cpp @@ -47,12 +47,12 @@ class OverlayWidget : public QWidget { void error(QLocalSocket::LocalSocketError); void update(); public: - OverlayWidget(QWidget *p = NULL); + OverlayWidget(QWidget *p = nullptr); }; OverlayWidget::OverlayWidget(QWidget *p) : QWidget(p) { - qlsSocket = NULL; - smMem = NULL; + qlsSocket = nullptr; + smMem = nullptr; uiWidth = uiHeight = 0; setFocusPolicy(Qt::StrongFocus); @@ -123,10 +123,10 @@ void OverlayWidget::detach() { if (qlsSocket) { qlsSocket->abort(); qlsSocket->deleteLater(); - qlsSocket = NULL; + qlsSocket = nullptr; } if (smMem) { - smMem = NULL; + smMem = nullptr; } } @@ -230,7 +230,7 @@ void OverlayWidget::readyRead() { if (! smMem->data()) { qWarning() << "SHMEM FAIL"; delete smMem; - smMem = NULL; + smMem = nullptr; } else { qWarning() << "SHMEM" << smMem->size(); } diff --git a/src/tests/Resample.cpp b/src/tests/Resample.cpp index 7cc693ebc..56a9d7f82 100644 --- a/src/tests/Resample.cpp +++ b/src/tests/Resample.cpp @@ -94,7 +94,7 @@ int main(int argc, char **argv) { pfOutput[i] = 0; - IppsResamplingPolyphaseFixed_32f *pSpec = NULL; + IppsResamplingPolyphaseFixed_32f *pSpec = nullptr; ippsResamplePolyphaseFixedInitAlloc_32f(&pSpec, iMicFreq, iSampleRate, 2*history, 0.90f, 8.0f, ippAlgHintFast); t.restart(); diff --git a/src/tests/TestCrypt/TestCrypt.cpp b/src/tests/TestCrypt/TestCrypt.cpp index 1021f8aec..2eb9e3e8c 100644 --- a/src/tests/TestCrypt/TestCrypt.cpp +++ b/src/tests/TestCrypt/TestCrypt.cpp @@ -153,7 +153,7 @@ void TestCrypt::testvectors() { cs.setKey(rawkey_str, rawkey_str, rawkey_str); unsigned char tag[16]; - QVERIFY(cs.ocb_encrypt(NULL, NULL, 0, rawkey, tag)); + QVERIFY(cs.ocb_encrypt(nullptr, nullptr, 0, rawkey, tag)); const unsigned char blanktag[AES_BLOCK_SIZE] = {0xBF,0x31,0x08,0x13,0x07,0x73,0xAD,0x5E,0xC7,0x0E,0xC6,0x9E,0x78,0x75,0xA7,0xB0}; for (int i=0;ifAvatarPosition[0]; From fd02c573b1788119757bf69b42b433ca51fc10da Mon Sep 17 00:00:00 2001 From: Popkornium18 Date: Thu, 2 Jul 2020 00:00:27 +0200 Subject: [PATCH 3/6] REFAC(crypto): replace NULL with nullptr This changes all occurances of NULL in CryptographicHash.cpp to nullptr. Additionally explicit comparisons with NULL were removed. --- src/crypto/CryptographicHash.cpp | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/src/crypto/CryptographicHash.cpp b/src/crypto/CryptographicHash.cpp index 650e7ca53..b2332aedb 100644 --- a/src/crypto/CryptographicHash.cpp +++ b/src/crypto/CryptographicHash.cpp @@ -30,30 +30,30 @@ class CryptographicHashPrivate { CryptographicHashPrivate(); /// If m_mdctx is set, cleanupMdctx will destroy - /// the EVP_MD_CTX object and set m_mdctx to NULL. + /// the EVP_MD_CTX object and set m_mdctx to nullptr. void cleanupMdctx(); }; CryptographicHashPrivate::CryptographicHashPrivate() - : m_mdctx(NULL) { + : m_mdctx(nullptr) { } void CryptographicHashPrivate::cleanupMdctx() { if (m_mdctx) { EVP_MD_CTX_destroy(m_mdctx); - m_mdctx = NULL; + m_mdctx = nullptr; } } CryptographicHashPrivate::CryptographicHashPrivate(const EVP_MD *type) - : m_mdctx(NULL) { + : m_mdctx(nullptr) { m_mdctx = EVP_MD_CTX_create(); - if (m_mdctx == NULL) { + if (!m_mdctx) { return; } - int err = EVP_DigestInit_ex(m_mdctx, type, NULL); + int err = EVP_DigestInit_ex(m_mdctx, type, nullptr); if (err != 1) { cleanupMdctx(); return; @@ -65,7 +65,7 @@ CryptographicHashPrivate::~CryptographicHashPrivate() { } void CryptographicHashPrivate::addData(const QByteArray &buf) { - if (m_mdctx == NULL) { + if (!m_mdctx) { return; } @@ -86,7 +86,7 @@ void CryptographicHashPrivate::addData(const QByteArray &buf) { } QByteArray CryptographicHashPrivate::result() { - if (m_mdctx == NULL) { + if (!m_mdctx) { return QByteArray(); } @@ -98,7 +98,7 @@ QByteArray CryptographicHashPrivate::result() { } QByteArray digest(EVP_MD_CTX_size(m_mdctx), '\0'); - int err = EVP_DigestFinal_ex(m_mdctx, reinterpret_cast(digest.data()), NULL); + int err = EVP_DigestFinal_ex(m_mdctx, reinterpret_cast(digest.data()), nullptr); if (err != 1) { cleanupMdctx(); return QByteArray(); @@ -136,11 +136,11 @@ QString CryptographicHash::shortAlgorithmName(CryptographicHash::Algorithm algo) } CryptographicHash::CryptographicHash() - : d(NULL) { + : d(nullptr) { } CryptographicHash::CryptographicHash(CryptographicHash::Algorithm algo) - : d(NULL) { + : d(nullptr) { switch (algo) { case CryptographicHash::Sha1: From f966b3ef37b7d609b533404d8f7a2298bc9c9e17 Mon Sep 17 00:00:00 2001 From: Popkornium18 Date: Thu, 2 Jul 2020 00:24:44 +0200 Subject: [PATCH 4/6] REFAC(shared): replace NULL with nullptr This changes all occurances of NULL in the src source dir to nullptr. Additionally explicit comparisons with NULL were removed. --- src/Channel.cpp | 8 +++--- src/Channel.h | 4 +-- src/Connection.cpp | 4 +-- src/EnvUtils.cpp | 2 +- src/Group.cpp | 4 +-- src/LogEmitter.h | 2 +- src/OSInfo.cpp | 14 +++++----- src/PlatformCheck.cpp | 2 +- src/SSL.cpp | 16 ++++++------ src/SSLCipherInfo.cpp | 2 +- src/SSLLocks.cpp | 12 ++++----- src/SelfSignedCertificate.cpp | 48 +++++++++++++++++------------------ src/ServerResolver.h | 2 +- src/Timer.cpp | 2 +- 14 files changed, 61 insertions(+), 61 deletions(-) diff --git a/src/Channel.cpp b/src/Channel.cpp index 139c6e698..81559257b 100644 --- a/src/Channel.cpp +++ b/src/Channel.cpp @@ -62,9 +62,9 @@ Channel *Channel::add(int id, const QString &name) { QWriteLocker lock(&c_qrwlChannels); if (c_qhChannels.contains(id)) - return NULL; + return nullptr; - Channel *c = new Channel(id, name, NULL); + Channel *c = new Channel(id, name, nullptr); c_qhChannels.insert(id, c); return c; } @@ -153,8 +153,8 @@ void Channel::addChannel(Channel *c) { } void Channel::removeChannel(Channel *c) { - c->cParent = NULL; - c->setParent(NULL); + c->cParent = nullptr; + c->setParent(nullptr); qlChannels.removeAll(c); } diff --git a/src/Channel.h b/src/Channel.h index 1afd46755..1da349e9f 100644 --- a/src/Channel.h +++ b/src/Channel.h @@ -63,7 +63,7 @@ class Channel : public QObject { /// setting. unsigned int uiMaxUsers; - Channel(int id, const QString &name, QObject *p = NULL); + Channel(int id, const QString &name, QObject *p = nullptr); ~Channel(); #ifdef MUMBLE @@ -92,7 +92,7 @@ class Channel : public QObject { bool isLinked(Channel *c) const; void link(Channel *c); - void unlink(Channel *c = NULL); + void unlink(Channel *c = nullptr); QSet allLinks(); QSet allChildren(); diff --git a/src/Connection.cpp b/src/Connection.cpp index 8771f39b7..78c465db9 100644 --- a/src/Connection.cpp +++ b/src/Connection.cpp @@ -21,7 +21,7 @@ #endif #ifdef Q_OS_WIN -HANDLE Connection::hQoS = NULL; +HANDLE Connection::hQoS = nullptr; #endif Connection::Connection(QObject *p, QSslSocket *qtsSock) : QObject(p) { @@ -68,7 +68,7 @@ void Connection::setToS() { return; dwFlow = 0; - if (! QOSAddSocketToFlow(hQoS, qtsSocket->socketDescriptor(), NULL, QOSTrafficTypeAudioVideo, QOS_NON_ADAPTIVE_FLOW, reinterpret_cast(&dwFlow))) + if (! QOSAddSocketToFlow(hQoS, qtsSocket->socketDescriptor(), nullptr, QOSTrafficTypeAudioVideo, QOS_NON_ADAPTIVE_FLOW, reinterpret_cast(&dwFlow))) qWarning("Connection: Failed to add flow to QOS"); #elif defined(Q_OS_UNIX) int val = 0xa0; diff --git a/src/EnvUtils.cpp b/src/EnvUtils.cpp index a433c2e78..7d5ade0fd 100644 --- a/src/EnvUtils.cpp +++ b/src/EnvUtils.cpp @@ -36,7 +36,7 @@ QString EnvUtils::getenv(QString name) { #else QByteArray name8bit = name.toLocal8Bit(); char *val = ::getenv(name8bit.constData()); - if (val == NULL) { + if (!val) { return QString(); } return QString::fromLocal8Bit(val); diff --git a/src/Group.cpp b/src/Group.cpp index cf886209d..c7093cbdb 100644 --- a/src/Group.cpp +++ b/src/Group.cpp @@ -67,11 +67,11 @@ Group *Group::getGroup(Channel *chan, QString name) { else if (g->bInheritable) return g; else - return NULL; + return nullptr; } p = p->cParent; } - return NULL; + return nullptr; } QSet Group::groupNames(Channel *chan) { diff --git a/src/LogEmitter.h b/src/LogEmitter.h index 1605ed8da..07964f1c4 100644 --- a/src/LogEmitter.h +++ b/src/LogEmitter.h @@ -16,7 +16,7 @@ class LogEmitter : public QObject { signals: void newLogEntry(const QString &msg); public: - LogEmitter(QObject *parent = NULL); + LogEmitter(QObject *parent = nullptr); void addLogEntry(const QString &msg); }; diff --git a/src/OSInfo.cpp b/src/OSInfo.cpp index a9e4cdeaf..e8c4b6f30 100644 --- a/src/OSInfo.cpp +++ b/src/OSInfo.cpp @@ -94,7 +94,7 @@ static QString win10DisplayableVersion() { } len = sizeof(buf); - err = RegQueryValueEx(key, L"ProductName", NULL, NULL, reinterpret_cast(&buf[0]), &len); + err = RegQueryValueEx(key, L"ProductName", nullptr, nullptr, reinterpret_cast(&buf[0]), &len); if (err != ERROR_SUCCESS) { RegCloseKey(key); return QString(); @@ -102,7 +102,7 @@ static QString win10DisplayableVersion() { productName = regString(buf, static_cast(len / sizeof(buf[0]))); len = sizeof(buf); - err = RegQueryValueEx(key, L"ReleaseId", NULL, NULL, reinterpret_cast(&buf[0]), &len); + err = RegQueryValueEx(key, L"ReleaseId", nullptr, nullptr, reinterpret_cast(&buf[0]), &len); if (err != ERROR_SUCCESS) { RegCloseKey(key); return QString(); @@ -110,7 +110,7 @@ static QString win10DisplayableVersion() { releaseId = regString(buf, static_cast(len / sizeof(buf[0]))); len = sizeof(buf); - err = RegQueryValueEx(key, L"CurrentBuild", NULL, NULL, reinterpret_cast(&buf[0]), &len); + err = RegQueryValueEx(key, L"CurrentBuild", nullptr, nullptr, reinterpret_cast(&buf[0]), &len); if (err != ERROR_SUCCESS) { RegCloseKey(key); return QString(); @@ -118,7 +118,7 @@ static QString win10DisplayableVersion() { currentBuild = regString(buf, static_cast(len / sizeof(buf[0]))); len = sizeof(dw); - err = RegQueryValueEx(key, L"UBR", NULL, NULL, reinterpret_cast(&dw), &len); + err = RegQueryValueEx(key, L"UBR", nullptr, nullptr, reinterpret_cast(&dw), &len); if (err != ERROR_SUCCESS) { RegCloseKey(key); return QString(); @@ -235,10 +235,10 @@ QString OSInfo::getOSVersion() { if (err != noErr) return QString::number(QSysInfo::MacintoshVersion, 16); - char *buildno = NULL; + char *buildno = nullptr; char buildno_buf[32]; size_t sz_buildno_buf = sizeof(buildno); - int ret = sysctlbyname("kern.osversion", buildno_buf, &sz_buildno_buf, NULL, 0); + int ret = sysctlbyname("kern.osversion", buildno_buf, &sz_buildno_buf, nullptr, 0); if (ret == 0) { buildno = &buildno_buf[0]; } @@ -370,7 +370,7 @@ QString OSInfo::getOSDisplayableVersion() { typedef BOOL (WINAPI *PGPI)(DWORD, DWORD, DWORD, DWORD, PDWORD); PGPI pGetProductInfo = (PGPI) GetProcAddress(GetModuleHandle(TEXT("kernel32.dll")), "GetProductInfo"); - if (pGetProductInfo == NULL) { + if (!pGetProductInfo) { return QString(); } diff --git a/src/PlatformCheck.cpp b/src/PlatformCheck.cpp index 405dc4c03..448cb44cd 100644 --- a/src/PlatformCheck.cpp +++ b/src/PlatformCheck.cpp @@ -11,7 +11,7 @@ bool PlatformCheck::IsWine() { #ifdef Q_OS_WIN // Detect if we're running under Wine. // For more info, see https://wiki.winehq.org/Developer_FAQ#How_can_I_detect_Wine.3F - if (QLibrary::resolve(QLatin1String("ntdll.dll"), "wine_get_version") != NULL) { + if (QLibrary::resolve(QLatin1String("ntdll.dll"), "wine_get_version")) { return true; } #endif diff --git a/src/SSL.cpp b/src/SSL.cpp index a0c22a929..4cddc43f7 100644 --- a/src/SSL.cpp +++ b/src/SSL.cpp @@ -33,7 +33,7 @@ void MumbleSSL::initialize() { // If we detect that no locking callback is configured, we // have to set it up ourselves to allow multi-threaded use // of OpenSSL. - if (CRYPTO_get_locking_callback() == NULL) { + if (!CRYPTO_get_locking_callback()) { SSLLocks::initialize(); } } @@ -49,23 +49,23 @@ QString MumbleSSL::defaultOpenSSLCipherString() { QList MumbleSSL::ciphersFromOpenSSLCipherString(QString cipherString) { QList chosenCiphers; - SSL_CTX *ctx = NULL; - SSL *ssl = NULL; - const SSL_METHOD *meth = NULL; + SSL_CTX *ctx = nullptr; + SSL *ssl = nullptr; + const SSL_METHOD *meth = nullptr; int i = 0; QByteArray csbuf = cipherString.toLatin1(); const char *ciphers = csbuf.constData(); meth = SSLv23_server_method(); - if (meth == NULL) { + if (!meth) { qWarning("MumbleSSL: unable to get SSL method"); goto out; } // We use const_cast to be compatible with OpenSSL 0.9.8. ctx = SSL_CTX_new(const_cast(meth)); - if (ctx == NULL) { + if (!ctx) { qWarning("MumbleSSL: unable to allocate SSL_CTX"); goto out; } @@ -76,14 +76,14 @@ QList MumbleSSL::ciphersFromOpenSSLCipherString(QString cipherString } ssl = SSL_new(ctx); - if (ssl == NULL) { + if (!ssl) { qWarning("MumbleSSL: unable to create SSL object in ciphersFromOpenSSLCipherString"); goto out; } while (1) { const char *name = SSL_get_cipher_list(ssl, i); - if (name == NULL) { + if (!name) { break; } #if QT_VERSION >= 0x050300 diff --git a/src/SSLCipherInfo.cpp b/src/SSLCipherInfo.cpp index 0f48e5638..d04ba864c 100644 --- a/src/SSLCipherInfo.cpp +++ b/src/SSLCipherInfo.cpp @@ -18,5 +18,5 @@ const SSLCipherInfo *SSLCipherInfoLookupByOpenSSLName(const char *openSslCipherN return ci; } } - return NULL; + return nullptr; } diff --git a/src/SSLLocks.cpp b/src/SSLLocks.cpp index 9512ae0dd..5ffc3cfdd 100644 --- a/src/SSLLocks.cpp +++ b/src/SSLLocks.cpp @@ -10,7 +10,7 @@ #include -static QMutex **locks = NULL; +static QMutex **locks = nullptr; void locking_callback(int mode, int type, const char *, int) { if (mode & CRYPTO_LOCK) { @@ -50,7 +50,7 @@ void SSLLocks::initialize() { int nlocks = CRYPTO_num_locks(); locks = reinterpret_cast(calloc(nlocks, sizeof(QMutex *))); - if (locks == NULL) { + if (!locks) { qFatal("SSLLocks: unable to allocate locks array"); // This initializer is called early during program @@ -71,12 +71,12 @@ void SSLLocks::initialize() { void SSLLocks::destroy() { // If SSLLocks was never initialized, or has been destroyed already, // don't try to do it again. - if (locks == NULL) { + if (!locks) { return; } - CRYPTO_set_locking_callback(NULL); - CRYPTO_set_id_callback(NULL); + CRYPTO_set_locking_callback(nullptr); + CRYPTO_set_id_callback(nullptr); int nlocks = CRYPTO_num_locks(); for (int i = 0; i < nlocks; i++) { @@ -84,5 +84,5 @@ void SSLLocks::destroy() { } free(locks); - locks = NULL; + locks = nullptr; } diff --git a/src/SelfSignedCertificate.cpp b/src/SelfSignedCertificate.cpp index 0db5154b4..cbdcf7528 100644 --- a/src/SelfSignedCertificate.cpp +++ b/src/SelfSignedCertificate.cpp @@ -12,10 +12,10 @@ static int add_ext(X509 * crt, int nid, char *value) { X509V3_CTX ctx; X509V3_set_ctx_nodb(&ctx); - X509V3_set_ctx(&ctx, crt, crt, NULL, NULL, 0); + X509V3_set_ctx(&ctx, crt, crt, nullptr, nullptr, 0); - X509_EXTENSION *ex = X509V3_EXT_conf_nid(NULL, &ctx, nid, value); - if (ex == NULL) { + X509_EXTENSION *ex = X509V3_EXT_conf_nid(nullptr, &ctx, nid, value); + if (!ex) { return 0; } @@ -30,14 +30,14 @@ static int add_ext(X509 * crt, int nid, char *value) { bool SelfSignedCertificate::generate(CertificateType certificateType, QString clientCertName, QString clientCertEmail, QSslCertificate &qscCert, QSslKey &qskKey) { bool ok = true; - X509 *x509 = NULL; - EVP_PKEY *pkey = NULL; - RSA *rsa = NULL; - BIGNUM *e = NULL; - X509_NAME *name = NULL; - ASN1_INTEGER *serialNumber = NULL; - ASN1_TIME *notBefore = NULL; - ASN1_TIME *notAfter = NULL; + X509 *x509 = nullptr; + EVP_PKEY *pkey = nullptr; + RSA *rsa = nullptr; + BIGNUM *e = nullptr; + X509_NAME *name = nullptr; + ASN1_INTEGER *serialNumber = nullptr; + ASN1_TIME *notBefore = nullptr; + ASN1_TIME *notAfter = nullptr; QString commonName; bool isServerCert = certificateType == CertificateTypeServerCertificate; @@ -47,25 +47,25 @@ bool SelfSignedCertificate::generate(CertificateType certificateType, QString cl } x509 = X509_new(); - if (x509 == NULL) { + if (!x509) { ok = false; goto out; } pkey = EVP_PKEY_new(); - if (pkey == NULL) { + if (!pkey) { ok = false; goto out; } rsa = RSA_new(); - if (rsa == NULL) { + if (!rsa) { ok = false; goto out; } e = BN_new(); - if (e == NULL) { + if (!e) { ok = false; goto out; } @@ -74,7 +74,7 @@ bool SelfSignedCertificate::generate(CertificateType certificateType, QString cl goto out; } - if (RSA_generate_key_ex(rsa, 2048, e, NULL) == 0) { + if (RSA_generate_key_ex(rsa, 2048, e, nullptr) == 0) { ok = false; goto out; } @@ -90,7 +90,7 @@ bool SelfSignedCertificate::generate(CertificateType certificateType, QString cl } serialNumber = X509_get_serialNumber(x509); - if (serialNumber == NULL) { + if (!serialNumber) { ok = false; goto out; } @@ -100,21 +100,21 @@ bool SelfSignedCertificate::generate(CertificateType certificateType, QString cl } notBefore = X509_get_notBefore(x509); - if (notBefore == NULL) { + if (!notBefore) { ok = false; goto out; } - if (X509_gmtime_adj(notBefore, 0) == NULL) { + if (!X509_gmtime_adj(notBefore, 0)) { ok = false; goto out; } notAfter = X509_get_notAfter(x509); - if (notAfter == NULL) { + if (!notAfter) { ok = false; goto out; } - if (X509_gmtime_adj(notAfter, 60*60*24*365*20) == NULL) { + if (!X509_gmtime_adj(notAfter, 60*60*24*365*20)) { ok = false; goto out; } @@ -125,7 +125,7 @@ bool SelfSignedCertificate::generate(CertificateType certificateType, QString cl } name = X509_get_subject_name(x509); - if (name == NULL) { + if (!name) { ok = false; goto out; } @@ -200,7 +200,7 @@ bool SelfSignedCertificate::generate(CertificateType certificateType, QString cl { QByteArray crt; - int len = i2d_X509(x509, NULL); + int len = i2d_X509(x509, nullptr); if (len <= 0) { ok = false; goto out; @@ -222,7 +222,7 @@ bool SelfSignedCertificate::generate(CertificateType certificateType, QString cl { QByteArray key; - int len = i2d_PrivateKey(pkey, NULL); + int len = i2d_PrivateKey(pkey, nullptr); if (len <= 0) { ok = false; goto out; diff --git a/src/ServerResolver.h b/src/ServerResolver.h index 2927f0972..9d00ea859 100644 --- a/src/ServerResolver.h +++ b/src/ServerResolver.h @@ -20,7 +20,7 @@ class ServerResolver : public QObject { Q_OBJECT Q_DISABLE_COPY(ServerResolver) public: - ServerResolver(QObject *parent = NULL); + ServerResolver(QObject *parent = nullptr); QString hostname(); quint16 port(); diff --git a/src/Timer.cpp b/src/Timer.cpp index c58f316eb..7730aa008 100644 --- a/src/Timer.cpp +++ b/src/Timer.cpp @@ -111,7 +111,7 @@ quint64 Timer::now() { # else quint64 Timer::now() { struct timeval tv; - gettimeofday(&tv, NULL); + gettimeofday(&tv, nullptr); quint64 e= tv.tv_sec * 1000000LL; e += tv.tv_usec; return e; From c6bf7bbfd2f2697eb297b3754c958dc4fd055805 Mon Sep 17 00:00:00 2001 From: Popkornium18 Date: Thu, 2 Jul 2020 00:27:21 +0200 Subject: [PATCH 5/6] REFAC(client): replace NULL with nullptr This changes all occurances of NULL in mumble_exe.cpp to nullptr. --- src/mumble_exe/mumble_exe.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/mumble_exe/mumble_exe.cpp b/src/mumble_exe/mumble_exe.cpp index 6431060bb..2ec5d64ec 100644 --- a/src/mumble_exe/mumble_exe.cpp +++ b/src/mumble_exe/mumble_exe.cpp @@ -17,7 +17,7 @@ typedef int (*DLL_DEBUG_MAIN)(int, char **); // Alert shows a fatal error dialog and waits for the user to click OK. static void Alert(LPCWSTR title, LPCWSTR msg) { - MessageBox(NULL, msg, title, MB_OK|MB_ICONERROR); + MessageBox(nullptr, msg, title, MB_OK|MB_ICONERROR); } // Get the current Mumble version built into this executable. @@ -39,7 +39,7 @@ static const std::wstring GetMumbleVersion() { static const std::wstring GetExecutableDirPath() { wchar_t path[MAX_PATH]; - if (GetModuleFileNameW(NULL, path, MAX_PATH) == 0) + if (GetModuleFileNameW(nullptr, path, MAX_PATH) == 0) return std::wstring(); if (!PathRemoveFileSpecW(path)) @@ -161,7 +161,7 @@ int main(int argc, char **argv) { return -2; } - HMODULE dll = LoadLibraryExW(abs_dll_path.c_str(), NULL, LOAD_WITH_ALTERED_SEARCH_PATH); + HMODULE dll = LoadLibraryExW(abs_dll_path.c_str(), nullptr, LOAD_WITH_ALTERED_SEARCH_PATH); if (!dll) { Alert(L"Mumble Launcher Error -3", L"Failed to load mumble_app.dll."); return -3; @@ -204,7 +204,7 @@ int APIENTRY wWinMain(HINSTANCE instance, HINSTANCE prevInstance, wchar_t *cmdAr return -2; } - HMODULE dll = LoadLibraryExW(abs_dll_path.c_str(), NULL, LOAD_WITH_ALTERED_SEARCH_PATH); + HMODULE dll = LoadLibraryExW(abs_dll_path.c_str(), nullptr, LOAD_WITH_ALTERED_SEARCH_PATH); if (!dll) { Alert(L"Mumble Launcher Error -3", L"Failed to load mumble_app.dll."); return -3; @@ -217,7 +217,7 @@ int APIENTRY wWinMain(HINSTANCE instance, HINSTANCE prevInstance, wchar_t *cmdAr } (void) cmdArg; - int rc = entry_point(instance, prevInstance, NULL, cmdShow); + int rc = entry_point(instance, prevInstance, nullptr, cmdShow); return rc; } From 567f24aca506364a8f76541f183c632fe2252fad Mon Sep 17 00:00:00 2001 From: Popkornium18 Date: Thu, 2 Jul 2020 00:29:59 +0200 Subject: [PATCH 6/6] REFAC(g15helper): replace NULL with nullptr This changes all occurances of NULL in g15helper_emu.cpp to nullptr. --- g15helper/g15helper_emu.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/g15helper/g15helper_emu.cpp b/g15helper/g15helper_emu.cpp index 4e096d2cd..b417b501a 100644 --- a/g15helper/g15helper_emu.cpp +++ b/g15helper/g15helper_emu.cpp @@ -106,12 +106,12 @@ int __stdcall WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdL if (lpCmdLine && (strcmp(lpCmdLine, "/detect") == 0)) { return 0; } else if (! lpCmdLine || (strcmp(lpCmdLine, "/mumble") != 0)) { - MessageBox(NULL, L"This program is run by Mumble, and should not be started separately.", L"Nothing to see here, move along", MB_OK | MB_ICONERROR); + MessageBox(nullptr, L"This program is run by Mumble, and should not be started separately.", L"Nothing to see here, move along", MB_OK | MB_ICONERROR); return 0; } char *argvec[1]; - argvec[0] = NULL; + argvec[0] = nullptr; int argc = 0; char **argv = &argvec[0];