Try to workaround bogus compiler warning in gcc 9 for ARMv7
../../src/corelib/io/qurlidna.cpp: In function ‘QString qt_ACE_do(QStringView, AceOperation, AceLeadingDot)’:
../../src/corelib/io/qurlidna.cpp:2543:23: error: ‘int __builtin_memcmp_eq(const void*, const void*, unsigned int)’
reading 8 bytes from a region of size 2 [-Werror=stringop-overflow=]
if (memcmp(result.constData() + prevLen, acePrefixUtf16, sizeof acePrefixUtf16) == 0)
~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
cc1plus: all warnings being treated as errors
In function ‘bool operator==(const QByteArray&, const QByteArray&)’,
inlined from ‘virtual void (* QLinuxFbIntegration::platformFunction(const QByteArray&) const)()’
at ../../src/plugins/platforms/linuxfb/qlinuxfbintegration.cpp:185:18:
include/QtCore/../../../../src/corelib/text/qbytearray.h:571:45: error:
‘int __builtin_memcmp_eq(const void*, const void*, unsigned int)’ reading 17 bytes from
a region of size 1 [-Werror=stringop-overflow=]
The warnings/errors are bogus. Fix them by using QStringView::sliced() and de-inlining the
comparison operator for QByteArray.
Change-Id: I24956fe74a7989e75cd03d717570b8fca493ab23
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
bb10
parent
9117e3850b
commit
563fbe79e5
|
|
@ -2548,8 +2548,7 @@ QString qt_ACE_do(QStringView domain, AceOperation op, AceLeadingDot dot)
|
|||
// ACE form domains contain only ASCII characters, but we can't consider them simple
|
||||
// is this an ACE form?
|
||||
// the shortest valid ACE domain is 6 characters long (U+0080 would be 1, but it's not allowed)
|
||||
static const ushort acePrefixUtf16[] = { 'x', 'n', '-', '-' };
|
||||
if (memcmp(result.constData() + prevLen, acePrefixUtf16, sizeof acePrefixUtf16) == 0)
|
||||
if (QStringView{result}.sliced(prevLen).startsWith(u"xn--"))
|
||||
simple = false;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -3104,6 +3104,10 @@ QDataStream &operator>>(QDataStream &in, QByteArray &ba)
|
|||
|
||||
\sa QByteArray::compare()
|
||||
*/
|
||||
bool operator==(const QByteArray &a1, const QByteArray &a2) noexcept
|
||||
{
|
||||
return (a1.size() == a2.size()) && (memcmp(a1.constData(), a2.constData(), a1.size())==0);
|
||||
}
|
||||
|
||||
/*! \fn bool operator==(const QByteArray &a1, const char *a2)
|
||||
\relates QByteArray
|
||||
|
|
|
|||
|
|
@ -567,8 +567,7 @@ inline int QByteArray::compare(const QByteArray &a, Qt::CaseSensitivity cs) cons
|
|||
return cs == Qt::CaseSensitive ? qstrcmp(*this, a) :
|
||||
qstrnicmp(data(), size(), a.data(), a.size());
|
||||
}
|
||||
inline bool operator==(const QByteArray &a1, const QByteArray &a2) noexcept
|
||||
{ return (a1.size() == a2.size()) && (memcmp(a1.constData(), a2.constData(), a1.size())==0); }
|
||||
Q_CORE_EXPORT bool operator==(const QByteArray &a1, const QByteArray &a2) noexcept;
|
||||
inline bool operator==(const QByteArray &a1, const char *a2) noexcept
|
||||
{ return a2 ? qstrcmp(a1,a2) == 0 : a1.isEmpty(); }
|
||||
inline bool operator==(const char *a1, const QByteArray &a2) noexcept
|
||||
|
|
|
|||
Loading…
Reference in New Issue