OSDN Git Service

compiler warning fixes
authorIvailo Monev <xakepa10@laimg.moc>
Fri, 20 Dec 2019 02:00:41 +0000 (02:00 +0000)
committerIvailo Monev <xakepa10@laimg.moc>
Fri, 20 Dec 2019 03:24:36 +0000 (03:24 +0000)
upstream commit:
https://github.com/qt/qtbase/commit/ef36fd02178482cd312ea551303856ef563421af

Signed-off-by: Ivailo Monev <xakepa10@laimg.moc>
18 files changed:
src/core/global/qnumeric.cpp
src/core/io/qdatastream.cpp
src/core/io/qfilesystemengine_unix.cpp
src/core/kernel/qmetatype.cpp
src/core/tools/qchar.cpp
src/core/tools/qtimeline.cpp
src/gui/accessible/qaccessiblewidget.cpp
src/gui/dialogs/qprintdialog_unix.cpp
src/gui/graphicsview/qgraphicsscenebsptreeindex.cpp
src/gui/image/qpnghandler.cpp
src/gui/image/qtiffhandler.cpp
src/gui/image/qtiffhandler_p.h
src/gui/painting/qpaintengine_raster.cpp
src/gui/styles/qstylesheetstyle.cpp
src/gui/styles/qwindowsstyle.cpp
src/gui/text/qfontengine.cpp
src/tools/uic/cpp/cppwriteinitialization.cpp
src/xml/kernel/qxmlstream.cpp

index 8a6792e..3bd349c 100644 (file)
@@ -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
 }
 
index 38e2614..96ab20f 100644 (file)
@@ -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
 }
 
 /*!
index ae1431b..86b73bb 100644 (file)
@@ -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
index f86b257..48720cc 100644 (file)
@@ -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;
index dbec9c2..f0446e0 100644 (file)
@@ -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;
 }
index 2853fff..d5d14d4 100644 (file)
@@ -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;
     }
 }
 
index 2b9643d..9fda974 100644 (file)
@@ -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;
         }
     }
 
index 7af8d9a..6962d3a 100644 (file)
@@ -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
index f5112ba..710b712 100644 (file)
@@ -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<QTimerEvent *>(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<QTimerEvent *>(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
index ca23bdd..93f039c 100644 (file)
@@ -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
index 8479987..0f0a4a1 100644 (file)
@@ -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<uint32 *>(buffer);
+    for (int32 x=0; x<width; ++x) {
+        uint32 p = target[x];
+#if Q_BYTE_ORDER == Q_BIG_ENDIAN
+        target[x] = (p & 0xff000000) >> 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<uint32 *>(image->bits()), ORIENTATION_TOPLEFT, stopOnError)) {
                     for (uint32 y=0; y<height; ++y)
-                        convert32BitOrder(image->scanLine(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<uint32 *>(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<uint32 *>(buffer);
-    for (int32 x=0; x<width; ++x) {
-        uint32 p = target[x];
-        // convert between ARGB and ABGR
-        target[x] = (p & 0xff000000)
-                    | ((p & 0x00ff0000) >> 16)
-                    | (p & 0x0000ff00)
-                    | ((p & 0x000000ff) << 16);
-    }
-}
-
-void QTiffHandler::convert32BitOrderBigEndian(void *buffer, int width)
-{
-    uint32 *target = reinterpret_cast<uint32 *>(buffer);
-    for (int32 x=0; x<width; ++x) {
-        uint32 p = target[x];
-        target[x] = (p & 0xff000000) >> 24
-                    | (p & 0x00ff0000) << 8
-                    | (p & 0x0000ff00) << 8
-                    | (p & 0x000000ff) << 8;
-    }
-}
-
 QT_END_NAMESPACE
index a5f5cc6..6b68b65 100644 (file)
@@ -60,8 +60,6 @@ public:
         LzwCompression = 1
     };
 private:
-    void convert32BitOrder(void *buffer, int width);
-    void convert32BitOrderBigEndian(void *buffer, int width);
     int compression;
 };
 
index af7084f..ac365db 100644 (file)
@@ -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
 }
 
 /*!
index 6f0a798..a4b0e66 100644 (file)
@@ -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:
index b419f1b..600d12d 100644 (file)
@@ -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:
index 835e38a..2b9f9d4 100644 (file)
@@ -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;
     }
index 1147db5..407ad97 100644 (file)
@@ -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);
 }
index 21400ca..bf668cd 100644 (file)
@@ -1199,7 +1199,7 @@ inline int QXmlStreamReaderPrivate::fastScanContentCharList()
                 break;
             }
             return n;
-        } break;
+        }
         case '\r':
             if ((c = filterCarriageReturn()) == 0)
                 return n;