From a8320dcf65f51701bcd68b1e85d38c6f11c3a873 Mon Sep 17 00:00:00 2001 From: Ivailo Monev Date: Fri, 20 Dec 2019 02:00:41 +0000 Subject: [PATCH] compiler warning fixes upstream commit: https://github.com/qt/qtbase/commit/ef36fd02178482cd312ea551303856ef563421af Signed-off-by: Ivailo Monev --- src/core/global/qnumeric.cpp | 40 ++++++++-------- src/core/io/qdatastream.cpp | 9 ++-- src/core/io/qfilesystemengine_unix.cpp | 2 +- src/core/kernel/qmetatype.cpp | 2 +- src/core/tools/qchar.cpp | 4 -- src/core/tools/qtimeline.cpp | 8 ++-- src/gui/accessible/qaccessiblewidget.cpp | 5 +- src/gui/dialogs/qprintdialog_unix.cpp | 8 +--- .../graphicsview/qgraphicsscenebsptreeindex.cpp | 22 ++++----- src/gui/image/qpnghandler.cpp | 19 ++++---- src/gui/image/qtiffhandler.cpp | 53 ++++++++++------------ src/gui/image/qtiffhandler_p.h | 2 - src/gui/painting/qpaintengine_raster.cpp | 8 +--- src/gui/styles/qstylesheetstyle.cpp | 8 ++-- src/gui/styles/qwindowsstyle.cpp | 2 - src/gui/text/qfontengine.cpp | 1 - src/tools/uic/cpp/cppwriteinitialization.cpp | 1 - src/xml/kernel/qxmlstream.cpp | 2 +- 18 files changed, 81 insertions(+), 115 deletions(-) diff --git a/src/core/global/qnumeric.cpp b/src/core/global/qnumeric.cpp index 8a6792e91..3bd349c1a 100644 --- a/src/core/global/qnumeric.cpp +++ b/src/core/global/qnumeric.cpp @@ -38,57 +38,53 @@ QT_BEGIN_NAMESPACE /*! Returns the bit pattern for an infinite number as a double. */ -static const union { unsigned char c[8]; double d; } qt_be_inf_bytes = { { 0x7f, 0xf0, 0, 0, 0, 0, 0, 0 } }; -static const union { unsigned char c[8]; double d; } qt_le_inf_bytes = { { 0, 0, 0, 0, 0, 0, 0xf0, 0x7f } }; #ifdef QT_ARMFPA -static const union { unsigned char c[8]; double d; } qt_armfpa_inf_bytes = { { 0, 0, 0xf0, 0x7f, 0, 0, 0, 0 } }; #endif Q_CORE_EXPORT double qInf() { #ifdef QT_ARMFPA + static const union { unsigned char c[8]; double d; } qt_armfpa_inf_bytes = { { 0, 0, 0xf0, 0x7f, 0, 0, 0, 0 } }; return qt_armfpa_inf_bytes.d; +#elif Q_BYTE_ORDER == Q_BIG_ENDIAN + static const union { unsigned char c[8]; double d; } qt_be_inf_bytes = { { 0x7f, 0xf0, 0, 0, 0, 0, 0, 0 } }; + return qt_be_inf_bytes.d; #else - return (QSysInfo::ByteOrder == QSysInfo::BigEndian - ? qt_be_inf_bytes.d - : qt_le_inf_bytes.d); + static const union { unsigned char c[8]; double d; } qt_le_inf_bytes = { { 0, 0, 0, 0, 0, 0, 0xf0, 0x7f } }; + return qt_le_inf_bytes.d; #endif } /*! Returns the bit pattern of a signalling NaN as a double. */ -static const union { unsigned char c[8]; double d; } qt_be_snan_bytes = { { 0x7f, 0xf8, 0, 0, 0, 0, 0, 0 } }; -static const union { unsigned char c[8]; double d; } qt_le_snan_bytes = { { 0, 0, 0, 0, 0, 0, 0xf8, 0x7f } }; -#ifdef QT_ARMFPA -static const union { unsigned char c[8]; double d; } qt_armfpa_snan_bytes = { { 0, 0, 0xf8, 0x7f, 0, 0, 0, 0 } }; -#endif Q_CORE_EXPORT double qSNaN() { #ifdef QT_ARMFPA + static const union { unsigned char c[8]; double d; } qt_armfpa_snan_bytes = { { 0, 0, 0xf8, 0x7f, 0, 0, 0, 0 } }; return qt_armfpa_snan_bytes.d; +#elif Q_BYTE_ORDER == Q_BIG_ENDIAN + static const union { unsigned char c[8]; double d; } qt_be_snan_bytes = { { 0x7f, 0xf8, 0, 0, 0, 0, 0, 0 } }; + return qt_be_snan_bytes.d; #else - return (QSysInfo::ByteOrder == QSysInfo::BigEndian - ? qt_be_snan_bytes.d - : qt_le_snan_bytes.d); + static const union { unsigned char c[8]; double d; } qt_le_snan_bytes = { { 0, 0, 0, 0, 0, 0, 0xf8, 0x7f } }; + return qt_le_snan_bytes.d; #endif } /*! Returns the bit pattern of a quiet NaN as a double. */ -static const union { unsigned char c[8]; double d; } qt_be_qnan_bytes = { { 0xff, 0xf8, 0, 0, 0, 0, 0, 0 } }; -static const union { unsigned char c[8]; double d; } qt_le_qnan_bytes = { { 0, 0, 0, 0, 0, 0, 0xf8, 0xff } }; -#ifdef QT_ARMFPA -static const union { unsigned char c[8]; double d; } qt_armfpa_qnan_bytes = { { 0, 0, 0xf8, 0xff, 0, 0, 0, 0 } }; -#endif Q_CORE_EXPORT double qQNaN() { #ifdef QT_ARMFPA + static const union { unsigned char c[8]; double d; } qt_armfpa_qnan_bytes = { { 0, 0, 0xf8, 0xff, 0, 0, 0, 0 } }; return qt_armfpa_qnan_bytes.d; +#elif Q_BYTE_ORDER == Q_BIG_ENDIAN + static const union { unsigned char c[8]; double d; } qt_be_qnan_bytes = { { 0xff, 0xf8, 0, 0, 0, 0, 0, 0 } }; + return qt_be_qnan_bytes.d; #else - return (QSysInfo::ByteOrder == QSysInfo::BigEndian - ? qt_be_qnan_bytes.d - : qt_le_qnan_bytes.d); + static const union { unsigned char c[8]; double d; } qt_le_qnan_bytes = { { 0, 0, 0, 0, 0, 0, 0xf8, 0xff } }; + return qt_le_qnan_bytes.d; #endif } diff --git a/src/core/io/qdatastream.cpp b/src/core/io/qdatastream.cpp index 38e2614cf..96ab20fc3 100644 --- a/src/core/io/qdatastream.cpp +++ b/src/core/io/qdatastream.cpp @@ -501,10 +501,11 @@ void QDataStream::setStatus(DataStatus status) void QDataStream::setByteOrder(ByteOrder bo) { byteorder = bo; - if (QSysInfo::ByteOrder == QSysInfo::BigEndian) - noswap = (byteorder == BigEndian); - else - noswap = (byteorder == LittleEndian); +#if Q_BYTE_ORDER == Q_BIG_ENDIAN + noswap = (byteorder == BigEndian); +#else + noswap = (byteorder == LittleEndian); +#endif } /*! diff --git a/src/core/io/qfilesystemengine_unix.cpp b/src/core/io/qfilesystemengine_unix.cpp index ae1431b8d..86b73bbfd 100644 --- a/src/core/io/qfilesystemengine_unix.cpp +++ b/src/core/io/qfilesystemengine_unix.cpp @@ -425,8 +425,8 @@ bool QFileSystemEngine::copyFile(const QFileSystemEntry &source, const QFileSyst Q_UNUSED(source); Q_UNUSED(target); error = QSystemError(ENOSYS, QSystemError::StandardLibraryError); //Function not implemented -#endif // Q_OS_LINUX return false; +#endif // Q_OS_LINUX } //static diff --git a/src/core/kernel/qmetatype.cpp b/src/core/kernel/qmetatype.cpp index f86b2577d..48720cce4 100644 --- a/src/core/kernel/qmetatype.cpp +++ b/src/core/kernel/qmetatype.cpp @@ -1343,8 +1343,8 @@ void QMetaType::destroy(int type, void *data) #ifndef QT_BOOTSTRAPPED case QMetaType::QUrl: delete static_cast< NS(QUrl)* >(data); -#endif break; +#endif case QMetaType::QLocale: delete static_cast< NS(QLocale)* >(data); break; diff --git a/src/core/tools/qchar.cpp b/src/core/tools/qchar.cpp index dbec9c207..f0446e0dc 100644 --- a/src/core/tools/qchar.cpp +++ b/src/core/tools/qchar.cpp @@ -109,8 +109,6 @@ static inline uint to_ascii_lower(uint ucs4) case 'Y': case 'Z': return ucs4 + 32; - default: - return ucs4; } return ucs4; } @@ -145,8 +143,6 @@ static inline uint to_ascii_upper(uint ucs4) case 'y': case 'z': return ucs4 - 32; - default: - return ucs4; } return ucs4; } diff --git a/src/core/tools/qtimeline.cpp b/src/core/tools/qtimeline.cpp index 2853fff14..d5d14d416 100644 --- a/src/core/tools/qtimeline.cpp +++ b/src/core/tools/qtimeline.cpp @@ -505,7 +505,6 @@ QTimeLine::CurveShape QTimeLine::curveShape() const { Q_D(const QTimeLine); switch (d->easingCurve.type()) { - default: case QEasingCurve::InOutSine: return EaseInOutCurve; case QEasingCurve::InCurve: @@ -518,14 +517,14 @@ QTimeLine::CurveShape QTimeLine::curveShape() const return SineCurve; case QEasingCurve::CosineCurve: return CosineCurve; + default: + return EaseInOutCurve; } - return EaseInOutCurve; } void QTimeLine::setCurveShape(CurveShape shape) { switch (shape) { - default: case EaseInOutCurve: setEasingCurve(QEasingCurve(QEasingCurve::InOutSine)); break; @@ -544,6 +543,9 @@ void QTimeLine::setCurveShape(CurveShape shape) case CosineCurve: setEasingCurve(QEasingCurve(QEasingCurve::CosineCurve)); break; + default: + setEasingCurve(QEasingCurve(QEasingCurve::InOutSine)); + break; } } diff --git a/src/gui/accessible/qaccessiblewidget.cpp b/src/gui/accessible/qaccessiblewidget.cpp index 2b9643d68..9fda9744a 100644 --- a/src/gui/accessible/qaccessiblewidget.cpp +++ b/src/gui/accessible/qaccessiblewidget.cpp @@ -110,7 +110,6 @@ static int qt_accAmpIndex(const QString &text) return -1; int fa = 0; - QChar ac; while ((fa = text.indexOf(QLatin1Char('&'), fa)) != -1) { ++fa; if (fa < text.length()) { @@ -118,10 +117,8 @@ static int qt_accAmpIndex(const QString &text) if (text.at(fa) == QLatin1Char('&')) { ++fa; continue; - } else { - return fa - 1; - break; } + return fa - 1; } } diff --git a/src/gui/dialogs/qprintdialog_unix.cpp b/src/gui/dialogs/qprintdialog_unix.cpp index 7af8d9a0f..6962d3a5a 100644 --- a/src/gui/dialogs/qprintdialog_unix.cpp +++ b/src/gui/dialogs/qprintdialog_unix.cpp @@ -1054,7 +1054,6 @@ QVariant QPPDOptionsModel::data(const QModelIndex& index, int role) const } return QVariant(); } - break; case Qt::DisplayRole: { QOptionTreeItem* itm; @@ -1067,16 +1066,13 @@ QVariant QPPDOptionsModel::data(const QModelIndex& index, int role) const return cups->unicodeString(itm->description); else if (itm->type == QOptionTreeItem::Option && itm->selected > -1) return cups->unicodeString(itm->selDescription); - else - return QVariant(); + return QVariant(); } - break; default: return QVariant(); } - if (role != Qt::DisplayRole) - return QVariant(); + return QVariant(); } QModelIndex QPPDOptionsModel::index(int row, int column, const QModelIndex& parent) const diff --git a/src/gui/graphicsview/qgraphicsscenebsptreeindex.cpp b/src/gui/graphicsview/qgraphicsscenebsptreeindex.cpp index f5112ba90..710b71222 100644 --- a/src/gui/graphicsview/qgraphicsscenebsptreeindex.cpp +++ b/src/gui/graphicsview/qgraphicsscenebsptreeindex.cpp @@ -693,21 +693,17 @@ void QGraphicsSceneBspTreeIndex::itemChange(const QGraphicsItem *item, QGraphics bool QGraphicsSceneBspTreeIndex::event(QEvent *event) { Q_D(QGraphicsSceneBspTreeIndex); - switch (event->type()) { - case QEvent::Timer: - if (d->indexTimerId && static_cast(event)->timerId() == d->indexTimerId) { - if (d->restartIndexTimer) { - d->restartIndexTimer = false; - } else { - // this call will kill the timer - d->_q_updateIndex(); - } + if (event->type() == QEvent::Timer) { + if (d->indexTimerId && static_cast(event)->timerId() == d->indexTimerId) { + if (d->restartIndexTimer) { + d->restartIndexTimer = false; + } else { + // this call will kill the timer + d->_q_updateIndex(); } - // Fallthrough intended - support timers in subclasses. - default: - return QObject::event(event); + } } - return true; + return QObject::event(event); } QT_END_NAMESPACE diff --git a/src/gui/image/qpnghandler.cpp b/src/gui/image/qpnghandler.cpp index ca23bdd35..93f039cb0 100644 --- a/src/gui/image/qpnghandler.cpp +++ b/src/gui/image/qpnghandler.cpp @@ -163,7 +163,7 @@ static void iod_read_fn(png_structp png_ptr, png_bytep data, png_size_t length) int nr = in->read((char*)data, length); if (nr <= 0) { png_error(png_ptr, "Read Error"); - return; + break; } length -= nr; } @@ -178,7 +178,6 @@ static void qpiw_write_fn(png_structp png_ptr, png_bytep data, png_size_t length uint nr = out->write((char*)data, length); if (nr != length) { png_error(png_ptr, "Write Error"); - return; } } @@ -234,8 +233,9 @@ void setup_qt(QImage& image, png_structp png_ptr, png_infop info_ptr, float scre if (image.isNull()) return; } - if (QSysInfo::ByteOrder == QSysInfo::BigEndian) - png_set_swap_alpha(png_ptr); +#if Q_BYTE_ORDER == Q_BIG_ENDIAN + png_set_swap_alpha(png_ptr); +#endif png_read_update_info(png_ptr, info_ptr); } else { @@ -327,8 +327,9 @@ void setup_qt(QImage& image, png_structp png_ptr, png_infop info_ptr, float scre return; } - if (QSysInfo::ByteOrder == QSysInfo::BigEndian) - png_set_swap_alpha(png_ptr); +#if Q_BYTE_ORDER == Q_BIG_ENDIAN + png_set_swap_alpha(png_ptr); +#endif png_read_update_info(png_ptr, info_ptr); } @@ -649,9 +650,9 @@ bool QPNGImageWriter::writeImage(const QImage& image, int quality_in, // Swap ARGB to RGBA (normal PNG format) before saving on // BigEndian machines - if (QSysInfo::ByteOrder == QSysInfo::BigEndian) { - png_set_swap_alpha(png_ptr); - } +#if Q_BYTE_ORDER == Q_BIG_ENDIAN + png_set_swap_alpha(png_ptr); +#endif // Qt==ARGB==Big(ARGB)==Little(BGRA). But RGB888 is RGB regardless if (QSysInfo::ByteOrder == QSysInfo::LittleEndian diff --git a/src/gui/image/qtiffhandler.cpp b/src/gui/image/qtiffhandler.cpp index 84799875e..0f0a4a10c 100644 --- a/src/gui/image/qtiffhandler.cpp +++ b/src/gui/image/qtiffhandler.cpp @@ -135,6 +135,27 @@ inline void rotate_right_mirror_vertical(QImage *const image) // rotate right->m *image = generated; } + +static void qConvert32BitOrder(void *buffer, int width) +{ + uint32 *target = reinterpret_cast(buffer); + for (int32 x=0; x> 24 + | (p & 0x00ff0000) << 8 + | (p & 0x0000ff00) << 8 + | (p & 0x000000ff) << 8; +#else + // convert between ARGB and ABGR + target[x] = (p & 0xff000000) + | ((p & 0x00ff0000) >> 16) + | (p & 0x0000ff00) + | ((p & 0x000000ff) << 16); +#endif + } +} + QTiffHandler::QTiffHandler() : QImageIOHandler() { compression = NoCompression; @@ -279,7 +300,7 @@ bool QTiffHandler::read(QImage *image) const int stopOnError = 1; if (TIFFReadRGBAImageOriented(tiff, width, height, reinterpret_cast(image->bits()), ORIENTATION_TOPLEFT, stopOnError)) { for (uint32 y=0; yscanLine(y), width); + qConvert32BitOrder(image->scanLine(y), width); } else { TIFFClose(tiff); return false; @@ -576,10 +597,7 @@ bool QTiffHandler::write(const QImage &image) int chunkStart = y; int chunkEnd = y + chunk.height(); while (y < chunkEnd) { - if (QSysInfo::ByteOrder == QSysInfo::LittleEndian) - convert32BitOrder(chunk.scanLine(y - chunkStart), width); - else - convert32BitOrderBigEndian(chunk.scanLine(y - chunkStart), width); + qConvert32BitOrder(chunk.scanLine(y - chunkStart), width); if (TIFFWriteScanline(tiff, reinterpret_cast(chunk.scanLine(y - chunkStart)), y) != 1) { TIFFClose(tiff); @@ -647,29 +665,4 @@ bool QTiffHandler::supportsOption(ImageOption option) const || option == ImageFormat; } -void QTiffHandler::convert32BitOrder(void *buffer, int width) -{ - uint32 *target = reinterpret_cast(buffer); - for (int32 x=0; x> 16) - | (p & 0x0000ff00) - | ((p & 0x000000ff) << 16); - } -} - -void QTiffHandler::convert32BitOrderBigEndian(void *buffer, int width) -{ - uint32 *target = reinterpret_cast(buffer); - for (int32 x=0; x> 24 - | (p & 0x00ff0000) << 8 - | (p & 0x0000ff00) << 8 - | (p & 0x000000ff) << 8; - } -} - QT_END_NAMESPACE diff --git a/src/gui/image/qtiffhandler_p.h b/src/gui/image/qtiffhandler_p.h index a5f5cc6e6..6b68b6539 100644 --- a/src/gui/image/qtiffhandler_p.h +++ b/src/gui/image/qtiffhandler_p.h @@ -60,8 +60,6 @@ public: LzwCompression = 1 }; private: - void convert32BitOrder(void *buffer, int width); - void convert32BitOrderBigEndian(void *buffer, int width); int compression; }; diff --git a/src/gui/painting/qpaintengine_raster.cpp b/src/gui/painting/qpaintengine_raster.cpp index af7084fb1..ac365dbec 100644 --- a/src/gui/painting/qpaintengine_raster.cpp +++ b/src/gui/painting/qpaintengine_raster.cpp @@ -2551,8 +2551,6 @@ void QRasterPaintEngine::drawTextItem(const QPointF &p, const QTextItem &textIte QFontEngine *fontEngine = ti.fontEngine; #if defined(Q_WS_X11) - - if (fontEngine->type() != QFontEngine::Freetype) { QPaintEngineEx::drawTextItem(p, ti); return; @@ -2571,11 +2569,9 @@ void QRasterPaintEngine::drawTextItem(const QPointF &p, const QTextItem &textIte if (!drawCachedGlyphs(glyphs.size(), glyphs.constData(), positions.constData(), fontEngine)) QPaintEngine::drawTextItem(p, ti); - - return; -#endif - +#else QPaintEngineEx::drawTextItem(p, ti); +#endif } /*! diff --git a/src/gui/styles/qstylesheetstyle.cpp b/src/gui/styles/qstylesheetstyle.cpp index 6f0a7987e..a4b0e66b0 100644 --- a/src/gui/styles/qstylesheetstyle.cpp +++ b/src/gui/styles/qstylesheetstyle.cpp @@ -4888,7 +4888,6 @@ QSize QStyleSheetStyle::sizeFromContents(ContentsType ct, const QStyleOption *op return (rule.hasContentsSize()) ? rule.size(sz) : rule.boxSize(baseStyle()->sizeFromContents(ct, opt, sz, w)); - break; case CT_Slider: if (rule.hasBorder() || rule.hasBox() || rule.hasGeometry()) @@ -5408,10 +5407,9 @@ QRect QStyleSheetStyle::subControlRect(ComplexControl cc, const QStyleOptionComp return sr; } else if (sc == SC_ScrollBarSubPage) { return QRect(contentRect.topLeft(), sb->orientation == Qt::Horizontal ? sr.bottomLeft() : sr.topRight()); - } else { // SC_ScrollBarAddPage - return QRect(sb->orientation == Qt::Horizontal ? sr.topRight() : sr.bottomLeft(), contentRect.bottomRight()); } - break; + // SC_ScrollBarAddPage + return QRect(sb->orientation == Qt::Horizontal ? sr.topRight() : sr.bottomLeft(), contentRect.bottomRight()); } case SC_ScrollBarAddLine: pe = PseudoElement_ScrollBarAddLine; break; case SC_ScrollBarSubLine: pe = PseudoElement_ScrollBarSubLine; break; @@ -5463,7 +5461,7 @@ QRect QStyleSheetStyle::subControlRect(ComplexControl cc, const QStyleOptionComp cr = horizontal ? QRect(cr.x() + sliderPos, cr.y(), len, thickness) : QRect(cr.x(), cr.y() + sliderPos, thickness, len); return subRule2.borderRect(cr); - break; } + } case SC_SliderTickmarks: // TODO... default: diff --git a/src/gui/styles/qwindowsstyle.cpp b/src/gui/styles/qwindowsstyle.cpp index b419f1b12..600d12dfd 100644 --- a/src/gui/styles/qwindowsstyle.cpp +++ b/src/gui/styles/qwindowsstyle.cpp @@ -393,8 +393,6 @@ int QWindowsStyle::pixelMetric(PixelMetric pm, const QStyleOption *opt, const QW case PM_DockWidgetFrameWidth: ret = 4; break; - break; - #endif // QT_NO_MENU case PM_SplitterWidth: diff --git a/src/gui/text/qfontengine.cpp b/src/gui/text/qfontengine.cpp index 835e38ae5..2b9f9d4ea 100644 --- a/src/gui/text/qfontengine.cpp +++ b/src/gui/text/qfontengine.cpp @@ -132,7 +132,6 @@ static HB_Fixed hb_getFontMetric(HB_Font font, HB_FontMetric metric) switch (metric) { case HB_FontAscent: return fe->ascent().value(); - break; default: return 0; } diff --git a/src/tools/uic/cpp/cppwriteinitialization.cpp b/src/tools/uic/cpp/cppwriteinitialization.cpp index 1147db5a9..407ad97fe 100644 --- a/src/tools/uic/cpp/cppwriteinitialization.cpp +++ b/src/tools/uic/cpp/cppwriteinitialization.cpp @@ -1845,7 +1845,6 @@ QString WriteInitialization::pixCall(const DomProperty *p) const qWarning("%s: Warning: Unknown icon format encountered. The ui-file was generated with a too-recent version of Designer.", qPrintable(m_option.messagePrefix())); return QLatin1String("QIcon()"); - break; } return pixCall(type, s); } diff --git a/src/xml/kernel/qxmlstream.cpp b/src/xml/kernel/qxmlstream.cpp index 21400ca22..bf668cd0b 100644 --- a/src/xml/kernel/qxmlstream.cpp +++ b/src/xml/kernel/qxmlstream.cpp @@ -1199,7 +1199,7 @@ inline int QXmlStreamReaderPrivate::fastScanContentCharList() break; } return n; - } break; + } case '\r': if ((c = filterCarriageReturn()) == 0) return n; -- 2.11.0