diff options
author | Kevin Funk <kevin.funk@kdab.com> | 2019-03-12 11:46:26 +0100 |
---|---|---|
committer | Kevin Funk <kevin.funk@kdab.com> | 2019-03-14 07:37:52 +0000 |
commit | 41e7b71c410b77a81d09d3cc2e169ffd7975b4d2 (patch) | |
tree | fd0722a70d1aedf8567cc11babd10adcbbd1e797 /src/corelib/tools | |
parent | b35eec360d4d88d094094fb54c101fad6cee5768 (diff) |
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 <Friedemann.Kleint@qt.io>
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
Diffstat (limited to 'src/corelib/tools')
-rw-r--r-- | src/corelib/tools/qcache.h | 14 | ||||
-rw-r--r-- | src/corelib/tools/qdatetime_p.h | 2 | ||||
-rw-r--r-- | src/corelib/tools/qdatetimeparser_p.h | 8 | ||||
-rw-r--r-- | src/corelib/tools/qfreelist_p.h | 4 | ||||
-rw-r--r-- | src/corelib/tools/qlist.h | 2 | ||||
-rw-r--r-- | src/corelib/tools/qlocale_p.h | 2 |
6 files changed, 16 insertions, 16 deletions
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<Key, Node>::iterator i = hash.find(key); if (typename QHash<Key, Node>::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 <class Key, class T> inline QCache<Key, T>::QCache(int amaxCost) Q_DECL_NOTHROW - : f(0), l(0), mx(amaxCost), total(0) {} + : f(nullptr), l(nullptr), mx(amaxCost), total(0) {} template <class Key, class T> inline void QCache<Key,T>::clear() { while (f) { delete f->t; f = f->n; } - hash.clear(); l = 0; total = 0; } + hash.clear(); l = nullptr; total = 0; } template <class Key, class T> inline void QCache<Key,T>::setMaxCost(int m) @@ -153,11 +153,11 @@ inline T *QCache<Key,T>::take(const Key &key) { typename QHash<Key, Node>::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<T, ConstantsType>::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<T>::iterator QList<T>::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<Node *>(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<float>::max()) { - if (ok != 0) + if (ok != nullptr) *ok = false; const float huge = std::numeric_limits<float>::infinity(); return d < 0 ? -huge : huge; |