mirror of
https://github.com/LongSoft/UEFITool.git
synced 2024-11-24 17:08:23 +08:00
Fix static analysis issues found by PVS-Studio and Coverity
This commit is contained in:
parent
fb5a81ebda
commit
d8bdac174d
@ -50,13 +50,6 @@ void QHexDocument::setData(QHexBuffer* buffer)
|
|||||||
qint64 QHexDocument::length() const { return m_buffer ? m_buffer->length() : 0; }
|
qint64 QHexDocument::length() const { return m_buffer ? m_buffer->length() : 0; }
|
||||||
uchar QHexDocument::at(int offset) const { return m_buffer->at(offset); }
|
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::undo() { m_undostack.undo(); Q_EMIT changed(); }
|
||||||
void QHexDocument::redo() { m_undostack.redo(); 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)); }
|
void QHexDocument::insert(qint64 offset, uchar b) { this->insert(offset, QByteArray(1, b)); }
|
||||||
|
@ -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(char *data, int size, QObject* parent = nullptr);
|
||||||
template<typename T> static QHexDocument* fromMemory(const QByteArray& ba, 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* fromBuffer(QHexBuffer* buffer, QObject* parent = nullptr);
|
||||||
static QHexDocument* fromFile(QString filename, QObject* parent = nullptr);
|
|
||||||
static QHexDocument* create(QObject* parent = nullptr);
|
static QHexDocument* create(QObject* parent = nullptr);
|
||||||
|
|
||||||
Q_SIGNALS:
|
Q_SIGNALS:
|
||||||
|
@ -91,7 +91,7 @@ bool match(const QByteArray& data, const QString& pattern)
|
|||||||
|
|
||||||
namespace {
|
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<quint8>::max()) return QHexFindOptions::Int8;
|
||||||
if(val <= std::numeric_limits<quint16>::max()) return QHexFindOptions::Int16;
|
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)
|
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(startoffset == -1) startoffset = static_cast<qint64>(hexview->offset());
|
||||||
|
|
||||||
if(mode == QHexFindMode::Hex && QHEXVIEW_VARIANT_EQ(value, String))
|
if(mode == QHexFindMode::Hex && QHEXVIEW_VARIANT_EQ(value, String))
|
||||||
|
@ -483,10 +483,10 @@ void QHexView::drawSeparators(QPainter* p) const
|
|||||||
QLineF l1(this->hexColumnX(), 0, this->hexColumnX(), this->height());
|
QLineF l1(this->hexColumnX(), 0, this->hexColumnX(), this->height());
|
||||||
QLineF l2(this->asciiColumnX(), 0, this->asciiColumnX(), 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);
|
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);
|
p->drawLine(l2);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user