From a166cf24812451f62680eac971b6f50173653084 Mon Sep 17 00:00:00 2001 From: Lioncash Date: Sun, 13 May 2018 13:53:49 -0400 Subject: [PATCH] PatchEngine: Give Patch and PatchEntry default member initializers Avoids potentially using the values uninitialized. While we're at it, also drop the prefixed underscores from one of the constructors. --- Source/Core/Core/PatchEngine.h | 14 +++++++------- Source/Core/DolphinQt2/Config/NewPatchDialog.cpp | 6 +----- Source/Core/DolphinWX/PatchAddEdit.cpp | 4 ++-- 3 files changed, 10 insertions(+), 14 deletions(-) diff --git a/Source/Core/Core/PatchEngine.h b/Source/Core/Core/PatchEngine.h index b1e7b2ba02..11889cf35d 100644 --- a/Source/Core/Core/PatchEngine.h +++ b/Source/Core/Core/PatchEngine.h @@ -24,19 +24,19 @@ extern const char* PatchTypeStrings[]; struct PatchEntry { - PatchEntry() {} - PatchEntry(PatchType _t, u32 _addr, u32 _value) : type(_t), address(_addr), value(_value) {} - PatchType type; - u32 address; - u32 value; + PatchEntry() = default; + PatchEntry(PatchType t, u32 addr, u32 value_) : type(t), address(addr), value(value_) {} + PatchType type = PatchType::PATCH_8BIT; + u32 address = 0; + u32 value = 0; }; struct Patch { std::string name; std::vector entries; - bool active; - bool user_defined; // False if this code is shipped with Dolphin. + bool active = false; + bool user_defined = false; // False if this code is shipped with Dolphin. }; int GetSpeedhackCycles(const u32 addr); diff --git a/Source/Core/DolphinQt2/Config/NewPatchDialog.cpp b/Source/Core/DolphinQt2/Config/NewPatchDialog.cpp index 3e871b842a..33fef87db5 100644 --- a/Source/Core/DolphinQt2/Config/NewPatchDialog.cpp +++ b/Source/Core/DolphinQt2/Config/NewPatchDialog.cpp @@ -79,11 +79,7 @@ void NewPatchDialog::ConnectWidgets() void NewPatchDialog::AddEntry() { - PatchEngine::PatchEntry entry; - entry.type = PatchEngine::PATCH_8BIT; - entry.address = entry.value = 0; - - m_patch.entries.push_back(entry); + m_patch.entries.emplace_back(); m_entry_layout->addWidget(CreateEntry(static_cast(m_patch.entries.size() - 1))); } diff --git a/Source/Core/DolphinWX/PatchAddEdit.cpp b/Source/Core/DolphinWX/PatchAddEdit.cpp index e58b90a913..78d22094f7 100644 --- a/Source/Core/DolphinWX/PatchAddEdit.cpp +++ b/Source/Core/DolphinWX/PatchAddEdit.cpp @@ -42,7 +42,7 @@ void CPatchAddEdit::CreateGUIControls(int _selection) if (_selection == -1) { tempEntries.clear(); - tempEntries.emplace_back(PatchEngine::PATCH_8BIT, 0x00000000, 0x00000000); + tempEntries.emplace_back(); } else { @@ -165,7 +165,7 @@ void CPatchAddEdit::AddEntry(wxCommandEvent& event) if (!UpdateTempEntryData(itCurEntry)) return; - PatchEngine::PatchEntry peEmptyEntry(PatchEngine::PATCH_8BIT, 0x00000000, 0x00000000); + PatchEngine::PatchEntry peEmptyEntry; ++itCurEntry; currentItem++; itCurEntry = tempEntries.insert(itCurEntry, peEmptyEntry);