From 1185c28f2f408d858c148062bb0125974905ef22 Mon Sep 17 00:00:00 2001 From: Edward Welbourne Date: Mon, 18 Jan 2016 12:40:41 +0100 Subject: [PATCH] Fix some mis-guided fall-throughs #ifdef QT_BOOTSTRAPPED. A switch had a case whose body was in a #ifndef; when that got elided, this case fell through into an entirely misguided case. Give the #if a #else clause so that it break;s in the defined case. Code review revealed another, then I searched for more following the same pattern. Change-Id: I57fb59b6c8d349604f3fc6c8b1d424fb3c775d50 Reviewed-by: Thiago Macieira --- src/corelib/tools/qdatetime.cpp | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/src/corelib/tools/qdatetime.cpp b/src/corelib/tools/qdatetime.cpp index ff20c57166..491ed99301 100644 --- a/src/corelib/tools/qdatetime.cpp +++ b/src/corelib/tools/qdatetime.cpp @@ -2697,10 +2697,11 @@ qint64 QDateTimePrivate::toMSecsSinceEpoch() const } case Qt::TimeZone: -#ifndef QT_BOOTSTRAPPED +#ifdef QT_BOOTSTRAPPED + break; +#else return zoneMSecsToEpochMSecs(m_msecs, m_timeZone); #endif - break; } Q_UNREACHABLE(); return 0; @@ -3197,7 +3198,9 @@ QString QDateTime::timeZoneAbbreviation() const case Qt::OffsetFromUTC: return QTimeZonePrivate::utcQString() + toOffsetString(Qt::ISODate, d->m_offsetFromUtc); case Qt::TimeZone: -#ifndef QT_BOOTSTRAPPED +#ifdef QT_BOOTSTRAPPED + break; +#else return d->m_timeZone.d->abbreviation(d->toMSecsSinceEpoch()); #endif // QT_BOOTSTRAPPED case Qt::LocalTime: { @@ -3228,7 +3231,9 @@ bool QDateTime::isDaylightTime() const case Qt::OffsetFromUTC: return false; case Qt::TimeZone: -#ifndef QT_BOOTSTRAPPED +#ifdef QT_BOOTSTRAPPED + break; +#else return d->m_timeZone.d->isDaylightTime(toMSecsSinceEpoch()); #endif // QT_BOOTSTRAPPED case Qt::LocalTime: { @@ -4820,10 +4825,8 @@ QDataStream &operator<<(QDataStream &out, const QDateTime &dateTime) out << (qint8)QDateTimePrivate::OffsetFromUTC; break; case Qt::TimeZone: -#ifndef QT_BOOTSTRAPPED out << (qint8)QDateTimePrivate::TimeZone; break; -#endif // QT_BOOTSTRAPPED case Qt::LocalTime: out << (qint8)QDateTimePrivate::LocalUnknown; break; @@ -4896,10 +4899,11 @@ QDataStream &operator>>(QDataStream &in, QDateTime &dateTime) spec = Qt::OffsetFromUTC; break; case QDateTimePrivate::TimeZone: -#ifndef QT_BOOTSTRAPPED spec = Qt::TimeZone; +#ifndef QT_BOOTSTRAPPED + // FIXME: need to use a different constructor ! +#endif break; -#endif // QT_BOOTSTRAPPED case QDateTimePrivate::LocalUnknown: case QDateTimePrivate::LocalStandard: case QDateTimePrivate::LocalDST: @@ -4955,8 +4959,8 @@ QDebug operator<<(QDebug dbg, const QDateTime &date) case Qt::TimeZone: #ifndef QT_BOOTSTRAPPED dbg << ' ' << date.timeZone().id(); - break; #endif // QT_BOOTSTRAPPED + break; case Qt::LocalTime: break; }