From ece0c0a5e7e0b18beb58ccd868bde54c7be64f78 Mon Sep 17 00:00:00 2001 From: Allan Sandfeld Jensen Date: Fri, 22 Nov 2019 14:46:58 +0100 Subject: Tidy nullptr usage Move away from using 0 as pointer literal. Done using clang-tidy. This is not complete as run-clang-tidy can't handle all of qtbase in one go. Change-Id: I1076a21f32aac0dab078af6f175f7508145eece0 Reviewed-by: Friedemann Kleint Reviewed-by: Lars Knoll --- src/network/kernel/qauthenticator.cpp | 10 +++++----- src/network/kernel/qdnslookup.cpp | 4 ++-- src/network/kernel/qdnslookup_unix.cpp | 8 ++++---- src/network/kernel/qhostaddress.cpp | 2 +- src/network/kernel/qhostinfo.cpp | 4 ++-- src/network/kernel/qhostinfo_unix.cpp | 8 ++++---- src/network/kernel/qnetworkinterface.cpp | 2 +- src/network/kernel/qnetworkproxy.cpp | 12 ++++++------ src/network/kernel/qurlinfo.cpp | 10 +++++----- 9 files changed, 30 insertions(+), 30 deletions(-) (limited to 'src/network/kernel') diff --git a/src/network/kernel/qauthenticator.cpp b/src/network/kernel/qauthenticator.cpp index 33a30eb1cd..e9a8e2a9e5 100644 --- a/src/network/kernel/qauthenticator.cpp +++ b/src/network/kernel/qauthenticator.cpp @@ -158,7 +158,7 @@ static QByteArray qGssapiContinue(QAuthenticatorPrivate *ctx, Constructs an empty authentication object. */ QAuthenticator::QAuthenticator() - : d(0) + : d(nullptr) { } @@ -175,7 +175,7 @@ QAuthenticator::~QAuthenticator() Constructs a copy of \a other. */ QAuthenticator::QAuthenticator(const QAuthenticator &other) - : d(0) + : d(nullptr) { if (other.d) *this = other; @@ -1227,7 +1227,7 @@ QByteArray qEncodeHmacMd5(QByteArray &key, const QByteArray &message) static QByteArray qCreatev2Hash(const QAuthenticatorPrivate *ctx, QNtlmPhase3Block *phase3) { - Q_ASSERT(phase3 != 0); + Q_ASSERT(phase3 != nullptr); // since v2 Hash is need for both NTLMv2 and LMv2 it is calculated // only once and stored and reused if(phase3->v2Hash.size() == 0) { @@ -1284,7 +1284,7 @@ static QByteArray qEncodeNtlmv2Response(const QAuthenticatorPrivate *ctx, const QNtlmPhase2Block& ch, QNtlmPhase3Block *phase3) { - Q_ASSERT(phase3 != 0); + Q_ASSERT(phase3 != nullptr); // return value stored in phase3 qCreatev2Hash(ctx, phase3); @@ -1351,7 +1351,7 @@ static QByteArray qEncodeLmv2Response(const QAuthenticatorPrivate *ctx, const QNtlmPhase2Block& ch, QNtlmPhase3Block *phase3) { - Q_ASSERT(phase3 != 0); + Q_ASSERT(phase3 != nullptr); // return value stored in phase3 qCreatev2Hash(ctx, phase3); diff --git a/src/network/kernel/qdnslookup.cpp b/src/network/kernel/qdnslookup.cpp index 1b66829070..ab1be02b6b 100644 --- a/src/network/kernel/qdnslookup.cpp +++ b/src/network/kernel/qdnslookup.cpp @@ -481,7 +481,7 @@ void QDnsLookup::abort() { Q_D(QDnsLookup); if (d->runnable) { - d->runnable = 0; + d->runnable = nullptr; d->reply = QDnsLookupReply(); d->reply.error = QDnsLookup::OperationCancelledError; d->reply.errorString = tr("Operation cancelled"); @@ -992,7 +992,7 @@ void QDnsLookupPrivate::_q_lookupFinished(const QDnsLookupReply &_reply) qDebug("DNS reply for %s: %i (%s)", qPrintable(name), _reply.error, qPrintable(_reply.errorString)); #endif reply = _reply; - runnable = 0; + runnable = nullptr; isFinished = true; emit q->finished(); } diff --git a/src/network/kernel/qdnslookup_unix.cpp b/src/network/kernel/qdnslookup_unix.cpp index ee7484ab35..12b40fc35d 100644 --- a/src/network/kernel/qdnslookup_unix.cpp +++ b/src/network/kernel/qdnslookup_unix.cpp @@ -73,13 +73,13 @@ QT_BEGIN_NAMESPACE typedef struct __res_state* res_state; #endif typedef int (*dn_expand_proto)(const unsigned char *, const unsigned char *, const unsigned char *, char *, int); -static dn_expand_proto local_dn_expand = 0; +static dn_expand_proto local_dn_expand = nullptr; typedef void (*res_nclose_proto)(res_state); -static res_nclose_proto local_res_nclose = 0; +static res_nclose_proto local_res_nclose = nullptr; typedef int (*res_ninit_proto)(res_state); -static res_ninit_proto local_res_ninit = 0; +static res_ninit_proto local_res_ninit = nullptr; typedef int (*res_nquery_proto)(res_state, const char *, int, int, unsigned char *, int); -static res_nquery_proto local_res_nquery = 0; +static res_nquery_proto local_res_nquery = nullptr; // Custom deleter to close resolver state. diff --git a/src/network/kernel/qhostaddress.cpp b/src/network/kernel/qhostaddress.cpp index b54fb349fb..ed1c23ed6e 100644 --- a/src/network/kernel/qhostaddress.cpp +++ b/src/network/kernel/qhostaddress.cpp @@ -144,7 +144,7 @@ static bool parseIp6(const QString &address, QIPAddressUtils::IPv6Address &addr, } else { scopeId->clear(); } - return QIPAddressUtils::parseIp6(addr, tmp.constBegin(), tmp.constEnd()) == 0; + return QIPAddressUtils::parseIp6(addr, tmp.constBegin(), tmp.constEnd()) == nullptr; } bool QHostAddressPrivate::parse(const QString &ipString) diff --git a/src/network/kernel/qhostinfo.cpp b/src/network/kernel/qhostinfo.cpp index f9335c3bb9..31671feece 100644 --- a/src/network/kernel/qhostinfo.cpp +++ b/src/network/kernel/qhostinfo.cpp @@ -410,7 +410,7 @@ QHostInfo QHostInfoAgent::reverseLookup(const QHostAddress &address) // Reverse lookup sockaddr_in sa4; sockaddr_in6 sa6; - sockaddr *sa = 0; + sockaddr *sa = nullptr; QT_SOCKLEN_T saSize; if (address.protocol() == QAbstractSocket::IPv4Protocol) { sa = reinterpret_cast(&sa4); @@ -455,7 +455,7 @@ QHostInfo QHostInfoAgent::lookup(const QString &hostName) return results; } - addrinfo *res = 0; + addrinfo *res = nullptr; struct addrinfo hints; memset(&hints, 0, sizeof(hints)); hints.ai_family = PF_UNSPEC; diff --git a/src/network/kernel/qhostinfo_unix.cpp b/src/network/kernel/qhostinfo_unix.cpp index 78a05f8407..625fbabf31 100644 --- a/src/network/kernel/qhostinfo_unix.cpp +++ b/src/network/kernel/qhostinfo_unix.cpp @@ -80,12 +80,12 @@ enum LibResolvFeature { typedef struct __res_state *res_state_ptr; typedef int (*res_init_proto)(void); -static res_init_proto local_res_init = 0; +static res_init_proto local_res_init = nullptr; typedef int (*res_ninit_proto)(res_state_ptr); -static res_ninit_proto local_res_ninit = 0; +static res_ninit_proto local_res_ninit = nullptr; typedef void (*res_nclose_proto)(res_state_ptr); -static res_nclose_proto local_res_nclose = 0; -static res_state_ptr local_res = 0; +static res_nclose_proto local_res_nclose = nullptr; +static res_state_ptr local_res = nullptr; #if QT_CONFIG(library) && !defined(Q_OS_QNX) namespace { diff --git a/src/network/kernel/qnetworkinterface.cpp b/src/network/kernel/qnetworkinterface.cpp index b7a6d9adf9..eed57f8a32 100644 --- a/src/network/kernel/qnetworkinterface.cpp +++ b/src/network/kernel/qnetworkinterface.cpp @@ -627,7 +627,7 @@ bool QNetworkAddressEntry::isPermanent() const Constructs an empty network interface object. */ QNetworkInterface::QNetworkInterface() - : d(0) + : d(nullptr) { } diff --git a/src/network/kernel/qnetworkproxy.cpp b/src/network/kernel/qnetworkproxy.cpp index a2a89ed94b..90c8b75a86 100644 --- a/src/network/kernel/qnetworkproxy.cpp +++ b/src/network/kernel/qnetworkproxy.cpp @@ -254,13 +254,13 @@ class QGlobalNetworkProxy { public: QGlobalNetworkProxy() - : applicationLevelProxy(0) - , applicationLevelProxyFactory(0) + : applicationLevelProxy(nullptr) + , applicationLevelProxyFactory(nullptr) #if QT_CONFIG(socks5) - , socks5SocketEngineHandler(0) + , socks5SocketEngineHandler(nullptr) #endif #if QT_CONFIG(http) - , httpSocketEngineHandler(0) + , httpSocketEngineHandler(nullptr) #endif #ifdef QT_USE_SYSTEM_PROXIES , useSystemProxies(true) @@ -313,7 +313,7 @@ public: applicationLevelProxy = new QNetworkProxy; *applicationLevelProxy = proxy; delete applicationLevelProxyFactory; - applicationLevelProxyFactory = 0; + applicationLevelProxyFactory = nullptr; useSystemProxies = false; } @@ -501,7 +501,7 @@ template<> void QSharedDataPointer::detach() \sa setType(), setApplicationProxy() */ QNetworkProxy::QNetworkProxy() - : d(0) + : d(nullptr) { // make sure we have QGlobalNetworkProxy singleton created, otherwise // you don't have any socket engine handler created when directly setting diff --git a/src/network/kernel/qurlinfo.cpp b/src/network/kernel/qurlinfo.cpp index 7ae6822fb4..e6f2e70ff4 100644 --- a/src/network/kernel/qurlinfo.cpp +++ b/src/network/kernel/qurlinfo.cpp @@ -126,7 +126,7 @@ public: QUrlInfo::QUrlInfo() { - d = 0; + d = nullptr; } /*! @@ -139,7 +139,7 @@ QUrlInfo::QUrlInfo(const QUrlInfo &ui) d = new QUrlInfoPrivate; *d = *ui.d; } else { - d = 0; + d = nullptr; } } @@ -443,7 +443,7 @@ QUrlInfo &QUrlInfo::operator=(const QUrlInfo &ui) *d = *ui.d; } else { delete d; - d = 0; + d = nullptr; } return *this; } @@ -683,7 +683,7 @@ bool QUrlInfo::equal(const QUrlInfo &i1, const QUrlInfo &i2, bool QUrlInfo::operator==(const QUrlInfo &other) const { if (!d) - return other.d == 0; + return other.d == nullptr; if (!other.d) return false; @@ -721,7 +721,7 @@ bool QUrlInfo::operator==(const QUrlInfo &other) const */ bool QUrlInfo::isValid() const { - return d != 0; + return d != nullptr; } QT_END_NAMESPACE -- cgit v1.2.3