From 2070819a3372e5818f8268b13c04ec86b88ed6f5 Mon Sep 17 00:00:00 2001 From: cristian64 Date: Sun, 12 May 2024 11:30:27 +0100 Subject: [PATCH] Address `hicpp-member-init` warnings. ``` /w/dolphin-memory-engine/Source/DolphinProcess/Linux/LinuxDolphinProcess.cpp:142:3: warning: uninitialized record type: 'local' [hicpp-member-init] 142 | struct iovec local; | ^ | {} /w/dolphin-memory-engine/Source/DolphinProcess/Linux/LinuxDolphinProcess.cpp:143:3: warning: uninitialized record type: 'remote' [hicpp-member-init] 143 | struct iovec remote; | ^ | {} /w/dolphin-memory-engine/Source/DolphinProcess/Linux/LinuxDolphinProcess.cpp:211:3: warning: uninitialized record type: 'local' [hicpp-member-init] 211 | struct iovec local; | ^ | {} /w/dolphin-memory-engine/Source/DolphinProcess/Linux/LinuxDolphinProcess.cpp:212:3: warning: uninitialized record type: 'remote' [hicpp-member-init] 212 | struct iovec remote; | ^ | {} /w/dolphin-memory-engine/Source/GUI/MainWindow.cpp:19:1: warning: constructor does not initialize these fields: m_watcher, m_scanner, m_viewer, m_copier, m_lblDolphinStatus, m_lblMem2Status, m_menuFile, m_menuEdit, m_menuDolphin, m_menuView, m_menuHelp, m_actOpenWatchList, m_actSaveWatchList, m_actSaveAsWatchList, m_actClearWatchList, m_actImportFromCT, m_actExportAsCSV, m_actSettings, m_actAutoHook, m_actHook, m_actUnhook, m_actMemoryViewer, m_actCopyMemory, m_actQuit, m_actAbout [hicpp-member-init] 19 | MainWindow::MainWindow() | ^ /w/dolphin-memory-engine/Source/GUI/MemScanner/MemScanWidget.cpp:14:1: warning: constructor does not initialize these fields: m_memScanner, m_resultsListModel, m_txbSearchRange1, m_txbSearchRange2, m_btnFirstScan, m_btnNextScan, m_btnResetScan, m_btnUndoScan, m_btnAddSelection, m_btnAddAll, m_btnRemoveSelection, m_txbSearchTerm1, m_txbSearchTerm2, m_searchTerm2Widget, m_currentValuesUpdateTimer, m_cmbScanFilter, m_cmbScanType, m_lblResultCount, m_chkSignedScan, m_chkEnforceMemAlignment, m_btnGroupScanBase, m_rdbBaseDecimal, m_rdbBaseHexadecimal, m_rdbBaseOctal, m_rdbBaseBinary, m_groupScanBase, m_tblResulstList, m_variableLengthType [hicpp-member-init] 14 | MemScanWidget::MemScanWidget() | ^ /w/dolphin-memory-engine/Source/GUI/MemViewer/MemViewer.cpp:25:1: warning: constructor does not initialize these fields: m_curosrRect [hicpp-member-init] 25 | MemViewer::MemViewer(QWidget* parent) : QAbstractScrollArea(parent) | ^ /w/dolphin-memory-engine/Source/GUI/MemViewer/MemViewerWidget.cpp:10:1: warning: constructor does not initialize these fields: m_txtJumpAddress, m_btnGoToMEM1Start, m_btnGoToSecondaryRAMStart, m_updateMemoryTimer, m_memViewer [hicpp-member-init] 10 | MemViewerWidget::MemViewerWidget(QWidget* const parent) : QWidget(parent) | ^ /w/dolphin-memory-engine/Source/GUI/MemWatcher/Dialogs/DlgAddWatchEntry.cpp:13:1: warning: constructor does not initialize these fields: m_entry, m_txbAddress, m_offsetsLayout, m_chkBoundToPointer, m_lblValuePreview, m_txbLabel, m_cmbTypes, m_spnLength, m_pointerWidget, m_btnAddOffset, m_btnRemoveOffset [hicpp-member-init] 13 | DlgAddWatchEntry::DlgAddWatchEntry(const bool newEntry, MemWatchEntry* const entry, | ^ /w/dolphin-memory-engine/Source/GUI/MemWatcher/Dialogs/DlgChangeType.cpp:11:1: warning: constructor does not initialize these fields: m_cmbTypes, m_spnLength, m_lengthSelection [hicpp-member-init] 11 | DlgChangeType::DlgChangeType(QWidget* parent, const int typeIndex, const size_t length) | ^ /w/dolphin-memory-engine/Source/GUI/MemWatcher/Dialogs/DlgImportCTFile.cpp:11:1: warning: constructor does not initialize these fields: m_useDolphinPointers, m_txbFileName, m_btnBrowseFiles, m_txbCommonBase, m_btnGroupImportAddressMethod, m_rdbUseDolphinPointers, m_rdbUseCommonBase, m_groupImportAddressMethod, m_widgetAddressMethod [hicpp-member-init] 11 | DlgImportCTFile::DlgImportCTFile(QWidget* const parent) : QDialog(parent) | ^ /w/dolphin-memory-engine/Source/GUI/MemWatcher/MemWatchWidget.cpp:31:1: warning: constructor does not initialize these fields: m_watchView, m_watchModel, m_watchDelegate, m_btnAddGroup, m_btnAddWatchEntry, m_updateTimer, m_freezeTimer [hicpp-member-init] 31 | MemWatchWidget::MemWatchWidget(QWidget* parent) : QWidget(parent) | ^ /w/dolphin-memory-engine/Source/MemoryScanner/MemoryScanner.cpp:30:1: warning: constructor does not initialize these fields: m_memSize [hicpp-member-init] 30 | MemScanner::MemScanner() = default; | ^ ``` --- .../Linux/LinuxDolphinProcess.cpp | 22 +++++--- Source/GUI/MainWindow.h | 50 ++++++++--------- Source/GUI/MemScanner/MemScanWidget.h | 56 +++++++++---------- Source/GUI/MemViewer/MemViewer.h | 4 +- Source/GUI/MemViewer/MemViewerWidget.h | 10 ++-- .../GUI/MemWatcher/Dialogs/DlgAddWatchEntry.h | 22 ++++---- Source/GUI/MemWatcher/Dialogs/DlgChangeType.h | 6 +- .../GUI/MemWatcher/Dialogs/DlgImportCTFile.h | 18 +++--- Source/GUI/MemWatcher/MemWatchWidget.h | 14 ++--- Source/MemoryScanner/MemoryScanner.h | 2 +- 10 files changed, 105 insertions(+), 99 deletions(-) diff --git a/Source/DolphinProcess/Linux/LinuxDolphinProcess.cpp b/Source/DolphinProcess/Linux/LinuxDolphinProcess.cpp index cf238ffc..802c8d98 100644 --- a/Source/DolphinProcess/Linux/LinuxDolphinProcess.cpp +++ b/Source/DolphinProcess/Linux/LinuxDolphinProcess.cpp @@ -139,9 +139,6 @@ bool LinuxDolphinProcess::findPID() bool LinuxDolphinProcess::readFromRAM(const u32 offset, char* buffer, const size_t size, const bool withBSwap) { - struct iovec local; - struct iovec remote; - size_t nread; u64 RAMAddress = 0; if (m_ARAMAccessible) { @@ -159,13 +156,22 @@ bool LinuxDolphinProcess::readFromRAM(const u32 offset, char* buffer, const size RAMAddress = m_emuRAMAddressStart + offset; } + iovec local{}; local.iov_base = buffer; local.iov_len = size; + + iovec remote{}; remote.iov_base = reinterpret_cast(RAMAddress); remote.iov_len = size; - nread = process_vm_readv(m_PID, &local, 1, &remote, 1, 0); - if (nread != size) + const ssize_t nread{process_vm_readv(m_PID, &local, 1, &remote, 1, 0)}; + if (nread == -1) + { + // A more specific error type should be available in `errno` (if ever interested). + return false; + } + + if (static_cast(nread) != size) return false; if (withBSwap) @@ -208,9 +214,6 @@ bool LinuxDolphinProcess::readFromRAM(const u32 offset, char* buffer, const size bool LinuxDolphinProcess::writeToRAM(const u32 offset, const char* buffer, const size_t size, const bool withBSwap) { - struct iovec local; - struct iovec remote; - u64 RAMAddress = 0; if (m_ARAMAccessible) { @@ -231,8 +234,11 @@ bool LinuxDolphinProcess::writeToRAM(const u32 offset, const char* buffer, const char* bufferCopy = new char[size]; std::memcpy(bufferCopy, buffer, size); + iovec local{}; local.iov_base = bufferCopy; local.iov_len = size; + + iovec remote{}; remote.iov_base = reinterpret_cast(RAMAddress); remote.iov_len = size; diff --git a/Source/GUI/MainWindow.h b/Source/GUI/MainWindow.h index e99f5c78..5910d407 100644 --- a/Source/GUI/MainWindow.h +++ b/Source/GUI/MainWindow.h @@ -58,34 +58,34 @@ class MainWindow : public QMainWindow QSplitter* m_splitter{}; - MemWatchWidget* m_watcher; - MemScanWidget* m_scanner; - MemViewerWidget* m_viewer; - DlgCopy* m_copier; + MemWatchWidget* m_watcher{}; + MemScanWidget* m_scanner{}; + MemViewerWidget* m_viewer{}; + DlgCopy* m_copier{}; QTimer m_autoHookTimer; - QLabel* m_lblDolphinStatus; - QLabel* m_lblMem2Status; + QLabel* m_lblDolphinStatus{}; + QLabel* m_lblMem2Status{}; - QMenu* m_menuFile; - QMenu* m_menuEdit; - QMenu* m_menuDolphin; - QMenu* m_menuView; - QMenu* m_menuHelp; - QAction* m_actOpenWatchList; - QAction* m_actSaveWatchList; - QAction* m_actSaveAsWatchList; - QAction* m_actClearWatchList; - QAction* m_actImportFromCT; - QAction* m_actExportAsCSV; - QAction* m_actSettings; - QAction* m_actAutoHook; - QAction* m_actHook; - QAction* m_actUnhook; - QAction* m_actMemoryViewer; - QAction* m_actCopyMemory; + QMenu* m_menuFile{}; + QMenu* m_menuEdit{}; + QMenu* m_menuDolphin{}; + QMenu* m_menuView{}; + QMenu* m_menuHelp{}; + QAction* m_actOpenWatchList{}; + QAction* m_actSaveWatchList{}; + QAction* m_actSaveAsWatchList{}; + QAction* m_actClearWatchList{}; + QAction* m_actImportFromCT{}; + QAction* m_actExportAsCSV{}; + QAction* m_actSettings{}; + QAction* m_actAutoHook{}; + QAction* m_actHook{}; + QAction* m_actUnhook{}; + QAction* m_actMemoryViewer{}; + QAction* m_actCopyMemory{}; QAction* m_actScanner{}; - QAction* m_actQuit; - QAction* m_actAbout; + QAction* m_actQuit{}; + QAction* m_actAbout{}; }; diff --git a/Source/GUI/MemScanner/MemScanWidget.h b/Source/GUI/MemScanner/MemScanWidget.h index 4b4a12d2..2accef90 100644 --- a/Source/GUI/MemScanner/MemScanWidget.h +++ b/Source/GUI/MemScanner/MemScanWidget.h @@ -58,33 +58,33 @@ class MemScanWidget : public QWidget void updateScanFilterChoices(); void updateTypeAdditionalOptions(); - MemScanner* m_memScanner; - ResultsListModel* m_resultsListModel; - QLineEdit* m_txbSearchRange1; - QLineEdit* m_txbSearchRange2; - QPushButton* m_btnFirstScan; - QPushButton* m_btnNextScan; - QPushButton* m_btnResetScan; - QPushButton* m_btnUndoScan; - QPushButton* m_btnAddSelection; - QPushButton* m_btnAddAll; - QPushButton* m_btnRemoveSelection; - QLineEdit* m_txbSearchTerm1; - QLineEdit* m_txbSearchTerm2; - QWidget* m_searchTerm2Widget; - QTimer* m_currentValuesUpdateTimer; - QComboBox* m_cmbScanFilter; - QComboBox* m_cmbScanType; - QLabel* m_lblResultCount; - QCheckBox* m_chkSignedScan; - QCheckBox* m_chkEnforceMemAlignment; - QButtonGroup* m_btnGroupScanBase; - QRadioButton* m_rdbBaseDecimal; - QRadioButton* m_rdbBaseHexadecimal; - QRadioButton* m_rdbBaseOctal; - QRadioButton* m_rdbBaseBinary; - QGroupBox* m_groupScanBase; - QTableView* m_tblResulstList; - bool m_variableLengthType; + MemScanner* m_memScanner{}; + ResultsListModel* m_resultsListModel{}; + QLineEdit* m_txbSearchRange1{}; + QLineEdit* m_txbSearchRange2{}; + QPushButton* m_btnFirstScan{}; + QPushButton* m_btnNextScan{}; + QPushButton* m_btnResetScan{}; + QPushButton* m_btnUndoScan{}; + QPushButton* m_btnAddSelection{}; + QPushButton* m_btnAddAll{}; + QPushButton* m_btnRemoveSelection{}; + QLineEdit* m_txbSearchTerm1{}; + QLineEdit* m_txbSearchTerm2{}; + QWidget* m_searchTerm2Widget{}; + QTimer* m_currentValuesUpdateTimer{}; + QComboBox* m_cmbScanFilter{}; + QComboBox* m_cmbScanType{}; + QLabel* m_lblResultCount{}; + QCheckBox* m_chkSignedScan{}; + QCheckBox* m_chkEnforceMemAlignment{}; + QButtonGroup* m_btnGroupScanBase{}; + QRadioButton* m_rdbBaseDecimal{}; + QRadioButton* m_rdbBaseHexadecimal{}; + QRadioButton* m_rdbBaseOctal{}; + QRadioButton* m_rdbBaseBinary{}; + QGroupBox* m_groupScanBase{}; + QTableView* m_tblResulstList{}; + bool m_variableLengthType{}; size_t m_showThreshold{}; }; diff --git a/Source/GUI/MemViewer/MemViewer.h b/Source/GUI/MemViewer/MemViewer.h index 4e3b3ce9..186eef9e 100644 --- a/Source/GUI/MemViewer/MemViewer.h +++ b/Source/GUI/MemViewer/MemViewer.h @@ -110,7 +110,7 @@ class MemViewer : public QAbstractScrollArea u32 m_currentFirstAddress = 0; u32 m_memViewStart = 0; u32 m_memViewEnd = 0; - QRect* m_curosrRect; - QShortcut* m_copyShortcut; + QRect* m_curosrRect{}; + QShortcut* m_copyShortcut{}; QElapsedTimer m_elapsedTimer; }; diff --git a/Source/GUI/MemViewer/MemViewerWidget.h b/Source/GUI/MemViewer/MemViewerWidget.h index 2ca84a5f..1272b550 100644 --- a/Source/GUI/MemViewer/MemViewerWidget.h +++ b/Source/GUI/MemViewer/MemViewerWidget.h @@ -30,9 +30,9 @@ class MemViewerWidget : public QWidget void initialiseWidgets(); void makeLayouts(); - QLineEdit* m_txtJumpAddress; - QPushButton* m_btnGoToMEM1Start; - QPushButton* m_btnGoToSecondaryRAMStart; - QTimer* m_updateMemoryTimer; - MemViewer* m_memViewer; + QLineEdit* m_txtJumpAddress{}; + QPushButton* m_btnGoToMEM1Start{}; + QPushButton* m_btnGoToSecondaryRAMStart{}; + QTimer* m_updateMemoryTimer{}; + MemViewer* m_memViewer{}; }; diff --git a/Source/GUI/MemWatcher/Dialogs/DlgAddWatchEntry.h b/Source/GUI/MemWatcher/Dialogs/DlgAddWatchEntry.h index bcb2d4eb..2a3c3b7d 100644 --- a/Source/GUI/MemWatcher/Dialogs/DlgAddWatchEntry.h +++ b/Source/GUI/MemWatcher/Dialogs/DlgAddWatchEntry.h @@ -38,17 +38,17 @@ class DlgAddWatchEntry : public QDialog void removePointerOffset(); void removeAllPointerOffset(); - MemWatchEntry* m_entry; - QLineEdit* m_txbAddress; + MemWatchEntry* m_entry{}; + QLineEdit* m_txbAddress{}; QVector m_offsets; QVector m_addressPath; - QGridLayout* m_offsetsLayout; - QCheckBox* m_chkBoundToPointer; - QLineEdit* m_lblValuePreview; - QLineEdit* m_txbLabel; - QComboBox* m_cmbTypes; - QSpinBox* m_spnLength; - QGroupBox* m_pointerWidget; - QPushButton* m_btnAddOffset; - QPushButton* m_btnRemoveOffset; + QGridLayout* m_offsetsLayout{}; + QCheckBox* m_chkBoundToPointer{}; + QLineEdit* m_lblValuePreview{}; + QLineEdit* m_txbLabel{}; + QComboBox* m_cmbTypes{}; + QSpinBox* m_spnLength{}; + QGroupBox* m_pointerWidget{}; + QPushButton* m_btnAddOffset{}; + QPushButton* m_btnRemoveOffset{}; }; diff --git a/Source/GUI/MemWatcher/Dialogs/DlgChangeType.h b/Source/GUI/MemWatcher/Dialogs/DlgChangeType.h index 765a1e6d..729d4b67 100644 --- a/Source/GUI/MemWatcher/Dialogs/DlgChangeType.h +++ b/Source/GUI/MemWatcher/Dialogs/DlgChangeType.h @@ -21,7 +21,7 @@ class DlgChangeType : public QDialog int m_typeIndex; size_t m_length; - QComboBox* m_cmbTypes; - QSpinBox* m_spnLength; - QWidget* m_lengthSelection; + QComboBox* m_cmbTypes{}; + QSpinBox* m_spnLength{}; + QWidget* m_lengthSelection{}; }; diff --git a/Source/GUI/MemWatcher/Dialogs/DlgImportCTFile.h b/Source/GUI/MemWatcher/Dialogs/DlgImportCTFile.h index 40e3c063..5c59b63b 100644 --- a/Source/GUI/MemWatcher/Dialogs/DlgImportCTFile.h +++ b/Source/GUI/MemWatcher/Dialogs/DlgImportCTFile.h @@ -23,15 +23,15 @@ class DlgImportCTFile : public QDialog void accept() override; private: - bool m_useDolphinPointers; + bool m_useDolphinPointers{}; u32 m_commonBase = 0; QString m_strFileName; - QLineEdit* m_txbFileName; - QPushButton* m_btnBrowseFiles; - QLineEdit* m_txbCommonBase; - QButtonGroup* m_btnGroupImportAddressMethod; - QRadioButton* m_rdbUseDolphinPointers; - QRadioButton* m_rdbUseCommonBase; - QGroupBox* m_groupImportAddressMethod; - QWidget* m_widgetAddressMethod; + QLineEdit* m_txbFileName{}; + QPushButton* m_btnBrowseFiles{}; + QLineEdit* m_txbCommonBase{}; + QButtonGroup* m_btnGroupImportAddressMethod{}; + QRadioButton* m_rdbUseDolphinPointers{}; + QRadioButton* m_rdbUseCommonBase{}; + QGroupBox* m_groupImportAddressMethod{}; + QWidget* m_widgetAddressMethod{}; }; diff --git a/Source/GUI/MemWatcher/MemWatchWidget.h b/Source/GUI/MemWatcher/MemWatchWidget.h index 9aea3dfa..5a041daa 100644 --- a/Source/GUI/MemWatcher/MemWatchWidget.h +++ b/Source/GUI/MemWatcher/MemWatchWidget.h @@ -49,13 +49,13 @@ class MemWatchWidget : public QWidget void initialiseWidgets(); void makeLayouts(); - QTreeView* m_watchView; - MemWatchModel* m_watchModel; - MemWatchDelegate* m_watchDelegate; - QPushButton* m_btnAddGroup; - QPushButton* m_btnAddWatchEntry; - QTimer* m_updateTimer; - QTimer* m_freezeTimer; + QTreeView* m_watchView{}; + MemWatchModel* m_watchModel{}; + MemWatchDelegate* m_watchDelegate{}; + QPushButton* m_btnAddGroup{}; + QPushButton* m_btnAddWatchEntry{}; + QTimer* m_updateTimer{}; + QTimer* m_freezeTimer{}; QString m_watchListFile = ""; bool m_hasUnsavedChanges = false; diff --git a/Source/MemoryScanner/MemoryScanner.h b/Source/MemoryScanner/MemoryScanner.h index a7848176..9fffbe31 100644 --- a/Source/MemoryScanner/MemoryScanner.h +++ b/Source/MemoryScanner/MemoryScanner.h @@ -167,7 +167,7 @@ class MemScanner Common::MemType m_memType = Common::MemType::type_byte; Common::MemBase m_memBase = Common::MemBase::base_decimal; - size_t m_memSize; + size_t m_memSize{}; bool m_enforceMemAlignment = true; bool m_memIsSigned = false;