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/corelib/plugin/qfactoryloader.cpp | 8 ++++---- src/corelib/plugin/qlibrary.cpp | 34 +++++++++++++++++----------------- src/corelib/plugin/qlibrary_unix.cpp | 2 +- src/corelib/plugin/qpluginloader.cpp | 8 ++++---- 4 files changed, 26 insertions(+), 26 deletions(-) (limited to 'src/corelib/plugin') diff --git a/src/corelib/plugin/qfactoryloader.cpp b/src/corelib/plugin/qfactoryloader.cpp index 18f10c9b43..14de8db1c6 100644 --- a/src/corelib/plugin/qfactoryloader.cpp +++ b/src/corelib/plugin/qfactoryloader.cpp @@ -212,7 +212,7 @@ void QFactoryLoader::update() QStringList(QLatin1String("libplugins_%1_*.so").arg(d->suffix)), #endif QDir::Files); - QLibraryPrivate *library = 0; + QLibraryPrivate *library = nullptr; for (int j = 0; j < plugins.count(); ++j) { QString fileName = QDir::cleanPath(path + QLatin1Char('/') + plugins.at(j)); @@ -383,7 +383,7 @@ QObject *QFactoryLoader::instance(int index) const { Q_D(const QFactoryLoader); if (index < 0) - return 0; + return nullptr; #if QT_CONFIG(library) QMutexLocker lock(&d->mutex); @@ -399,7 +399,7 @@ QObject *QFactoryLoader::instance(int index) const return obj; } } - return 0; + return nullptr; } index -= d->libraryList.size(); lock.unlock(); @@ -416,7 +416,7 @@ QObject *QFactoryLoader::instance(int index) const --index; } - return 0; + return nullptr; } QMultiMap QFactoryLoader::keyMap() const diff --git a/src/corelib/plugin/qlibrary.cpp b/src/corelib/plugin/qlibrary.cpp index eeaa3c18ec..b3a95d4f26 100644 --- a/src/corelib/plugin/qlibrary.cpp +++ b/src/corelib/plugin/qlibrary.cpp @@ -256,7 +256,7 @@ static bool findPatternUnloaded(const QString &library, QLibraryPrivate *lib) qsizetype fdlen = qMin(file.size(), MaxMemoryMapSize); const char *filedata = reinterpret_cast(file.map(0, fdlen)); - if (filedata == 0) { + if (filedata == nullptr) { // Try reading the data into memory instead (up to 64 MB). data = file.read(64 * 1024 * 1024); filedata = data.constData(); @@ -387,12 +387,12 @@ private: }; static QBasicMutex qt_library_mutex; -static QLibraryStore *qt_library_data = 0; +static QLibraryStore *qt_library_data = nullptr; static bool qt_library_data_once; QLibraryStore::~QLibraryStore() { - qt_library_data = 0; + qt_library_data = nullptr; } inline void QLibraryStore::cleanup() @@ -459,7 +459,7 @@ inline QLibraryPrivate *QLibraryStore::findOrCreate(const QString &fileName, con QLibraryStore *data = instance(); // check if this library is already loaded - QLibraryPrivate *lib = 0; + QLibraryPrivate *lib = nullptr; if (Q_LIKELY(data)) { lib = data->libraryMap.value(fileName); if (lib) @@ -498,7 +498,7 @@ inline void QLibraryStore::releaseLibrary(QLibraryPrivate *lib) } QLibraryPrivate::QLibraryPrivate(const QString &canonicalFileName, const QString &version, QLibrary::LoadHints loadHints) - : pHnd(0), fileName(canonicalFileName), fullVersion(version), instance(0), + : pHnd(nullptr), fileName(canonicalFileName), fullVersion(version), instance(nullptr), libraryRefCount(0), libraryUnloadCount(0), pluginState(MightBeAPlugin) { loadHintsInt.storeRelaxed(loadHints); @@ -528,7 +528,7 @@ void QLibraryPrivate::mergeLoadHints(QLibrary::LoadHints lh) QFunctionPointer QLibraryPrivate::resolve(const char *symbol) { if (!pHnd) - return 0; + return nullptr; return resolve_sys(symbol); } @@ -584,12 +584,12 @@ bool QLibraryPrivate::unload(UnloadFlag flag) //when the library is unloaded, we release the reference on it so that 'this' //can get deleted libraryRefCount.deref(); - pHnd = 0; - instance = 0; + pHnd = nullptr; + instance = nullptr; } } - return (pHnd == 0); + return (pHnd == nullptr); } void QLibraryPrivate::release() @@ -847,7 +847,7 @@ bool QLibrary::isLoaded() const Constructs a library with the given \a parent. */ QLibrary::QLibrary(QObject *parent) - :QObject(parent), d(0), did_load(false) + :QObject(parent), d(nullptr), did_load(false) { } @@ -862,7 +862,7 @@ QLibrary::QLibrary(QObject *parent) ".dylib" on \macos and iOS, and ".dll" on Windows. (See \l{fileName}.) */ QLibrary::QLibrary(const QString& fileName, QObject *parent) - :QObject(parent), d(0), did_load(false) + :QObject(parent), d(nullptr), did_load(false) { setFileName(fileName); } @@ -879,7 +879,7 @@ QLibrary::QLibrary(const QString& fileName, QObject *parent) ".dylib" on \macos and iOS, and ".dll" on Windows. (See \l{fileName}.) */ QLibrary::QLibrary(const QString& fileName, int verNum, QObject *parent) - :QObject(parent), d(0), did_load(false) + :QObject(parent), d(nullptr), did_load(false) { setFileNameAndVersion(fileName, verNum); } @@ -895,7 +895,7 @@ QLibrary::QLibrary(const QString& fileName, int verNum, QObject *parent) ".dylib" on \macos and iOS, and ".dll" on Windows. (See \l{fileName}.) */ QLibrary::QLibrary(const QString& fileName, const QString &version, QObject *parent) - :QObject(parent), d(0), did_load(false) + :QObject(parent), d(nullptr), did_load(false) { setFileNameAndVersion(fileName, version); } @@ -942,7 +942,7 @@ void QLibrary::setFileName(const QString &fileName) if (d) { lh = d->loadHints(); d->release(); - d = 0; + d = nullptr; did_load = false; } d = QLibraryPrivate::findOrCreate(fileName, QString(), lh); @@ -970,7 +970,7 @@ void QLibrary::setFileNameAndVersion(const QString &fileName, int verNum) if (d) { lh = d->loadHints(); d->release(); - d = 0; + d = nullptr; did_load = false; } d = QLibraryPrivate::findOrCreate(fileName, verNum >= 0 ? QString::number(verNum) : QString(), lh); @@ -991,7 +991,7 @@ void QLibrary::setFileNameAndVersion(const QString &fileName, const QString &ver if (d) { lh = d->loadHints(); d->release(); - d = 0; + d = nullptr; did_load = false; } d = QLibraryPrivate::findOrCreate(fileName, version, lh); @@ -1020,7 +1020,7 @@ void QLibrary::setFileNameAndVersion(const QString &fileName, const QString &ver QFunctionPointer QLibrary::resolve(const char *symbol) { if (!isLoaded() && !load()) - return 0; + return nullptr; return d->resolve(symbol); } diff --git a/src/corelib/plugin/qlibrary_unix.cpp b/src/corelib/plugin/qlibrary_unix.cpp index f0de1010d7..6eb84b327b 100644 --- a/src/corelib/plugin/qlibrary_unix.cpp +++ b/src/corelib/plugin/qlibrary_unix.cpp @@ -277,7 +277,7 @@ bool QLibraryPrivate::load_sys() qualifiedFileName = attempt; errorString.clear(); } - return (pHnd != 0); + return (pHnd != nullptr); } bool QLibraryPrivate::unload_sys() diff --git a/src/corelib/plugin/qpluginloader.cpp b/src/corelib/plugin/qpluginloader.cpp index c2443dbdda..aed1704d5f 100644 --- a/src/corelib/plugin/qpluginloader.cpp +++ b/src/corelib/plugin/qpluginloader.cpp @@ -136,7 +136,7 @@ QT_BEGIN_NAMESPACE Constructs a plugin loader with the given \a parent. */ QPluginLoader::QPluginLoader(QObject *parent) - : QObject(parent), d(0), did_load(false) + : QObject(parent), d(nullptr), did_load(false) { } @@ -152,7 +152,7 @@ QPluginLoader::QPluginLoader(QObject *parent) \sa setFileName() */ QPluginLoader::QPluginLoader(const QString &fileName, QObject *parent) - : QObject(parent), d(0), did_load(false) + : QObject(parent), d(nullptr), did_load(false) { setFileName(fileName); setLoadHints(QLibrary::PreventUnloadHint); @@ -195,7 +195,7 @@ QPluginLoader::~QPluginLoader() QObject *QPluginLoader::instance() { if (!isLoaded() && !load()) - return 0; + return nullptr; if (!d->inst && d->instance) d->inst = d->instance(); return d->inst.data(); @@ -363,7 +363,7 @@ void QPluginLoader::setFileName(const QString &fileName) if (d) { lh = d->loadHints(); d->release(); - d = 0; + d = nullptr; did_load = false; } -- cgit v1.2.3