Fix build for Android with android-clang in r17

Task-number: QTBUG-67464
Change-Id: Ib971a5da82b31bce9ac1c9ac623ad7d5302cfaec
Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io>
This commit is contained in:
Liang Qi 2018-06-05 13:13:12 +02:00
parent 8c33b79823
commit 62abbe34b8
8 changed files with 18 additions and 24 deletions

View File

@ -3990,7 +3990,7 @@ Q_GLOBAL_STATIC(QInternal_CallBackTable, global_callback_table)
bool QInternal::registerCallback(Callback cb, qInternalCallback callback)
{
if (cb >= 0 && cb < QInternal::LastCallback) {
if (unsigned(cb) < unsigned(QInternal::LastCallback)) {
QInternal_CallBackTable *cbt = global_callback_table();
cbt->callbacks.resize(cb + 1);
cbt->callbacks[cb].append(callback);
@ -4001,7 +4001,7 @@ bool QInternal::registerCallback(Callback cb, qInternalCallback callback)
bool QInternal::unregisterCallback(Callback cb, qInternalCallback callback)
{
if (cb >= 0 && cb < QInternal::LastCallback) {
if (unsigned(cb) < unsigned(QInternal::LastCallback)) {
if (global_callback_table.exists()) {
QInternal_CallBackTable *cbt = global_callback_table();
return (bool) cbt->callbacks[cb].removeAll(callback);

View File

@ -315,18 +315,14 @@ QMimeMagicRule::QMimeMagicRule(const QString &type,
break;
case Big32:
case Little32:
if (m_number <= quint32(-1)) {
m_number = m_type == Little32 ? qFromLittleEndian<quint32>(m_number) : qFromBigEndian<quint32>(m_number);
if (m_numberMask != 0)
m_numberMask = m_type == Little32 ? qFromLittleEndian<quint32>(m_numberMask) : qFromBigEndian<quint32>(m_numberMask);
}
m_number = m_type == Little32 ? qFromLittleEndian<quint32>(m_number) : qFromBigEndian<quint32>(m_number);
if (m_numberMask != 0)
m_numberMask = m_type == Little32 ? qFromLittleEndian<quint32>(m_numberMask) : qFromBigEndian<quint32>(m_numberMask);
Q_FALLTHROUGH();
case Host32:
if (m_number <= quint32(-1)) {
if (m_numberMask == 0)
m_numberMask = quint32(-1);
m_matchFunction = &QMimeMagicRule::matchNumber<quint32>;
}
if (m_numberMask == 0)
m_numberMask = quint32(-1);
m_matchFunction = &QMimeMagicRule::matchNumber<quint32>;
break;
default:
break;

View File

@ -549,7 +549,7 @@ void QPlatformCursorImage::createSystemCursor(int id)
void QPlatformCursorImage::set(Qt::CursorShape id)
{
QPlatformCursorImage *cursor = 0;
if (id >= 0 && id <= Qt::LastCursor) {
if (unsigned(id) <= unsigned(Qt::LastCursor)) {
if (!systemCursorTable[id])
createSystemCursor(id);
cursor = systemCursorTable[id];

View File

@ -664,18 +664,18 @@ QStringList QFileDialogOptions::history() const
void QFileDialogOptions::setLabelText(QFileDialogOptions::DialogLabel label, const QString &text)
{
if (label >= 0 && label < DialogLabelCount)
if (unsigned(label) < unsigned(DialogLabelCount))
d->labels[label] = text;
}
QString QFileDialogOptions::labelText(QFileDialogOptions::DialogLabel label) const
{
return (label >= 0 && label < DialogLabelCount) ? d->labels[label] : QString();
return (unsigned(label) < unsigned(DialogLabelCount)) ? d->labels[label] : QString();
}
bool QFileDialogOptions::isLabelExplicitlySet(DialogLabel label)
{
return label >= 0 && label < DialogLabelCount && !d->labels[label].isEmpty();
return unsigned(label) < unsigned(DialogLabelCount) && !d->labels[label].isEmpty();
}
QUrl QFileDialogOptions::initialDirectory() const

View File

@ -762,7 +762,7 @@ QPageSizePrivate::QPageSizePrivate(QPageSize::PageSizeId pageSizeId)
m_windowsId(0),
m_units(QPageSize::Point)
{
if (pageSizeId >= QPageSize::PageSizeId(0) && pageSizeId <= QPageSize::LastPageSize)
if (unsigned(pageSizeId) <= unsigned(QPageSize::LastPageSize))
init(pageSizeId, QString());
}
@ -1478,7 +1478,7 @@ QRect QPageSize::rectPixels(int resolution) const
QString QPageSize::key(PageSizeId pageSizeId)
{
if (pageSizeId < PageSizeId(0) || pageSizeId > LastPageSize)
if (unsigned(pageSizeId) > unsigned(LastPageSize))
return QString();
return QString::fromUtf8(qt_pageSizes[pageSizeId].mediaOption);
}
@ -1497,7 +1497,7 @@ static QString msgImperialPageSizeInch(int width, int height)
QString QPageSize::name(PageSizeId pageSizeId)
{
if (pageSizeId < PageSizeId(0) || pageSizeId > LastPageSize)
if (unsigned(pageSizeId) > unsigned(LastPageSize))
return QString();
switch (pageSizeId) {

View File

@ -64,8 +64,6 @@ HeaderSize entry_size(const QByteArray &name, const QByteArray &value)
const unsigned sum = unsigned(name.size()) + value.size();
if (std::numeric_limits<unsigned>::max() - 32 < sum)
return HeaderSize();
if (sum + 32 > std::numeric_limits<quint32>::max())
return HeaderSize();
return HeaderSize(true, quint32(sum + 32));
}

View File

@ -139,7 +139,7 @@ static const int NumEntries = sizeof(entries) / sizeof(entries[0]);
*/
const char * QTest::benchmarkMetricName(QBenchmarkMetric metric)
{
if (metric >= 0 && metric < QTest::NumEntries)
if (unsigned(metric) < unsigned(QTest::NumEntries))
return entries[metric].name;
return "";
@ -151,7 +151,7 @@ const char * QTest::benchmarkMetricName(QBenchmarkMetric metric)
*/
const char * QTest::benchmarkMetricUnit(QBenchmarkMetric metric)
{
if (metric >= 0 && metric < QTest::NumEntries)
if (unsigned(metric) < unsigned(QTest::NumEntries))
return entries[metric].unit;
return "";

View File

@ -1005,7 +1005,7 @@ Qt::DayOfWeek QCalendarModel::dayOfWeekForColumn(int column) const
int QCalendarModel::columnForDayOfWeek(Qt::DayOfWeek day) const
{
if (day < 1 || day > 7)
if (day < 1 || unsigned(day) > unsigned(7))
return -1;
int column = (int)day - (int)m_firstDay;
if (column < 0)