From b3651868609cc1d4b9316d8ec65a0656b421970e Mon Sep 17 00:00:00 2001 From: Andrei Golubev Date: Fri, 22 Apr 2022 10:15:02 +0200 Subject: [PATCH] Fix unused variables in qtbase clang compiler recently got smarter and detects "pseudo used variable" patterns where we declare a variable and only use it in self-increments, self-decrements and other similar expressions Errors: qtbase/src/corelib/text/qlocale.cpp:3898:9: error: variable 'group_cnt' set but not used [-Werror,-Wunused-but-set-variable] int group_cnt = 0; // counts number of group chars ^ qtbase/src/corelib/text/qunicodetools.cpp:1372:21: error: variable 'uc' set but not used [-Werror,-Wunused-but-set-variable] const char16_t *uc = text + from; ^ and more of the kind Remove the ones that have no usage, mark others with [[maybe_unused]] Pick-to: 6.3 6.2 Change-Id: Ib2d0722110e3da8c39e29ec78c0ec290d064c970 Reviewed-by: Thiago Macieira --- src/corelib/text/qlocale.cpp | 2 -- src/corelib/text/qunicodetools.cpp | 8 -------- src/gui/kernel/qplatformcursor.cpp | 6 +----- src/network/access/qnetworkdiskcache.cpp | 2 +- .../input/evdevmouse/qevdevmousehandler.cpp | 2 -- 5 files changed, 2 insertions(+), 18 deletions(-) diff --git a/src/corelib/text/qlocale.cpp b/src/corelib/text/qlocale.cpp index bdd896b4c8..8a272c6e49 100644 --- a/src/corelib/text/qlocale.cpp +++ b/src/corelib/text/qlocale.cpp @@ -3904,7 +3904,6 @@ bool QLocaleData::numberToCLocale(QStringView s, QLocale::NumberOptions number_o decltype(length) idx = 0; int digitsInGroup = 0; - int group_cnt = 0; // counts number of group chars int decpt_idx = -1; int last_separator_idx = -1; int start_of_digits_idx = -1; @@ -3974,7 +3973,6 @@ bool QLocaleData::numberToCLocale(QStringView s, QLocale::NumberOptions number_o } last_separator_idx = idx; - ++group_cnt; digitsInGroup = 0; // don't add the group separator diff --git a/src/corelib/text/qunicodetools.cpp b/src/corelib/text/qunicodetools.cpp index ff11baa99a..3c96931ea7 100644 --- a/src/corelib/text/qunicodetools.cpp +++ b/src/corelib/text/qunicodetools.cpp @@ -1369,7 +1369,6 @@ static qsizetype indic_nextSyllableBoundary(QChar::Script script, const char16_t static void indicAttributes(QChar::Script script, const char16_t *text, qsizetype from, qsizetype len, QCharAttributes *attributes) { qsizetype end = from + len; - const char16_t *uc = text + from; attributes += from; qsizetype i = 0; while (i < len) { @@ -1381,7 +1380,6 @@ static void indicAttributes(QChar::Script script, const char16_t *text, qsizetyp i++; while (i < boundary) { attributes[i].graphemeBoundary = false; - ++uc; ++i; } assert(i == boundary); @@ -1632,7 +1630,6 @@ finish: static void tibetanAttributes(QChar::Script script, const char16_t *text, qsizetype from, qsizetype len, QCharAttributes *attributes) { qsizetype end = from + len; - const char16_t *uc = text + from; qsizetype i = 0; Q_UNUSED(script); attributes += from; @@ -1646,7 +1643,6 @@ static void tibetanAttributes(QChar::Script script, const char16_t *text, qsizet i++; while (i < boundary) { attributes[i].graphemeBoundary = false; - ++uc; ++i; } assert(i == boundary); @@ -1847,7 +1843,6 @@ static qsizetype myanmar_nextSyllableBoundary(const char16_t *s, qsizetype start static void myanmarAttributes(QChar::Script script, const char16_t *text, qsizetype from, qsizetype len, QCharAttributes *attributes) { qsizetype end = from + len; - const char16_t *uc = text + from; qsizetype i = 0; Q_UNUSED(script); attributes += from; @@ -1863,7 +1858,6 @@ static void myanmarAttributes(QChar::Script script, const char16_t *text, qsizet i++; while (i < boundary) { attributes[i].graphemeBoundary = false; - ++uc; ++i; } assert(i == boundary); @@ -2183,7 +2177,6 @@ static qsizetype khmer_nextSyllableBoundary(const char16_t *s, qsizetype start, static void khmerAttributes(QChar::Script script, const char16_t *text, qsizetype from, qsizetype len, QCharAttributes *attributes) { qsizetype end = from + len; - const char16_t *uc = text + from; qsizetype i = 0; Q_UNUSED(script); attributes += from; @@ -2197,7 +2190,6 @@ static void khmerAttributes(QChar::Script script, const char16_t *text, qsizetyp i++; while ( i < boundary ) { attributes[i].graphemeBoundary = false; - ++uc; ++i; } assert( i == boundary ); diff --git a/src/gui/kernel/qplatformcursor.cpp b/src/gui/kernel/qplatformcursor.cpp index 1330b5bf31..825cb435f8 100644 --- a/src/gui/kernel/qplatformcursor.cpp +++ b/src/gui/kernel/qplatformcursor.cpp @@ -619,7 +619,7 @@ void QPlatformCursorImage::set(const uchar *data, const uchar *mask, int p = 0; int d, m; - int x = -1, w = 0; + int x = -1; uchar *cursor_data = cursorImage.bits(); qsizetype bpl = cursorImage.bytesPerLine(); @@ -641,15 +641,11 @@ void QPlatformCursorImage::set(const uchar *data, const uchar *mask, x = j*8+b; else if (x >= 0 && !m) { x = -1; - w = 0; } - if (m) - w++; } } if (x >= 0) { x = -1; - w = 0; } cursor_data += bpl; } diff --git a/src/network/access/qnetworkdiskcache.cpp b/src/network/access/qnetworkdiskcache.cpp index 069267e543..dff16adde7 100644 --- a/src/network/access/qnetworkdiskcache.cpp +++ b/src/network/access/qnetworkdiskcache.cpp @@ -536,7 +536,7 @@ qint64 QNetworkDiskCache::expire() } } - int removedFiles = 0; + [[maybe_unused]] int removedFiles = 0; // used under QNETWORKDISKCACHE_DEBUG qint64 goal = (maximumCacheSize() * 9) / 10; QMultiMap::const_iterator i = cacheItems.constBegin(); while (i != cacheItems.constEnd()) { diff --git a/src/platformsupport/input/evdevmouse/qevdevmousehandler.cpp b/src/platformsupport/input/evdevmouse/qevdevmousehandler.cpp index 2012022656..80a2e0e8ff 100644 --- a/src/platformsupport/input/evdevmouse/qevdevmousehandler.cpp +++ b/src/platformsupport/input/evdevmouse/qevdevmousehandler.cpp @@ -219,7 +219,6 @@ void QEvdevMouseHandler::readMouseData() int n = 0; bool posChanged = false, btnChanged = false; bool pendingMouseEvent = false; - int eventCompressCount = 0; forever { int result = QT_READ(m_fd, reinterpret_cast(buffer) + n, sizeof(buffer) - n); @@ -326,7 +325,6 @@ void QEvdevMouseHandler::readMouseData() posChanged = false; if (m_compression) { pendingMouseEvent = true; - eventCompressCount++; } else { sendMouseEvent(); }