Skip to content

Commit b169801

Browse files
committed
apply some suggestions from the static analyzer.
1 parent fbcc627 commit b169801

34 files changed

+187
-189
lines changed

core/keypad.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,6 @@ static uint8_t keypad_handle_ghosting(uint8_t data, uint8_t queryMask) {
8888
uint64_t ghostMatrix = data;
8989
uint8_t peekRows = 0;
9090
uint8_t ghostData = 0;
91-
uint8_t shift = 0;
9291
for (uint8_t row = 0; row < KEYPAD_ACTUAL_ROWS; row++) {
9392
if (!(queryMask & (1 << row))) {
9493
uint8_t peekData = keypad_peek_keymap(row);

gui/qt/basiccodeviewerwindow.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ void BasicEditor::resizeEvent(QResizeEvent *e)
8989
lineNumberArea->setGeometry(QRect(cr.left(), cr.top(), lineNumberAreaWidth(), cr.height()));
9090
}
9191

92-
void BasicEditor::lineNumberAreaPaintEvent(QPaintEvent *event)
92+
void BasicEditor::lineNumberAreaPaintEvent(QPaintEvent *event) const
9393
{
9494
QPainter painter(lineNumberArea);
9595
painter.fillRect(event->rect(), Qt::lightGray);

gui/qt/basiccodeviewerwindow.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ class BasicEditor : public QPlainTextEdit
6363
BasicEditor(QWidget *parent = nullptr);
6464

6565
void updateDarkMode();
66-
void lineNumberAreaPaintEvent(QPaintEvent *event);
66+
void lineNumberAreaPaintEvent(QPaintEvent *event) const;
6767
int lineNumberAreaWidth();
6868
void toggleHighlight();
6969

gui/qt/basicdebugger.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -111,13 +111,13 @@ void MainWindow::debugBasicClearEdits() {
111111
m_basicCodeIndex = 0;
112112
}
113113

114-
void MainWindow::debugBasicClearHighlights() {
114+
void MainWindow::debugBasicClearHighlights() const {
115115
QList<QTextEdit::ExtraSelection> extraSelections;
116116
ui->basicEdit->setExtraSelections(extraSelections);
117117
ui->basicTempEdit->setExtraSelections(extraSelections);
118118
}
119119

120-
void MainWindow::debugBasicGuiState(bool state) {
120+
void MainWindow::debugBasicGuiState(bool state) const {
121121
if (state) {
122122
ui->btnDebugBasicRun->setText(tr("Run"));
123123
ui->btnDebugBasicRun->setIcon(m_iconRun);

gui/qt/datawidget.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ void DataWidget::updateAllHighlights() {
4040
connect(this, &DataWidget::cursorPositionChanged, this, &DataWidget::highlightCurrentLine);
4141
}
4242

43-
QString DataWidget::getSelectedAddr() {
43+
QString DataWidget::getSelectedAddr() const {
4444
if (!isEnabled()) {
4545
return QStringLiteral("000000");
4646
}
@@ -51,7 +51,7 @@ QString DataWidget::getSelectedAddr() {
5151
return c.selectedText();
5252
}
5353

54-
bool DataWidget::labelCheck() {
54+
bool DataWidget::labelCheck() const {
5555
if (!isEnabled()) {
5656
return false;
5757
}

gui/qt/datawidget.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,8 +59,8 @@ class DataWidget : public QPlainTextEdit {
5959
void addHighlight(const QColor &lightModeColor, const QColor &darkModeColor);
6060
void highlightCurrentLine();
6161
void cursorState(bool movable);
62-
bool labelCheck();
63-
QString getSelectedAddr();
62+
bool labelCheck() const;
63+
QString getSelectedAddr() const;
6464

6565
signals:
6666
void gotoDisasmAddress(uint32_t address);

gui/qt/debugger.cpp

Lines changed: 23 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,7 @@ void MainWindow::debugImportFile(const QString &file) {
186186
}
187187
}
188188

189-
void MainWindow::debugExportFile(const QString &filename) {
189+
void MainWindow::debugExportFile(const QString &filename) const {
190190
if (filename.isEmpty()) {
191191
return;
192192
}
@@ -500,7 +500,7 @@ void MainWindow::debugCommand(int reason, uint32_t data) {
500500
debugRaise();
501501
}
502502

503-
void MainWindow::debugSync() {
503+
void MainWindow::debugSync() const {
504504
if (!guiDebug) {
505505
return;
506506
}
@@ -589,7 +589,7 @@ void MainWindow::debugSync() {
589589
}
590590
}
591591

592-
void MainWindow::debugGuiState(bool state) {
592+
void MainWindow::debugGuiState(bool state) const {
593593
if (state) {
594594
ui->buttonRun->setText(tr("Run"));
595595
ui->buttonRun->setIcon(m_iconRun);
@@ -866,7 +866,7 @@ void MainWindow::debugPopulate() {
866866
// Clock items
867867
// ------------------------------------------------
868868

869-
void MainWindow::debugZeroCycles() {
869+
void MainWindow::debugZeroCycles() const {
870870
debug.totalCycles = 0;
871871
debug.dmaCycles = 0;
872872
debug.flashCacheMisses = 0;
@@ -924,7 +924,7 @@ void MainWindow::breakRemove(uint32_t address) {
924924
}
925925
}
926926

927-
int MainWindow::breakGetMask(int row) {
927+
int MainWindow::breakGetMask(int row) const {
928928
int mask;
929929
if (static_cast<QAbstractButton *>(m_breakpoints->cellWidget(row, BREAK_ENABLE_COL))->isChecked()) {
930930
mask = DBG_MASK_EXEC;
@@ -993,11 +993,11 @@ void MainWindow::breakModified(QTableWidgetItem *item) {
993993
memUpdate();
994994
}
995995

996-
QString MainWindow::breakNextLabel() {
996+
QString MainWindow::breakNextLabel() const {
997997
return QStringLiteral("Label") + QString::number(m_breakpoints->rowCount());
998998
}
999999

1000-
QString MainWindow::watchNextLabel() {
1000+
QString MainWindow::watchNextLabel() const {
10011001
return QStringLiteral("Label") + QString::number(m_watchpoints->rowCount());
10021002
}
10031003

@@ -1140,7 +1140,7 @@ void MainWindow::portSetPrev(QTableWidgetItem *current, [[maybe_unused]] QTableW
11401140
}
11411141
}
11421142

1143-
void MainWindow::portRemoveRow(int row) {
1143+
void MainWindow::portRemoveRow(int row) const {
11441144
uint16_t port = static_cast<uint16_t>(hex2int(m_ports->item(row, PORT_ADDR_COL)->text()));
11451145
debug_ports(port, ~DBG_MASK_NONE, false);
11461146
m_ports->removeRow(row);
@@ -1155,7 +1155,7 @@ void MainWindow::portRemoveSelected() {
11551155
}
11561156
}
11571157

1158-
void MainWindow::portPopulate(int currRow) {
1158+
void MainWindow::portPopulate(int currRow) const {
11591159
uint16_t port = static_cast<uint16_t>(hex2int(m_ports->item(currRow, PORT_ADDR_COL)->text()));
11601160
uint8_t read = static_cast<uint8_t>(port_peek_byte(port));
11611161

@@ -1242,7 +1242,7 @@ bool MainWindow::portAdd(uint16_t port, int mask, bool unset) {
12421242
return true;
12431243
}
12441244

1245-
int MainWindow::portGetMask(int row) {
1245+
int MainWindow::portGetMask(int row) const {
12461246
unsigned int mask = 0;
12471247
if (static_cast<QAbstractButton *>(m_ports->cellWidget(row, PORT_READ_COL))->isChecked()) {
12481248
mask |= DBG_MASK_PORT_READ;
@@ -1589,7 +1589,7 @@ void MainWindow::memUpdate() {
15891589
memDocksUpdate();
15901590
}
15911591

1592-
int MainWindow::watchGetMask(int row) {
1592+
int MainWindow::watchGetMask(int row) const {
15931593
int mask = 0;
15941594
if (static_cast<QAbstractButton *>(m_watchpoints->cellWidget(row, WATCH_READ_COL))->isChecked()) {
15951595
mask |= DBG_MASK_READ;
@@ -1735,7 +1735,7 @@ void MainWindow::batterySetCharging(bool checked) {
17351735
control.batteryCharging = checked;
17361736
}
17371737

1738-
void MainWindow::batterySet(int value) {
1738+
void MainWindow::batterySet(int value) const {
17391739
control.setBatteryStatus = static_cast<uint8_t>(value);
17401740
ui->sliderBattery->setValue(value);
17411741
ui->labelBattery->setText(QString::number(value * 20) + "%");
@@ -1917,14 +1917,14 @@ void MainWindow::equatesAddEquate(const QString &name, uint32_t address) {
19171917
}
19181918

19191919
bool MainWindow::equatesAddEquateInternal(const QString &name, uint32_t address) {
1920-
std::pair<map_value_t::iterator, bool> inserted = disasm.reverse.emplace(name.toUpper().toStdString(), address);
1921-
if (!inserted.second) {
1922-
uint32_t oldAddress = std::exchange(inserted.first->second, address);
1920+
auto [mapIter, inserted] = disasm.reverse.emplace(name.toUpper().toStdString(), address);
1921+
if (!inserted) {
1922+
const uint32_t oldAddress = std::exchange(mapIter->second, address);
19231923
if (oldAddress == address) {
19241924
return false;
19251925
}
1926-
std::pair<map_t::iterator, map_t::iterator> range = disasm.map.equal_range(oldAddress);
1927-
for (map_t::iterator it = range.first; it != range.second; ) {
1926+
auto [addrIt, nameIt] = disasm.map.equal_range(oldAddress);
1927+
for (auto it = addrIt; it != nameIt; ) {
19281928
if (name.compare(QString::fromStdString(it->second), Qt::CaseInsensitive) == 0) {
19291929
it = disasm.map.erase(it);
19301930
} else {
@@ -2004,7 +2004,7 @@ void MainWindow::gotoDisasmAddr(uint32_t address) {
20042004
ui->disasm->setFocus();
20052005
}
20062006

2007-
QAction *MainWindow::gotoDisasmAction(QMenu *menu) {
2007+
QAction *MainWindow::gotoDisasmAction(QMenu *menu) const {
20082008
QAction *gotoDisasm = menu->addAction(ACTION_GOTO_DISASM_VIEW);
20092009
gotoDisasm->setEnabled(m_uiEditMode || ui->debugDisassemblyWidget->isVisible());
20102010
return gotoDisasm;
@@ -2047,7 +2047,7 @@ HexWidget *MainWindow::gotoMemAddrNoRaise(uint32_t address) {
20472047
return memWidget;
20482048
}
20492049

2050-
QAction *MainWindow::gotoMemAction(QMenu *menu, bool vat) {
2050+
QAction *MainWindow::gotoMemAction(QMenu *menu, bool vat) const {
20512051
QAction *gotoMem = menu->addAction(vat ? ACTION_GOTO_VAT_MEMORY_VIEW : ACTION_GOTO_MEMORY_VIEW);
20522052
gotoMem->setEnabled(m_uiEditMode || ui->debugMemoryWidget->isVisible() || !m_docksMemory.isEmpty());
20532053
return gotoMem;
@@ -2220,7 +2220,7 @@ bool MainWindow::eventFilter(QObject *obj, QEvent *e) {
22202220
// Stack
22212221
// ------------------------------------------------
22222222

2223-
bool MainWindow::adlState(int state) {
2223+
bool MainWindow::adlState(int state) const {
22242224
bool adl = ui->checkADL->isChecked();
22252225
if (state == Qt::Checked) {
22262226
adl = true;
@@ -2454,7 +2454,7 @@ void MainWindow::osUpdate() {
24542454
connect(ui->fpStack, &QTableWidget::itemChanged, this, &MainWindow::fpModified);
24552455
}
24562456

2457-
void MainWindow::opModified(QTableWidgetItem *item) {
2457+
void MainWindow::opModified(QTableWidgetItem *item) const {
24582458
if (item == Q_NULLPTR) {
24592459
return;
24602460
}
@@ -2519,7 +2519,7 @@ void MainWindow::opModified(QTableWidgetItem *item) {
25192519
sender()->blockSignals(false);
25202520
}
25212521

2522-
void MainWindow::fpModified(QTableWidgetItem *item) {
2522+
void MainWindow::fpModified(QTableWidgetItem *item) const {
25232523
if (item == Q_NULLPTR) {
25242524
return;
25252525
}
@@ -2637,7 +2637,7 @@ void MainWindow::contextVat(const QPoint &posa) {
26372637
}
26382638
}
26392639

2640-
void MainWindow::memDocksUpdate() {
2640+
void MainWindow::memDocksUpdate() const {
26412641
QList<QDockWidget*> docks = findChildren<QDockWidget*>();
26422642
foreach (QDockWidget* dock, docks) {
26432643
if (dock->windowTitle().contains(TXT_MEM_DOCK)) {

gui/qt/debugger/disasm.cpp

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -11,16 +11,16 @@ disasm_state_t disasm;
1111
static char tmpbuf[20];
1212

1313
static std::string strW(uint32_t data) {
14-
std::pair<map_t::iterator, map_t::iterator> range;
15-
map_t::iterator sit;
16-
std::string ret;
1714
bool high = data > 511;
1815
if (disasm.il) {
1916
snprintf(tmpbuf, sizeof(tmpbuf), "$%06X", data);
2017
} else {
2118
snprintf(tmpbuf, sizeof(tmpbuf), "$%04X", data);
2219
}
2320
if (high) {
21+
std::pair<map_t::iterator, map_t::iterator> range;
22+
map_t::iterator sit;
23+
std::string ret;
2424
range = disasm.map.equal_range(data);
2525
for (sit = range.first; sit != range.second; ++sit) {
2626
ret += sit->second;
@@ -45,15 +45,14 @@ static std::string strW(uint32_t data) {
4545
}
4646
}
4747
}
48-
return std::string(tmpbuf);
48+
return {tmpbuf};
4949
}
5050

5151
static std::string strA(uint32_t data) {
52-
std::pair<map_t::iterator, map_t::iterator> range;
5352
map_t::iterator sit;
5453
std::string ret;
55-
bool high = data > 511;
56-
range = disasm.map.equal_range(data);
54+
const bool high = data > 511;
55+
std::pair<map_t::iterator, map_t::iterator> range = disasm.map.equal_range(data);
5756
for (sit = range.first; sit != range.second; ++sit) {
5857
if (high || sit->second[0] == '_') {
5958
if (!ret.empty()) {
@@ -85,7 +84,7 @@ static std::string strA(uint32_t data) {
8584
}
8685
snprintf(tmpbuf, sizeof(tmpbuf), "$%04X", data);
8786
}
88-
return std::string(tmpbuf);
87+
return {tmpbuf};
8988
}
9089

9190
static int disasmFetch([[maybe_unused]] struct zdis_ctx *ctx, uint32_t addr) {

gui/qt/debugger/hexwidget.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,8 @@ class HexWidget : public QAbstractScrollArea {
3333
int indexPrevOf(const QByteArray &ba);
3434
int indexPrevNotOf(const QByteArray &ba);
3535
int indexOf(const QByteArray &ba);
36-
const char *data() { return m_data.constData(); }
37-
const char *modified() { return m_modified.constData(); }
36+
const char *data() const { return m_data.constData(); }
37+
const char *modified() const { return m_modified.constData(); }
3838

3939
protected:
4040
virtual void paintEvent(QPaintEvent *) Q_DECL_OVERRIDE;

gui/qt/debugger/visualizerdisplaywidget.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ void VisualizerDisplayWidget::setConfig(uint32_t bppstep, int w, int h, uint32_t
115115
m_image = new QImage(w, h, QImage::Format_RGB32);
116116
}
117117

118-
void VisualizerDisplayWidget::contextMenu(const QPoint& posa) {
118+
void VisualizerDisplayWidget::contextMenu(const QPoint& posa) const {
119119
QString copyStr = tr("Copy Address");
120120
QString coordStr = tr("Coordinate: ");
121121

0 commit comments

Comments
 (0)