diff options
author | Marc Mutz <[email protected]> | 2024-07-18 14:09:06 +0200 |
---|---|---|
committer | Marc Mutz <[email protected]> | 2024-07-30 22:45:07 +0200 |
commit | 63295f43e70955a194602a7acf39013f124e14b7 (patch) | |
tree | 67e73a29699e564289d779be8b7aba275d5a2b1d | |
parent | 85f37700e8ce5d596348b5ff6d589dc419d562e9 (diff) |
Fix -Wformat issues in our headers
Before we add __attribute__((format(printf))) to qsnprintf(), we need
to make sure our code is clean.
Pick-to: 6.8 6.7 6.5 6.2 5.15
Task-number: QTBUG-127110
Change-Id: I7411ff0036482ad68bd5867b624518f68f249229
Reviewed-by: Thiago Macieira <[email protected]>
-rw-r--r-- | src/testlib/qtest.h | 10 | ||||
-rw-r--r-- | src/testlib/qtesttostring.h | 7 |
2 files changed, 11 insertions, 6 deletions
diff --git a/src/testlib/qtest.h b/src/testlib/qtest.h index ff3744a48e9..9b8f12ec545 100644 --- a/src/testlib/qtest.h +++ b/src/testlib/qtest.h @@ -56,8 +56,9 @@ bool _q_compareSequence(ActualIterator actualIt, ActualIterator actualEnd, if (!isOk) { qsnprintf(msg, sizeof(msg), "Compared lists have different sizes.\n" - " Actual (%s) size: %zd\n" - " Expected (%s) size: %zd", actual, actualSize, + " Actual (%s) size: %lld\n" + " Expected (%s) size: %lld", + actual, qlonglong(actualSize), expected, expectedSize); } @@ -67,9 +68,10 @@ bool _q_compareSequence(ActualIterator actualIt, ActualIterator actualEnd, char *val1 = toString(*actualIt); char *val2 = toString(*expectedIt); - qsnprintf(msg, sizeof(msg), "Compared lists differ at index %zd.\n" + qsnprintf(msg, sizeof(msg), "Compared lists differ at index %lld.\n" " Actual (%s): %s\n" - " Expected (%s): %s", i, actual, val1 ? val1 : "<null>", + " Expected (%s): %s", + qlonglong(i), actual, val1 ? val1 : "<null>", expected, val2 ? val2 : "<null>"); isOk = false; diff --git a/src/testlib/qtesttostring.h b/src/testlib/qtesttostring.h index bcd70501f67..5fffa398132 100644 --- a/src/testlib/qtesttostring.h +++ b/src/testlib/qtesttostring.h @@ -206,7 +206,9 @@ template<> inline char *toString(const QChar &c) template<> inline char *toString(const QModelIndex &idx) { char msg[128]; - qsnprintf(msg, sizeof(msg), "QModelIndex(%d,%d,%p,%p)", idx.row(), idx.column(), idx.internalPointer(), idx.model()); + qsnprintf(msg, sizeof(msg), "QModelIndex(%d,%d,%p,%p)", + idx.row(), idx.column(), idx.internalPointer(), + static_cast<const void*>(idx.model())); return qstrdup(msg); } #endif @@ -319,7 +321,8 @@ struct QCborValueFormatter { QScopedArrayPointer<char> hold(format(taggedValue)); char *buf = new char[BufferLen]; - qsnprintf(buf, BufferLen, "QCborValue(QCborTag(%llu), %s)", tag, hold.get()); + qsnprintf(buf, BufferLen, "QCborValue(QCborTag(%llu), %s)", + qToUnderlying(tag), hold.get()); return buf; } |