Use q20::{cmp_{equal,not_equal,{less,greater}{,_equal}} around the code
- edited a few places that compare signed and unsigned integer variables, using C-style casts. The cmp_<name> functions allow to do such comparisons in a convenient way. Task-number: QTBUG-105464 Change-Id: I912893a47a1c93d163b0fbeccb61602adca80dd2 Reviewed-by: Ivan Solovev <ivan.solovev@qt.io>
This commit is contained in:
parent
7a90ed1238
commit
b4b90bfbaf
@ -24,6 +24,8 @@
|
|||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#include <QtCore/q20utility.h>
|
||||||
|
|
||||||
QT_BEGIN_NAMESPACE
|
QT_BEGIN_NAMESPACE
|
||||||
|
|
||||||
struct QDefaultColorTables
|
struct QDefaultColorTables
|
||||||
@ -1773,7 +1775,7 @@ void dither_to_Mono(QImageData *dst, const QImageData *src,
|
|||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
while (p < end) {
|
while (p < end) {
|
||||||
if ((uint)qGray(*p++) < qt_bayer_matrix[j++&15][i&15])
|
if (q20::cmp_less(qGray(*p++), qt_bayer_matrix[j++&15][i&15]))
|
||||||
*m |= 1 << bit;
|
*m |= 1 << bit;
|
||||||
if (bit == 0) {
|
if (bit == 0) {
|
||||||
m++;
|
m++;
|
||||||
|
@ -17,6 +17,8 @@
|
|||||||
#include "qtexttable.h"
|
#include "qtexttable.h"
|
||||||
#include "qtextengine_p.h"
|
#include "qtextengine_p.h"
|
||||||
|
|
||||||
|
#include <QtCore/q20utility.h>
|
||||||
|
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
|
||||||
QT_BEGIN_NAMESPACE
|
QT_BEGIN_NAMESPACE
|
||||||
@ -461,13 +463,13 @@ int QTextDocumentPrivate::remove_string(int pos, uint length, QTextUndoCommand::
|
|||||||
{
|
{
|
||||||
Q_ASSERT(pos >= 0);
|
Q_ASSERT(pos >= 0);
|
||||||
Q_ASSERT(blocks.length() == fragments.length());
|
Q_ASSERT(blocks.length() == fragments.length());
|
||||||
Q_ASSERT(blocks.length() >= pos+(int)length);
|
Q_ASSERT(q20::cmp_greater_equal(blocks.length(), pos+length));
|
||||||
|
|
||||||
int b = blocks.findNode(pos);
|
int b = blocks.findNode(pos);
|
||||||
uint x = fragments.findNode(pos);
|
uint x = fragments.findNode(pos);
|
||||||
|
|
||||||
Q_ASSERT(blocks.size(b) > length);
|
Q_ASSERT(blocks.size(b) > length);
|
||||||
Q_ASSERT(x && fragments.position(x) == (uint)pos && fragments.size(x) == length);
|
Q_ASSERT(x && q20::cmp_equal(fragments.position(x), pos) && fragments.size(x) == length);
|
||||||
Q_ASSERT(noBlockInString(QStringView{text}.mid(fragments.fragment(x)->stringPosition, length)));
|
Q_ASSERT(noBlockInString(QStringView{text}.mid(fragments.fragment(x)->stringPosition, length)));
|
||||||
|
|
||||||
blocks.setSize(b, blocks.size(b)-length);
|
blocks.setSize(b, blocks.size(b)-length);
|
||||||
@ -725,7 +727,7 @@ void QTextDocumentPrivate::setCharFormat(int pos, int length, const QTextCharFor
|
|||||||
appendUndoItem(c);
|
appendUndoItem(c);
|
||||||
|
|
||||||
pos += length;
|
pos += length;
|
||||||
Q_ASSERT(pos == (int)(it.position() + fragment->size_array[0]) || pos >= endPos);
|
Q_ASSERT(q20::cmp_equal(pos, (it.position() + fragment->size_array[0])) || pos >= endPos);
|
||||||
}
|
}
|
||||||
|
|
||||||
int n = fragments.findNode(startPos - 1);
|
int n = fragments.findNode(startPos - 1);
|
||||||
@ -1036,7 +1038,7 @@ void QTextDocumentPrivate::appendUndoItem(const QTextUndoCommand &c)
|
|||||||
clearUndoRedoStacks(QTextDocument::RedoStack);
|
clearUndoRedoStacks(QTextDocument::RedoStack);
|
||||||
|
|
||||||
if (editBlock != 0 && editBlockCursorPosition >= 0) { // we had a beginEditBlock() with a cursor position
|
if (editBlock != 0 && editBlockCursorPosition >= 0) { // we had a beginEditBlock() with a cursor position
|
||||||
if (c.pos != (quint32) editBlockCursorPosition) { // and that cursor position is different from the command
|
if (q20::cmp_not_equal(c.pos, editBlockCursorPosition)) { // and that cursor position is different from the command
|
||||||
// generate a CursorMoved undo item
|
// generate a CursorMoved undo item
|
||||||
QT_INIT_TEXTUNDOCOMMAND(cc, QTextUndoCommand::CursorMoved, true, QTextUndoCommand::MoveCursor,
|
QT_INIT_TEXTUNDOCOMMAND(cc, QTextUndoCommand::CursorMoved, true, QTextUndoCommand::MoveCursor,
|
||||||
0, 0, editBlockCursorPosition, 0, 0);
|
0, 0, editBlockCursorPosition, 0, 0);
|
||||||
|
@ -6,6 +6,7 @@
|
|||||||
#include <QtFbSupport/private/qfbwindow_p.h>
|
#include <QtFbSupport/private/qfbwindow_p.h>
|
||||||
#include <QtCore/QFile>
|
#include <QtCore/QFile>
|
||||||
#include <QtCore/QRegularExpression>
|
#include <QtCore/QRegularExpression>
|
||||||
|
#include <QtCore/q20utility.h>
|
||||||
#include <QtGui/QPainter>
|
#include <QtGui/QPainter>
|
||||||
|
|
||||||
#include <private/qcore_unix_p.h> // overrides QT_OPEN
|
#include <private/qcore_unix_p.h> // overrides QT_OPEN
|
||||||
@ -69,16 +70,16 @@ static QRect determineGeometry(const fb_var_screeninfo &vinfo, const QRect &user
|
|||||||
if (userGeometry.isValid()) {
|
if (userGeometry.isValid()) {
|
||||||
w = userGeometry.width();
|
w = userGeometry.width();
|
||||||
h = userGeometry.height();
|
h = userGeometry.height();
|
||||||
if ((uint)w > vinfo.xres)
|
if (q20::cmp_greater(w, vinfo.xres))
|
||||||
w = vinfo.xres;
|
w = vinfo.xres;
|
||||||
if ((uint)h > vinfo.yres)
|
if (q20::cmp_greater(h, vinfo.yres))
|
||||||
h = vinfo.yres;
|
h = vinfo.yres;
|
||||||
|
|
||||||
int xxoff = userGeometry.x(), yyoff = userGeometry.y();
|
int xxoff = userGeometry.x(), yyoff = userGeometry.y();
|
||||||
if (xxoff != 0 || yyoff != 0) {
|
if (xxoff != 0 || yyoff != 0) {
|
||||||
if (xxoff < 0 || xxoff + w > (int)(vinfo.xres))
|
if (xxoff < 0 || q20::cmp_greater(xxoff + w, vinfo.xres))
|
||||||
xxoff = vinfo.xres - w;
|
xxoff = vinfo.xres - w;
|
||||||
if (yyoff < 0 || yyoff + h > (int)(vinfo.yres))
|
if (yyoff < 0 || q20::cmp_greater(yyoff + h, vinfo.yres))
|
||||||
yyoff = vinfo.yres - h;
|
yyoff = vinfo.yres - h;
|
||||||
xoff += xxoff;
|
xoff += xxoff;
|
||||||
yoff += yyoff;
|
yoff += yyoff;
|
||||||
|
@ -2840,7 +2840,7 @@ void QTreeView::expandToDepth(int depth)
|
|||||||
d->interruptDelayedItemsLayout();
|
d->interruptDelayedItemsLayout();
|
||||||
d->layout(-1);
|
d->layout(-1);
|
||||||
for (int i = 0; i < d->viewItems.size(); ++i) {
|
for (int i = 0; i < d->viewItems.size(); ++i) {
|
||||||
if (d->viewItems.at(i).level <= (uint)depth) {
|
if (q20::cmp_less_equal(d->viewItems.at(i).level, depth)) {
|
||||||
d->viewItems[i].expanded = true;
|
d->viewItems[i].expanded = true;
|
||||||
d->layout(i);
|
d->layout(i);
|
||||||
d->storeExpanded(d->viewItems.at(i).index);
|
d->storeExpanded(d->viewItems.at(i).index);
|
||||||
@ -3463,7 +3463,7 @@ void QTreeViewPrivate::layout(int i, bool recursiveExpanding, bool afterIsUninit
|
|||||||
}
|
}
|
||||||
viewItems.resize(count);
|
viewItems.resize(count);
|
||||||
afterIsUninitialized = true;
|
afterIsUninitialized = true;
|
||||||
} else if (viewItems[i].total != (uint)count) {
|
} else if (q20::cmp_not_equal(viewItems[i].total, count)) {
|
||||||
if (!afterIsUninitialized)
|
if (!afterIsUninitialized)
|
||||||
insertViewItems(i + 1, count, QTreeViewItem()); // expand
|
insertViewItems(i + 1, count, QTreeViewItem()); // expand
|
||||||
else if (count > 0)
|
else if (count > 0)
|
||||||
|
@ -14,6 +14,7 @@
|
|||||||
#ifndef QT_NO_DEBUG
|
#ifndef QT_NO_DEBUG
|
||||||
#include "qdebug.h"
|
#include "qdebug.h"
|
||||||
#endif
|
#endif
|
||||||
|
#include <QtCore/q20utility.h>
|
||||||
|
|
||||||
#include <limits.h>
|
#include <limits.h>
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
@ -2234,7 +2235,7 @@ int QStyle::sliderPositionFromValue(int min, int max, int logicalValue, int span
|
|||||||
if (range > (uint)INT_MAX/4096) {
|
if (range > (uint)INT_MAX/4096) {
|
||||||
double dpos = (double(p))/(double(range)/span);
|
double dpos = (double(p))/(double(range)/span);
|
||||||
return int(dpos);
|
return int(dpos);
|
||||||
} else if (range > (uint)span) {
|
} else if (q20::cmp_greater(range, span)) {
|
||||||
return (2 * p * span + range) / (2*range);
|
return (2 * p * span + range) / (2*range);
|
||||||
} else {
|
} else {
|
||||||
uint div = span / range;
|
uint div = span / range;
|
||||||
@ -2273,7 +2274,7 @@ int QStyle::sliderValueFromPosition(int min, int max, int pos, int span, bool up
|
|||||||
|
|
||||||
const qint64 range = qint64(max) - min;
|
const qint64 range = qint64(max) - min;
|
||||||
|
|
||||||
if ((uint)span > range) {
|
if (q20::cmp_greater(span, range)) {
|
||||||
const int tmp = (2 * range * pos + span) / (qint64(2) * span);
|
const int tmp = (2 * range * pos + span) / (qint64(2) * span);
|
||||||
return upsideDown ? max - tmp : tmp + min;
|
return upsideDown ? max - tmp : tmp + min;
|
||||||
} else {
|
} else {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user