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 <thiago.macieira@intel.com>
This commit is contained in:
Andrei Golubev 2022-04-22 10:15:02 +02:00
parent 242633430b
commit b365186860
5 changed files with 2 additions and 18 deletions

View File

@ -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

View File

@ -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 );

View File

@ -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;
}

View File

@ -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<QDateTime, QString>::const_iterator i = cacheItems.constBegin();
while (i != cacheItems.constEnd()) {

View File

@ -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<char *>(buffer) + n, sizeof(buffer) - n);
@ -326,7 +325,6 @@ void QEvdevMouseHandler::readMouseData()
posChanged = false;
if (m_compression) {
pendingMouseEvent = true;
eventCompressCount++;
} else {
sendMouseEvent();
}