diff --git a/src/corelib/text/qbytearrayalgorithms.h b/src/corelib/text/qbytearrayalgorithms.h index 649ec2e39bd..5b2b71838fa 100644 --- a/src/corelib/text/qbytearrayalgorithms.h +++ b/src/corelib/text/qbytearrayalgorithms.h @@ -139,8 +139,10 @@ Q_CORE_EXPORT int qstrnicmp(const char *, const char *, size_t len); Q_CORE_EXPORT int qstrnicmp(const char *, qsizetype, const char *, qsizetype = -1); // implemented in qvsnprintf.cpp -Q_CORE_EXPORT int qvsnprintf(char *str, size_t n, const char *fmt, va_list ap); -Q_CORE_EXPORT int qsnprintf(char *str, size_t n, const char *fmt, ...); +Q_CORE_EXPORT int qvsnprintf(char *str, size_t n, const char *fmt, va_list ap) + Q_ATTRIBUTE_FORMAT_PRINTF(3, 0); +Q_CORE_EXPORT int qsnprintf(char *str, size_t n, const char *fmt, ...) + Q_ATTRIBUTE_FORMAT_PRINTF(3, 4); // qChecksum: Internet checksum Q_CORE_EXPORT quint16 qChecksum(QByteArrayView data, Qt::ChecksumType standard = Qt::ChecksumIso3309); diff --git a/tests/auto/corelib/text/qbytearray/tst_qbytearray.cpp b/tests/auto/corelib/text/qbytearray/tst_qbytearray.cpp index fea603faed7..29103b5e3d4 100644 --- a/tests/auto/corelib/text/qbytearray/tst_qbytearray.cpp +++ b/tests/auto/corelib/text/qbytearray/tst_qbytearray.cpp @@ -716,7 +716,11 @@ void tst_QByteArray::qvsnprintf() #ifndef Q_OS_WIN memset(buf, 42, sizeof(buf)); + QT_WARNING_PUSH + QT_WARNING_DISABLE_GCC("-Wformat-zero-length") + QT_WARNING_DISABLE_CLANG("-Wformat-zero-length") QCOMPARE(::qsnprintf(buf, 10, ""), 0); + QT_WARNING_POP #endif }