From 41e7b71c410b77a81d09d3cc2e169ffd7975b4d2 Mon Sep 17 00:00:00 2001 From: Kevin Funk Date: Tue, 12 Mar 2019 11:46:26 +0100 Subject: More nullptr usage in headers Diff generated by running clang-tidy's modernize-use-nullptr checker on the CMake-based Qt version. Skipping src/3rdparty, examples/, tests/ Change-Id: Ib182074e2e2fd52f63093f73b3e2e4c0cb7af188 Reviewed-by: Friedemann Kleint Reviewed-by: Simon Hausmann --- src/corelib/tools/qcache.h | 14 +++++++------- src/corelib/tools/qdatetime_p.h | 2 +- src/corelib/tools/qdatetimeparser_p.h | 8 ++++---- src/corelib/tools/qfreelist_p.h | 4 ++-- src/corelib/tools/qlist.h | 2 +- src/corelib/tools/qlocale_p.h | 2 +- 6 files changed, 16 insertions(+), 16 deletions(-) (limited to 'src/corelib/tools') diff --git a/src/corelib/tools/qcache.h b/src/corelib/tools/qcache.h index 8c0e7860f7..b558a8358d 100644 --- a/src/corelib/tools/qcache.h +++ b/src/corelib/tools/qcache.h @@ -51,7 +51,7 @@ class QCache struct Node { inline Node() : keyPtr(0) {} inline Node(T *data, int cost) - : keyPtr(0), t(data), c(cost), p(0), n(0) {} + : keyPtr(nullptr), t(data), c(cost), p(nullptr), n(nullptr) {} const Key *keyPtr; T *t; int c; Node *p,*n; }; Node *f, *l; @@ -71,14 +71,14 @@ class QCache inline T *relink(const Key &key) { typename QHash::iterator i = hash.find(key); if (typename QHash::const_iterator(i) == hash.constEnd()) - return 0; + return nullptr; Node &n = *i; if (f != &n) { if (n.p) n.p->n = n.n; if (n.n) n.n->p = n.p; if (l == &n) l = n.p; - n.p = 0; + n.p = nullptr; n.n = f; f->p = &n; f = &n; @@ -117,12 +117,12 @@ private: template inline QCache::QCache(int amaxCost) Q_DECL_NOTHROW - : f(0), l(0), mx(amaxCost), total(0) {} + : f(nullptr), l(nullptr), mx(amaxCost), total(0) {} template inline void QCache::clear() { while (f) { delete f->t; f = f->n; } - hash.clear(); l = 0; total = 0; } + hash.clear(); l = nullptr; total = 0; } template inline void QCache::setMaxCost(int m) @@ -153,11 +153,11 @@ inline T *QCache::take(const Key &key) { typename QHash::iterator i = hash.find(key); if (i == hash.end()) - return 0; + return nullptr; Node &n = *i; T *t = n.t; - n.t = 0; + n.t = nullptr; unlink(n); return t; } diff --git a/src/corelib/tools/qdatetime_p.h b/src/corelib/tools/qdatetime_p.h index 4d30d4192b..6e4120d762 100644 --- a/src/corelib/tools/qdatetime_p.h +++ b/src/corelib/tools/qdatetime_p.h @@ -135,7 +135,7 @@ public: #if QT_CONFIG(timezone) static qint64 zoneMSecsToEpochMSecs(qint64 msecs, const QTimeZone &zone, DaylightStatus hint = UnknownDaylightTime, - QDate *localDate = 0, QTime *localTime = 0); + QDate *localDate = nullptr, QTime *localTime = nullptr); // Inlined for its one caller in qdatetime.cpp inline void setUtcOffsetByTZ(qint64 atMSecsSinceEpoch); diff --git a/src/corelib/tools/qdatetimeparser_p.h b/src/corelib/tools/qdatetimeparser_p.h index f7e6e351fe..e244fed09a 100644 --- a/src/corelib/tools/qdatetimeparser_p.h +++ b/src/corelib/tools/qdatetimeparser_p.h @@ -86,7 +86,7 @@ public: DateTimeEdit }; QDateTimeParser(QVariant::Type t, Context ctx) - : currentSectionIndex(-1), display(0), cachedDay(-1), parserType(t), + : currentSectionIndex(-1), display(nullptr), cachedDay(-1), parserType(t), fixday(false), spec(Qt::LocalTime), context(ctx) { defaultLocale = QLocale::system(); @@ -218,9 +218,9 @@ private: ParsedSection parseSection(const QDateTime ¤tValue, int sectionIndex, int offset, QString *text) const; int findMonth(const QString &str1, int monthstart, int sectionIndex, - QString *monthName = 0, int *used = 0) const; + QString *monthName = nullptr, int *used = nullptr) const; int findDay(const QString &str1, int intDaystart, int sectionIndex, - QString *dayName = 0, int *used = 0) const; + QString *dayName = nullptr, int *used = nullptr) const; ParsedSection findTimeZone(QStringRef str, const QDateTime &when, int maxVal, int minVal) const; #if QT_CONFIG(timezone) @@ -236,7 +236,7 @@ private: PossiblePM = 3, PossibleBoth = 4 }; - AmPmFinder findAmPm(QString &str, int index, int *used = 0) const; + AmPmFinder findAmPm(QString &str, int index, int *used = nullptr) const; #endif // datestring bool potentialValue(const QStringRef &str, int min, int max, int index, diff --git a/src/corelib/tools/qfreelist_p.h b/src/corelib/tools/qfreelist_p.h index 63be0952ff..d72d6e1b4b 100644 --- a/src/corelib/tools/qfreelist_p.h +++ b/src/corelib/tools/qfreelist_p.h @@ -249,11 +249,11 @@ inline int QFreeList::next() if (!v) { v = allocate((id & ConstantsType::IndexMask) - at, ConstantsType::Sizes[block]); - if (!_v[block].testAndSetRelease(0, v)) { + if (!_v[block].testAndSetRelease(nullptr, v)) { // race with another thread lost delete [] v; v = _v[block].loadAcquire(); - Q_ASSERT(v != 0); + Q_ASSERT(v != nullptr); } } diff --git a/src/corelib/tools/qlist.h b/src/corelib/tools/qlist.h index 6643288bd5..34577acaa5 100644 --- a/src/corelib/tools/qlist.h +++ b/src/corelib/tools/qlist.h @@ -526,7 +526,7 @@ inline typename QList::iterator QList::insert(iterator before, const T &t) Q_ASSERT_X(isValidIterator(before), "QList::insert", "The specified iterator argument 'before' is invalid"); int iBefore = int(before.i - reinterpret_cast(p.begin())); - Node *n = 0; + Node *n = nullptr; if (d->ref.isShared()) n = detach_helper_grow(iBefore, 1); else diff --git a/src/corelib/tools/qlocale_p.h b/src/corelib/tools/qlocale_p.h index 98b6a31a46..1e8dc28fbf 100644 --- a/src/corelib/tools/qlocale_p.h +++ b/src/corelib/tools/qlocale_p.h @@ -249,7 +249,7 @@ public: if (qIsInf(d)) return float(d); if (std::fabs(d) > std::numeric_limits::max()) { - if (ok != 0) + if (ok != nullptr) *ok = false; const float huge = std::numeric_limits::infinity(); return d < 0 ? -huge : huge; -- cgit v1.2.3