From 0ba8fd89724a82f66622432fe4a230ec629cb678 Mon Sep 17 00:00:00 2001 From: Jasmine Iwanek Date: Mon, 21 Aug 2023 20:23:52 -0400 Subject: [PATCH] More linting in src/qt --- src/qt/qt_harddiskdialog.cpp | 16 ++++++++-------- src/qt/qt_newfloppydialog.cpp | 22 +++++++++++----------- src/qt/qt_settingsfloppycdrom.cpp | 4 ++-- src/qt/qt_settingsotherremovable.cpp | 24 +++++++++++++++--------- 4 files changed, 36 insertions(+), 30 deletions(-) diff --git a/src/qt/qt_harddiskdialog.cpp b/src/qt/qt_harddiskdialog.cpp index 2a07db482..5dab101b8 100644 --- a/src/qt/qt_harddiskdialog.cpp +++ b/src/qt/qt_harddiskdialog.cpp @@ -511,24 +511,24 @@ void HarddiskDialog::onExistingFileSelected(const QString &fileName, bool precheck) { // TODO : Over to non-existing file selected - /* +#if 0 if (!(existing & 1)) { - f = _wfopen(wopenfilestring, L"rb"); - if (f != NULL) { - fclose(f); + fp = _wfopen(wopenfilestring, L"rb"); + if (fp != NULL) { + fclose(fp); if (settings_msgbox_ex(MBX_QUESTION_YN, (wchar_t *) IDS_4111, (wchar_t *) IDS_4118, (wchar_t *) IDS_4120, (wchar_t *) IDS_4121, NULL) != 0) / * yes * / return FALSE; } } - f = _wfopen(wopenfilestring, (existing & 1) ? L"rb" : L"wb"); - if (f == NULL) { + fp = _wfopen(wopenfilestring, (existing & 1) ? L"rb" : L"wb"); + if (fp == NULL) { hdd_add_file_open_error: - fclose(f); + fclose(fp); settings_msgbox_header(MBX_ERROR, (existing & 1) ? (wchar_t *) IDS_4114 : (wchar_t *) IDS_4115, (existing & 1) ? (wchar_t *) IDS_4107 : (wchar_t *) IDS_4108); return TRUE; } - */ +#endif uint64_t size = 0; uint32_t sector_size = 0; diff --git a/src/qt/qt_newfloppydialog.cpp b/src/qt/qt_newfloppydialog.cpp index 10c505e3b..e24ad9aa1 100644 --- a/src/qt/qt_newfloppydialog.cpp +++ b/src/qt/qt_newfloppydialog.cpp @@ -259,7 +259,7 @@ NewFloppyDialog::onCreate() bool NewFloppyDialog::create86f(const QString &filename, const disk_size_t &disk_size, uint8_t rpm_mode) { - FILE *f; + FILE *fp; uint32_t magic = 0x46423638; uint16_t version = 0x020C; @@ -326,13 +326,13 @@ NewFloppyDialog::create86f(const QString &filename, const disk_size_t &disk_size memset(tarray, 0, 2048); memset(empty, 0, array_size); - f = plat_fopen(filename.toUtf8().data(), "wb"); - if (!f) + fp = plat_fopen(filename.toUtf8().data(), "wb"); + if (!fp) return false; - fwrite(&magic, 4, 1, f); - fwrite(&version, 2, 1, f); - fwrite(&dflags, 2, 1, f); + fwrite(&magic, 4, 1, fp); + fwrite(&version, 2, 1, fp); + fwrite(&dflags, 2, 1, fp); track_size = array_size + 6; @@ -344,17 +344,17 @@ NewFloppyDialog::create86f(const QString &filename, const disk_size_t &disk_size for (i = 0; i < (disk_size.tracks * disk_size.sides) << shift; i++) tarray[i] = track_base + (i * track_size); - fwrite(tarray, 1, (disk_size.sides == 2) ? 2048 : 1024, f); + fwrite(tarray, 1, (disk_size.sides == 2) ? 2048 : 1024, fp); for (i = 0; i < (disk_size.tracks * disk_size.sides) << shift; i++) { - fwrite(&tflags, 2, 1, f); - fwrite(&index_hole_pos, 4, 1, f); - fwrite(empty, 1, array_size, f); + fwrite(&tflags, 2, 1, fp); + fwrite(&index_hole_pos, 4, 1, fp); + fwrite(empty, 1, array_size, fp); } free(empty); - fclose(f); + fclose(fp); return true; } diff --git a/src/qt/qt_settingsfloppycdrom.cpp b/src/qt/qt_settingsfloppycdrom.cpp index e4adcd0c2..988f9e856 100644 --- a/src/qt/qt_settingsfloppycdrom.cpp +++ b/src/qt/qt_settingsfloppycdrom.cpp @@ -179,7 +179,7 @@ SettingsFloppyCDROM::SettingsFloppyCDROM(QWidget *parent) auto *modelType = ui->comboBoxCDROMType->model(); int removeRows = modelType->rowCount(); - int j = 0; + uint32_t j = 0; int selectedTypeRow = 0; int eligibleRows = 0; while (cdrom_drive_types[j].bus_type != BUS_TYPE_NONE) { @@ -337,7 +337,7 @@ SettingsFloppyCDROM::on_comboBoxBus_activated(int) auto *modelType = ui->comboBoxCDROMType->model(); int removeRows = modelType->rowCount(); - int j = 0; + uint32_t j = 0; int selectedTypeRow = 0; int eligibleRows = 0; while (cdrom_drive_types[j].bus_type != BUS_TYPE_NONE) { diff --git a/src/qt/qt_settingsotherremovable.cpp b/src/qt/qt_settingsotherremovable.cpp index dea865543..f8b29dac5 100644 --- a/src/qt/qt_settingsotherremovable.cpp +++ b/src/qt/qt_settingsotherremovable.cpp @@ -52,6 +52,9 @@ setMOBus(QAbstractItemModel *model, const QModelIndex &idx, uint8_t bus, uint8_t case MO_BUS_SCSI: icon = ProgSettings::loadIcon("/mo.ico"); break; + + default: + break; } auto i = idx.siblingAtColumn(0); @@ -84,6 +87,9 @@ setZIPBus(QAbstractItemModel *model, const QModelIndex &idx, uint8_t bus, uint8_ case ZIP_BUS_SCSI: icon = ProgSettings::loadIcon("/zip.ico"); break; + + default: + break; } auto i = idx.siblingAtColumn(0); @@ -158,9 +164,9 @@ SettingsOtherRemovable::~SettingsOtherRemovable() void SettingsOtherRemovable::save() { - auto *model = ui->tableViewMO->model(); - for (int i = 0; i < MO_NUM; i++) { - mo_drives[i].f = NULL; + const auto *model = ui->tableViewMO->model(); + for (uint8_t i = 0; i < MO_NUM; i++) { + mo_drives[i].fp = NULL; mo_drives[i].priv = NULL; mo_drives[i].bus_type = model->index(i, 0).data(Qt::UserRole).toUInt(); mo_drives[i].res = model->index(i, 0).data(Qt::UserRole + 1).toUInt(); @@ -168,8 +174,8 @@ SettingsOtherRemovable::save() } model = ui->tableViewZIP->model(); - for (int i = 0; i < ZIP_NUM; i++) { - zip_drives[i].f = NULL; + for (uint8_t i = 0; i < ZIP_NUM; i++) { + zip_drives[i].fp = NULL; zip_drives[i].priv = NULL; zip_drives[i].bus_type = model->index(i, 0).data(Qt::UserRole).toUInt(); zip_drives[i].res = model->index(i, 0).data(Qt::UserRole + 1).toUInt(); @@ -185,8 +191,8 @@ SettingsOtherRemovable::onMORowChanged(const QModelIndex ¤t) uint8_t type = current.siblingAtColumn(1).data(Qt::UserRole).toUInt(); ui->comboBoxMOBus->setCurrentIndex(-1); - auto *model = ui->comboBoxMOBus->model(); - auto match = model->match(model->index(0, 0), Qt::UserRole, bus); + const auto *model = ui->comboBoxMOBus->model(); + auto match = model->match(model->index(0, 0), Qt::UserRole, bus); if (!match.isEmpty()) ui->comboBoxMOBus->setCurrentIndex(match.first().row()); @@ -205,8 +211,8 @@ SettingsOtherRemovable::onZIPRowChanged(const QModelIndex ¤t) bool is250 = current.siblingAtColumn(1).data(Qt::UserRole).toBool(); ui->comboBoxZIPBus->setCurrentIndex(-1); - auto *model = ui->comboBoxZIPBus->model(); - auto match = model->match(model->index(0, 0), Qt::UserRole, bus); + const auto *model = ui->comboBoxZIPBus->model(); + auto match = model->match(model->index(0, 0), Qt::UserRole, bus); if (!match.isEmpty()) ui->comboBoxZIPBus->setCurrentIndex(match.first().row());