Fix static analysis issues found by PVS-Studio and Coverity

This commit is contained in:
Nikolaj Schlej 2023-04-23 10:05:37 -07:00 committed by Nikolaj Schlej
parent fb5a81ebda
commit d8bdac174d
4 changed files with 4 additions and 12 deletions

View File

@ -50,13 +50,6 @@ void QHexDocument::setData(QHexBuffer* buffer)
qint64 QHexDocument::length() const { return m_buffer ? m_buffer->length() : 0; }
uchar QHexDocument::at(int offset) const { return m_buffer->at(offset); }
QHexDocument* QHexDocument::fromFile(QString filename, QObject* parent)
{
QFile f(filename);
f.open(QFile::ReadOnly);
return QHexDocument::fromMemory<QMemoryBuffer>(f.readAll(), parent);
}
void QHexDocument::undo() { m_undostack.undo(); Q_EMIT changed(); }
void QHexDocument::redo() { m_undostack.redo(); Q_EMIT changed(); }
void QHexDocument::insert(qint64 offset, uchar b) { this->insert(offset, QByteArray(1, b)); }

View File

@ -47,7 +47,6 @@ class QHexDocument: public QObject
template<typename T> static QHexDocument* fromMemory(char *data, int size, QObject* parent = nullptr);
template<typename T> static QHexDocument* fromMemory(const QByteArray& ba, QObject* parent = nullptr);
static QHexDocument* fromBuffer(QHexBuffer* buffer, QObject* parent = nullptr);
static QHexDocument* fromFile(QString filename, QObject* parent = nullptr);
static QHexDocument* create(QObject* parent = nullptr);
Q_SIGNALS:

View File

@ -91,7 +91,7 @@ bool match(const QByteArray& data, const QString& pattern)
namespace {
unsigned int countBits(uint val)
unsigned int countBits(quint64 val)
{
if(val <= std::numeric_limits<quint8>::max()) return QHexFindOptions::Int8;
if(val <= std::numeric_limits<quint16>::max()) return QHexFindOptions::Int16;
@ -257,7 +257,7 @@ QHexPosition offsetToPosition(const QHexOptions* options, qint64 offset) { retur
QPair<qint64, qint64> find(const QHexView* hexview, QVariant value, qint64 startoffset, QHexFindMode mode, unsigned int options, QHexFindDirection fd)
{
qint64 offset = -1, size = 0;
qint64 offset, size = 0;
if(startoffset == -1) startoffset = static_cast<qint64>(hexview->offset());
if(mode == QHexFindMode::Hex && QHEXVIEW_VARIANT_EQ(value, String))

View File

@ -483,10 +483,10 @@ void QHexView::drawSeparators(QPainter* p) const
QLineF l1(this->hexColumnX(), 0, this->hexColumnX(), this->height());
QLineF l2(this->asciiColumnX(), 0, this->asciiColumnX(), this->height());
if(!m_hexdelegate || (m_hexdelegate && !m_hexdelegate->paintSeparator(p, l1, this)))
if(!m_hexdelegate || !m_hexdelegate->paintSeparator(p, l1, this))
p->drawLine(l1);
if(!m_hexdelegate || (m_hexdelegate && !m_hexdelegate->paintSeparator(p, l2, this)))
if(!m_hexdelegate || !m_hexdelegate->paintSeparator(p, l2, this))
p->drawLine(l2);
}