From 2ff794d299b0426d1f2a523523260efad84a9837 Mon Sep 17 00:00:00 2001 From: Tillmann Karras Date: Wed, 12 Feb 2014 21:08:23 +0100 Subject: [PATCH 1/2] Fix some warnings --- Source/Core/Common/Timer.cpp | 3 ++- Source/Core/Core/CoreTiming.cpp | 2 +- Source/Core/Core/PowerPC/JitArm32/JitArm_BackPatch.cpp | 2 +- Source/Core/DolphinWX/ISOFile.cpp | 3 ++- 4 files changed, 6 insertions(+), 4 deletions(-) diff --git a/Source/Core/Common/Timer.cpp b/Source/Core/Common/Timer.cpp index 91a2a2d3ad..a2e08bbf1d 100644 --- a/Source/Core/Common/Timer.cpp +++ b/Source/Core/Common/Timer.cpp @@ -3,6 +3,7 @@ // Refer to the license.txt file included. #include +#include #ifdef _WIN32 #include @@ -113,7 +114,7 @@ std::string Timer::GetTimeElapsedFormatted() const // Hours u32 Hours = Minutes / 60; - std::string TmpStr = StringFromFormat("%02i:%02i:%02i:%03lu", + std::string TmpStr = StringFromFormat("%02i:%02i:%02i:%03" PRIu64, Hours, Minutes % 60, Seconds % 60, Milliseconds % 1000); return TmpStr; } diff --git a/Source/Core/Core/CoreTiming.cpp b/Source/Core/Core/CoreTiming.cpp index ace2c9759c..ceda4a668b 100644 --- a/Source/Core/Core/CoreTiming.cpp +++ b/Source/Core/Core/CoreTiming.cpp @@ -469,7 +469,7 @@ std::string GetScheduledEventsSummary() if (!name) name = "[unknown]"; - text += StringFromFormat("%s : %li %08lx%08lx\n", name, ptr->time, ptr->userdata >> 32, ptr->userdata); + text += StringFromFormat("%s : %" PRIi64 " %016" PRIx64 "\n", name, ptr->time, ptr->userdata); ptr = ptr->next; } return text; diff --git a/Source/Core/Core/PowerPC/JitArm32/JitArm_BackPatch.cpp b/Source/Core/Core/PowerPC/JitArm32/JitArm_BackPatch.cpp index bb085e96a8..79fb88a7d5 100644 --- a/Source/Core/Core/PowerPC/JitArm32/JitArm_BackPatch.cpp +++ b/Source/Core/Core/PowerPC/JitArm32/JitArm_BackPatch.cpp @@ -90,7 +90,7 @@ const u8 *JitArm::BackPatch(u8 *codePtr, u32, void *ctx_void) if (!DisamLoadStore(Value, rD, accessSize, Store)) { - printf("Invalid backpatch at location 0x%08x(0x%08x)\n", ctx->CTX_PC, Value); + printf("Invalid backpatch at location 0x%08lx(0x%08x)\n", ctx->CTX_PC, Value); exit(0); } diff --git a/Source/Core/DolphinWX/ISOFile.cpp b/Source/Core/DolphinWX/ISOFile.cpp index 5aa02f5df1..cb3e01eda4 100644 --- a/Source/Core/DolphinWX/ISOFile.cpp +++ b/Source/Core/DolphinWX/ISOFile.cpp @@ -5,6 +5,7 @@ #include #include #include +#include #include "Common.h" #include "CommonPaths.h" @@ -188,7 +189,7 @@ std::string GameListItem::CreateCacheFilename() // Filename.extension_HashOfFolderPath_Size.cache // Append hash to prevent ISO name-clashing in different folders. - Filename.append(StringFromFormat("%s_%x_%zx.cache", + Filename.append(StringFromFormat("%s_%x_%" PRIx64 ".cache", extension.c_str(), HashFletcher((const u8 *)LegalPathname.c_str(), LegalPathname.size()), File::GetSize(m_FileName))); From 404624bf0b0125e5a408021c616ee9b9e2dde382 Mon Sep 17 00:00:00 2001 From: Tillmann Karras Date: Wed, 12 Feb 2014 16:00:34 +0100 Subject: [PATCH 2/2] Turn loops into range-based form and some things suggested by cppcheck and compiler warnings. --- Source/Core/Common/ArmEmitter.cpp | 18 ++++----- Source/Core/Common/BreakPoints.cpp | 29 +++++++-------- Source/Core/Common/CDUtils.cpp | 2 +- Source/Core/Common/ChunkFile.h | 4 +- Source/Core/Common/IniFile.cpp | 19 +++++----- Source/Core/Common/LogManager.cpp | 9 ++--- Source/Core/Common/SymbolDB.h | 5 --- Source/Core/Common/SysConf.cpp | 11 ++---- Source/Core/Common/SysConf.h | 8 ++-- Source/Core/Core/Core.cpp | 6 +-- Source/Core/Core/DSP/disassemble.cpp | 9 ++--- Source/Core/Core/HW/DSPHLE/MailHandler.h | 2 +- Source/Core/Core/HW/EXI_DeviceGecko.cpp | 2 +- Source/Core/Core/HW/SI_DeviceGBA.cpp | 2 +- .../Core/HW/WiimoteEmu/EmuSubroutines.cpp | 2 +- Source/Core/Core/HW/WiimoteEmu/WiimoteEmu.cpp | 4 +- Source/Core/Core/IPC_HLE/WII_IPC_HLE.cpp | 4 +- .../Core/IPC_HLE/WII_IPC_HLE_Device_fs.cpp | 9 ++--- .../Core/IPC_HLE/WII_IPC_HLE_Device_hid.cpp | 4 +- Source/Core/Core/IPC_HLE/WII_Socket.cpp | 4 +- Source/Core/Core/NetPlayServer.cpp | 17 +++------ Source/Core/Core/PatchEngine.cpp | 24 ++++++------ .../PowerPC/Interpreter/Interpreter_FPUtils.h | 2 +- .../Core/Core/PowerPC/Jit64/Jit_Integer.cpp | 2 +- .../Core/Core/PowerPC/JitCommon/JitCache.cpp | 2 +- Source/Core/Core/PowerPC/PPCAnalyst.cpp | 16 ++++---- Source/Core/Core/PowerPC/PPCSymbolDB.cpp | 20 +++++----- Source/Core/Core/PowerPC/SignatureDB.cpp | 37 ++++++++++--------- Source/Core/DiscIO/CompressedBlob.cpp | 3 +- Source/Core/DiscIO/DiscScrubber.cpp | 2 +- Source/Core/DiscIO/VolumeDirectory.cpp | 2 +- .../Core/DolphinWX/Android/ButtonManager.cpp | 12 +++--- Source/Core/DolphinWX/Android/ButtonManager.h | 4 +- Source/Core/DolphinWX/ConfigMain.cpp | 11 ++---- .../Debugger/CodeWindowFunctions.cpp | 6 +-- .../DolphinWX/Debugger/DSPDebugWindow.cpp | 7 ++-- .../Core/DolphinWX/Debugger/MemoryWindow.cpp | 2 +- Source/Core/DolphinWX/FifoPlayerDlg.cpp | 4 +- Source/Core/DolphinWX/ISOProperties.cpp | 21 +++++------ Source/Core/DolphinWX/LogWindow.cpp | 2 +- .../DolphinWX/MemoryCards/WiiSaveCrypted.cpp | 16 ++++---- .../ControllerInterface/ExpressionParser.cpp | 4 +- Source/Core/VideoBackends/D3D/D3DUtil.cpp | 4 +- .../VideoBackends/D3D/LineGeometryShader.cpp | 4 +- .../VideoBackends/D3D/PSTextureEncoder.cpp | 5 +-- .../VideoBackends/D3D/PixelShaderCache.cpp | 4 +- .../VideoBackends/D3D/PointGeometryShader.cpp | 4 +- .../VideoBackends/D3D/VertexShaderCache.cpp | 4 +- Source/Core/VideoBackends/OGL/Render.cpp | 13 +++---- Source/Core/VideoCommon/TextureCacheBase.cpp | 2 +- .../Core/VideoCommon/VertexLoaderManager.cpp | 12 +++--- Source/Core/VideoCommon/VideoBackendBase.cpp | 8 ++-- 52 files changed, 199 insertions(+), 230 deletions(-) diff --git a/Source/Core/Common/ArmEmitter.cpp b/Source/Core/Common/ArmEmitter.cpp index 6178d2c58c..00b64606db 100644 --- a/Source/Core/Common/ArmEmitter.cpp +++ b/Source/Core/Common/ArmEmitter.cpp @@ -206,23 +206,23 @@ void ARMXEmitter::ORI2R(ARMReg rd, ARMReg rs, u32 val, ARMReg scratch) void ARMXEmitter::FlushLitPool() { - for(std::vector::iterator it = currentLitPool.begin(); it != currentLitPool.end(); ++it) { + for(LiteralPool& pool : currentLitPool) { // Search for duplicates - for(std::vector::iterator old_it = currentLitPool.begin(); old_it != it; ++old_it) { - if ((*old_it).val == (*it).val) - (*it).loc = (*old_it).loc; + for(LiteralPool& old_pool : currentLitPool) { + if (old_pool.val == pool.val) + pool.loc = old_pool.loc; } // Write the constant to Literal Pool - if (!(*it).loc) + if (!pool.loc) { - (*it).loc = (s32)code; - Write32((*it).val); + pool.loc = (s32)code; + Write32(pool.val); } - s32 offset = (*it).loc - (s32)(*it).ldr_address - 8; + s32 offset = pool.loc - (s32)pool.ldr_address - 8; // Backpatch the LDR - *(u32*)(*it).ldr_address |= (offset >= 0) << 23 | abs(offset); + *(u32*)pool.ldr_address |= (offset >= 0) << 23 | abs(offset); } // TODO: Save a copy of previous pools in case they are still in range. currentLitPool.clear(); diff --git a/Source/Core/Common/BreakPoints.cpp b/Source/Core/Common/BreakPoints.cpp index e4b2337b42..bd96e2cefc 100644 --- a/Source/Core/Common/BreakPoints.cpp +++ b/Source/Core/Common/BreakPoints.cpp @@ -8,11 +8,10 @@ #include "../Core/PowerPC/JitCommon/JitBase.h" #include -#include bool BreakPoints::IsAddressBreakPoint(u32 _iAddress) { - for (auto& bp : m_BreakPoints) + for (const TBreakPoint& bp : m_BreakPoints) if (bp.iAddress == _iAddress) return true; return false; @@ -20,7 +19,7 @@ bool BreakPoints::IsAddressBreakPoint(u32 _iAddress) bool BreakPoints::IsTempBreakPoint(u32 _iAddress) { - for (auto& bp : m_BreakPoints) + for (const TBreakPoint& bp : m_BreakPoints) if (bp.iAddress == _iAddress && bp.bTemporary) return true; return false; @@ -29,7 +28,7 @@ bool BreakPoints::IsTempBreakPoint(u32 _iAddress) BreakPoints::TBreakPointsStr BreakPoints::GetStrings() const { TBreakPointsStr bps; - for (const auto& bp : m_BreakPoints) + for (const TBreakPoint& bp : m_BreakPoints) { if (!bp.bTemporary) { @@ -44,7 +43,7 @@ BreakPoints::TBreakPointsStr BreakPoints::GetStrings() const void BreakPoints::AddFromStrings(const TBreakPointsStr& bpstrs) { - for (const auto& bpstr : bpstrs) + for (const std::string& bpstr : bpstrs) { TBreakPoint bp; std::stringstream ss; @@ -84,7 +83,7 @@ void BreakPoints::Add(u32 em_address, bool temp) void BreakPoints::Remove(u32 em_address) { - for (TBreakPoints::iterator i = m_BreakPoints.begin(); i != m_BreakPoints.end(); ++i) + for (auto i = m_BreakPoints.begin(); i != m_BreakPoints.end(); ++i) { if (i->iAddress == em_address) { @@ -100,12 +99,10 @@ void BreakPoints::Clear() { if (jit) { - std::for_each(m_BreakPoints.begin(), m_BreakPoints.end(), - [](const TBreakPoint& bp) - { - jit->GetBlockCache()->InvalidateICache(bp.iAddress, 4); - } - ); + for (const TBreakPoint& bp : m_BreakPoints) + { + jit->GetBlockCache()->InvalidateICache(bp.iAddress, 4); + } } m_BreakPoints.clear(); @@ -114,7 +111,7 @@ void BreakPoints::Clear() MemChecks::TMemChecksStr MemChecks::GetStrings() const { TMemChecksStr mcs; - for (const auto& bp : m_MemChecks) + for (const TMemCheck& bp : m_MemChecks) { std::stringstream mc; mc << std::hex << bp.StartAddress; @@ -129,7 +126,7 @@ MemChecks::TMemChecksStr MemChecks::GetStrings() const void MemChecks::AddFromStrings(const TMemChecksStr& mcstrs) { - for (const auto& mcstr : mcstrs) + for (const std::string& mcstr : mcstrs) { TMemCheck mc; std::stringstream ss; @@ -156,7 +153,7 @@ void MemChecks::Add(const TMemCheck& _rMemoryCheck) void MemChecks::Remove(u32 _Address) { - for (TMemChecks::iterator i = m_MemChecks.begin(); i != m_MemChecks.end(); ++i) + for (auto i = m_MemChecks.begin(); i != m_MemChecks.end(); ++i) { if (i->StartAddress == _Address) { @@ -168,7 +165,7 @@ void MemChecks::Remove(u32 _Address) TMemCheck *MemChecks::GetMemCheck(u32 address) { - for (auto& bp : m_MemChecks) + for (TMemCheck& bp : m_MemChecks) { if (bp.bRange) { diff --git a/Source/Core/Common/CDUtils.cpp b/Source/Core/Common/CDUtils.cpp index 763fbf7f45..cd9d881fb7 100644 --- a/Source/Core/Common/CDUtils.cpp +++ b/Source/Core/Common/CDUtils.cpp @@ -192,7 +192,7 @@ std::vector cdio_get_devices () for (unsigned int j = checklist[i].num_min; j <= checklist[i].num_max; ++j) { std::string drive = StringFromFormat(checklist[i].format, j); - if ( (is_cdrom(drive.c_str(), NULL)) > 0 ) + if ( (is_cdrom(drive, NULL)) > 0 ) { drives.push_back(std::move(drive)); } diff --git a/Source/Core/Common/ChunkFile.h b/Source/Core/Common/ChunkFile.h index acacca4732..10ec036cad 100644 --- a/Source/Core/Common/ChunkFile.h +++ b/Source/Core/Common/ChunkFile.h @@ -117,9 +117,9 @@ public: case MODE_WRITE: case MODE_MEASURE: case MODE_VERIFY: - for (auto itr = x.begin(); itr != x.end(); ++itr) + for (V& val : x) { - Do(*itr); + Do(val); } break; } diff --git a/Source/Core/Common/IniFile.cpp b/Source/Core/Common/IniFile.cpp index b07fb09224..6999c58693 100644 --- a/Source/Core/Common/IniFile.cpp +++ b/Source/Core/Common/IniFile.cpp @@ -87,10 +87,9 @@ void IniFile::Section::Set(const std::string& key, const std::vector::const_iterator it; - for (it = newValues.begin(); it != newValues.end(); ++it) + for (const std::string& value : newValues) { - temp = (*it) + ","; + temp = value + ","; } // remove last , temp.resize(temp.length() - 1); @@ -210,7 +209,7 @@ bool IniFile::Section::Delete(const std::string& key) const IniFile::Section* IniFile::GetSection(const std::string& sectionName) const { - for (const auto& sect : sections) + for (const Section& sect : sections) if (!strcasecmp(sect.name.c_str(), sectionName.c_str())) return (&(sect)); return 0; @@ -218,7 +217,7 @@ const IniFile::Section* IniFile::GetSection(const std::string& sectionName) cons IniFile::Section* IniFile::GetSection(const std::string& sectionName) { - for (auto& sect : sections) + for (Section& sect : sections) if (!strcasecmp(sect.name.c_str(), sectionName.c_str())) return (&(sect)); return 0; @@ -240,7 +239,7 @@ bool IniFile::DeleteSection(const std::string& sectionName) Section* s = GetSection(sectionName); if (!s) return false; - for (std::vector
::iterator iter = sections.begin(); iter != sections.end(); ++iter) + for (auto iter = sections.begin(); iter != sections.end(); ++iter) { if (&(*iter) == s) { @@ -399,21 +398,21 @@ bool IniFile::Save(const std::string& filename) return false; } - for (auto& section : sections) + for (const Section& section : sections) { if (section.keys_order.size() != 0 || section.lines.size() != 0) out << "[" << section.name << "]" << std::endl; if (section.keys_order.size() == 0) { - for (auto s : section.lines) + for (const std::string& s : section.lines) out << s << std::endl; } else { - for (auto kvit = section.keys_order.begin(); kvit != section.keys_order.end(); ++kvit) + for (const std::string& kvit : section.keys_order) { - auto pair = section.values.find(*kvit); + auto pair = section.values.find(kvit); out << pair->first << " = " << pair->second << std::endl; } } diff --git a/Source/Core/Common/LogManager.cpp b/Source/Core/Common/LogManager.cpp index 5fe218b2f4..c73624c68c 100644 --- a/Source/Core/Common/LogManager.cpp +++ b/Source/Core/Common/LogManager.cpp @@ -81,7 +81,7 @@ LogManager::LogManager() m_consoleLog = new ConsoleListener(); m_debuggerLog = new DebuggerLogListener(); - for (auto& container : m_Log) + for (LogContainer* container : m_Log) { container->SetEnable(true); container->AddListener(m_fileLog); @@ -102,7 +102,7 @@ LogManager::~LogManager() m_logManager->RemoveListener((LogTypes::LOG_TYPE)i, m_debuggerLog); } - for (auto& container : m_Log) + for (LogContainer* container : m_Log) delete container; delete m_fileLog; @@ -168,10 +168,9 @@ void LogContainer::Trigger(LogTypes::LOG_LEVELS level, const char *msg) { std::lock_guard lk(m_listeners_lock); - std::set::const_iterator i; - for (i = m_listeners.begin(); i != m_listeners.end(); ++i) + for (LogListener* listener : m_listeners) { - (*i)->Log(level, msg); + listener->Log(level, msg); } } diff --git a/Source/Core/Common/SymbolDB.h b/Source/Core/Common/SymbolDB.h index e0272d4274..348bdb5055 100644 --- a/Source/Core/Common/SymbolDB.h +++ b/Source/Core/Common/SymbolDB.h @@ -95,11 +95,6 @@ public: const XFuncMap &Symbols() const {return functions;} XFuncMap &AccessSymbols() {return functions;} - // deprecated - XFuncMap::iterator GetIterator() { return functions.begin(); } - XFuncMap::const_iterator GetConstIterator() { return functions.begin(); } - XFuncMap::iterator End() { return functions.end(); } - void Clear(const char *prefix = ""); void List(); void Index(); diff --git a/Source/Core/Common/SysConf.cpp b/Source/Core/Common/SysConf.cpp index acfb11b0ed..6948e7db31 100644 --- a/Source/Core/Common/SysConf.cpp +++ b/Source/Core/Common/SysConf.cpp @@ -25,8 +25,7 @@ SysConf::~SysConf() void SysConf::Clear() { - for (std::vector::const_iterator i = m_Entries.begin(); - i < m_Entries.end() - 1; i++) + for (auto i = m_Entries.begin(); i < m_Entries.end() - 1; ++i) delete [] i->data; m_Entries.clear(); } @@ -85,8 +84,7 @@ bool SysConf::LoadFromFileInternal(FILE *fh) } // Last offset is an invalid entry. We ignore it throughout this class - for (std::vector::iterator i = m_Entries.begin(); - i < m_Entries.end() - 1; i++) + for (auto i = m_Entries.begin(); i < m_Entries.end() - 1; ++i) { SSysConfEntry& curEntry = *i; f.Seek(curEntry.offset, SEEK_SET); @@ -300,7 +298,7 @@ void SysConf::GenerateSysConf() items[26].data[0] = 0x01; - for (auto& item : items) + for (const SSysConfEntry& item : items) m_Entries.push_back(item); File::CreateFullPath(m_FilenameDefault); @@ -362,8 +360,7 @@ bool SysConf::SaveToFile(const char *filename) { File::IOFile f(filename, "r+b"); - for (std::vector::iterator i = m_Entries.begin(); - i < m_Entries.end() - 1; i++) + for (auto i = m_Entries.begin(); i < m_Entries.end() - 1; ++i) { // Seek to after the name of this entry f.Seek(i->offset + i->nameLength + 1, SEEK_SET); diff --git a/Source/Core/Common/SysConf.h b/Source/Core/Common/SysConf.h index f8f6ca317d..1b4706e74a 100644 --- a/Source/Core/Common/SysConf.h +++ b/Source/Core/Common/SysConf.h @@ -79,7 +79,7 @@ public: } std::vector::iterator index = m_Entries.begin(); - for (; index < m_Entries.end() - 1; index++) + for (; index < m_Entries.end() - 1; ++index) { if (strcmp(index->name, sectionName) == 0) break; @@ -102,7 +102,7 @@ public: } std::vector::iterator index = m_Entries.begin(); - for (; index < m_Entries.end() - 1; index++) + for (; index < m_Entries.end() - 1; ++index) { if (strcmp(index->name, sectionName) == 0) break; @@ -122,7 +122,7 @@ public: return false; std::vector::iterator index = m_Entries.begin(); - for (; index < m_Entries.end() - 1; index++) + for (; index < m_Entries.end() - 1; ++index) { if (strcmp(index->name, sectionName) == 0) break; @@ -143,7 +143,7 @@ public: return false; std::vector::iterator index = m_Entries.begin(); - for (; index < m_Entries.end() - 1; index++) + for (; index < m_Entries.end() - 1; ++index) { if (strcmp(index->name, sectionName) == 0) break; diff --git a/Source/Core/Core/Core.cpp b/Source/Core/Core/Core.cpp index 342d241842..716c9f4d8e 100644 --- a/Source/Core/Core/Core.cpp +++ b/Source/Core/Core/Core.cpp @@ -673,9 +673,9 @@ void UpdateTitle() if (ElapseTime == 0) ElapseTime = 1; - float FPS = Common::AtomicLoad(DrawnFrame) * 1000.0 / ElapseTime; - float VPS = DrawnVideo * 1000.0 / ElapseTime; - float Speed = DrawnVideo * (100 * 1000.0) / (VideoInterface::TargetRefreshRate * ElapseTime); + float FPS = (float) (Common::AtomicLoad(DrawnFrame) * 1000.0 / ElapseTime); + float VPS = (float) (DrawnVideo * 1000.0 / ElapseTime); + float Speed = (float) (DrawnVideo * (100 * 1000.0) / (VideoInterface::TargetRefreshRate * ElapseTime)); // Settings are shown the same for both extended and summary info std::string SSettings = StringFromFormat("%s %s | %s | %s", cpu_core_base->GetName(), _CoreParameter.bCPUThread ? "DC" : "SC", diff --git a/Source/Core/Core/DSP/disassemble.cpp b/Source/Core/Core/DSP/disassemble.cpp index 99bd2811b3..33fc28eb7a 100644 --- a/Source/Core/Core/DSP/disassemble.cpp +++ b/Source/Core/Core/DSP/disassemble.cpp @@ -55,18 +55,17 @@ DSPDisassembler::~DSPDisassembler() return; int count = 0; - for (std::map::const_iterator iter = unk_opcodes.begin(); - iter != unk_opcodes.end(); ++iter) + for (const auto& entry : unk_opcodes) { - if (iter->second > 0) + if (entry.second > 0) { count++; - fprintf(uo.GetHandle(), "OP%04x\t%d", iter->first, iter->second); + fprintf(uo.GetHandle(), "OP%04x\t%d", entry.first, entry.second); for (int j = 15; j >= 0; j--) // print op bits { if ((j & 0x3) == 3) fprintf(uo.GetHandle(), "\tb"); - fprintf(uo.GetHandle(), "%d", (iter->first >> j) & 0x1); + fprintf(uo.GetHandle(), "%d", (entry.first >> j) & 0x1); } fprintf(uo.GetHandle(), "\n"); } diff --git a/Source/Core/Core/HW/DSPHLE/MailHandler.h b/Source/Core/Core/HW/DSPHLE/MailHandler.h index b54c163d87..94a98f8bfa 100644 --- a/Source/Core/Core/HW/DSPHLE/MailHandler.h +++ b/Source/Core/Core/HW/DSPHLE/MailHandler.h @@ -26,7 +26,7 @@ public: u32 GetNextMail() { - if (m_Mails.size()) + if (!m_Mails.empty()) { return m_Mails.front(); } diff --git a/Source/Core/Core/HW/EXI_DeviceGecko.cpp b/Source/Core/Core/HW/EXI_DeviceGecko.cpp index 0bb84c4fdb..b8ac071425 100644 --- a/Source/Core/Core/HW/EXI_DeviceGecko.cpp +++ b/Source/Core/Core/HW/EXI_DeviceGecko.cpp @@ -77,7 +77,7 @@ bool GeckoSockServer::GetAvailableSock(sf::SocketTCP &sock_to_fill) std::lock_guard lk(connection_lock); - if (waiting_socks.size()) + if (!waiting_socks.empty()) { sock_to_fill = waiting_socks.front(); if (clientThread.joinable()) diff --git a/Source/Core/Core/HW/SI_DeviceGBA.cpp b/Source/Core/Core/HW/SI_DeviceGBA.cpp index 6a59ecd3af..754c17d376 100644 --- a/Source/Core/Core/HW/SI_DeviceGBA.cpp +++ b/Source/Core/Core/HW/SI_DeviceGBA.cpp @@ -56,7 +56,7 @@ bool GetAvailableSock(sf::SocketTCP& sock_to_fill) std::lock_guard lk(cs_gba); - if (waiting_socks.size()) + if (!waiting_socks.empty()) { sock_to_fill = waiting_socks.front(); waiting_socks.pop(); diff --git a/Source/Core/Core/HW/WiimoteEmu/EmuSubroutines.cpp b/Source/Core/Core/HW/WiimoteEmu/EmuSubroutines.cpp index ebb3ff6adf..f30d81224a 100644 --- a/Source/Core/Core/HW/WiimoteEmu/EmuSubroutines.cpp +++ b/Source/Core/Core/HW/WiimoteEmu/EmuSubroutines.cpp @@ -1257,7 +1257,7 @@ void Wiimote::DoState(PointerWrap& p) if (p.mode == PointerWrap::MODE_READ) { //clear - while (m_read_requests.size()) + while (!m_read_requests.empty()) m_read_requests.pop(); p.Do(size); diff --git a/Source/Core/Core/HW/WiimoteEmu/WiimoteEmu.cpp b/Source/Core/Core/HW/WiimoteEmu/WiimoteEmu.cpp index b259334d03..edebc2fb1b 100644 --- a/Source/Core/Core/HW/WiimoteEmu/WiimoteEmu.cpp +++ b/Source/Core/Core/HW/WiimoteEmu/WiimoteEmu.cpp @@ -252,7 +252,7 @@ void Wiimote::Reset() memset(m_shake_step, 0, sizeof(m_shake_step)); // clear read request queue - while (m_read_requests.size()) + while (!m_read_requests.empty()) { delete[] m_read_requests.front().data; m_read_requests.pop(); @@ -351,7 +351,7 @@ bool Wiimote::Step() } // check if there is a read data request - if (m_read_requests.size()) + if (!m_read_requests.empty()) { ReadRequest& rr = m_read_requests.front(); // send up to 16 bytes to the wii diff --git a/Source/Core/Core/IPC_HLE/WII_IPC_HLE.cpp b/Source/Core/Core/IPC_HLE/WII_IPC_HLE.cpp index 3bd37ba373..ba6cf7936b 100644 --- a/Source/Core/Core/IPC_HLE/WII_IPC_HLE.cpp +++ b/Source/Core/Core/IPC_HLE/WII_IPC_HLE.cpp @@ -606,9 +606,9 @@ void Update() void UpdateDevices() { // Check if a hardware device must be updated - for (TDeviceMap::const_iterator itr = g_DeviceMap.begin(); itr != g_DeviceMap.end(); ++itr) + for (const auto& entry : g_DeviceMap) { - if (itr->second->IsOpened() && itr->second->Update()) + if (entry.second->IsOpened() && entry.second->Update()) { break; } diff --git a/Source/Core/Core/IPC_HLE/WII_IPC_HLE_Device_fs.cpp b/Source/Core/Core/IPC_HLE/WII_IPC_HLE_Device_fs.cpp index 4de7af8e06..31c5c6f7cd 100644 --- a/Source/Core/Core/IPC_HLE/WII_IPC_HLE_Device_fs.cpp +++ b/Source/Core/Core/IPC_HLE/WII_IPC_HLE_Device_fs.cpp @@ -59,8 +59,7 @@ bool CWII_IPC_HLE_Device_fs::Close(u32 _CommandAddress, bool _bForce) static u64 ComputeTotalFileSize(const File::FSTEntry& parentEntry) { u64 sizeOfFiles = 0; - const std::vector& children = parentEntry.children; - for (const auto& entry : children) + for (const File::FSTEntry& entry : parentEntry.children) { if (entry.isDirectory) sizeOfFiles += ComputeTotalFileSize(entry); @@ -146,10 +145,10 @@ bool CWII_IPC_HLE_Device_fs::IOCtlV(u32 _CommandAddress) // Decode entities of invalid file system characters so that // games (such as HP:HBP) will be able to find what they expect. - for (Common::replace_v::const_iterator it = replacements.begin(); it != replacements.end(); ++it) + for (const Common::replace_t& r : replacements) { - for (size_t j = 0; (j = FileName.find(it->second, j)) != FileName.npos; ++j) - FileName.replace(j, it->second.length(), 1, it->first); + for (size_t j = 0; (j = FileName.find(r.second, j)) != FileName.npos; ++j) + FileName.replace(j, r.second.length(), 1, r.first); } strcpy(pFilename, FileName.c_str()); diff --git a/Source/Core/Core/IPC_HLE/WII_IPC_HLE_Device_hid.cpp b/Source/Core/Core/IPC_HLE/WII_IPC_HLE_Device_hid.cpp index c1b82e4d55..636c8830a8 100644 --- a/Source/Core/Core/IPC_HLE/WII_IPC_HLE_Device_hid.cpp +++ b/Source/Core/Core/IPC_HLE/WII_IPC_HLE_Device_hid.cpp @@ -94,9 +94,9 @@ CWII_IPC_HLE_Device_hid::~CWII_IPC_HLE_Device_hid() deinit_libusb = true; } - for ( std::map::const_iterator iter = open_devices.begin(); iter != open_devices.end(); ++iter ) + for (const auto& device : open_devices) { - libusb_close(iter->second); + libusb_close(device.second); } open_devices.clear(); diff --git a/Source/Core/Core/IPC_HLE/WII_Socket.cpp b/Source/Core/Core/IPC_HLE/WII_Socket.cpp index 32e6cbe81c..35655778c9 100644 --- a/Source/Core/Core/IPC_HLE/WII_Socket.cpp +++ b/Source/Core/Core/IPC_HLE/WII_Socket.cpp @@ -582,9 +582,9 @@ void WiiSockMan::Update() FD_ZERO(&read_fds); FD_ZERO(&write_fds); FD_ZERO(&except_fds); - for (auto it = WiiSockets.begin(); it != WiiSockets.end(); ++it) + for (auto& entry : WiiSockets) { - WiiSocket& sock = it->second; + WiiSocket& sock = entry.second; if (sock.valid()) { FD_SET(sock.fd, &read_fds); diff --git a/Source/Core/Core/NetPlayServer.cpp b/Source/Core/Core/NetPlayServer.cpp index 3209f6ad28..91fa402b6b 100644 --- a/Source/Core/Core/NetPlayServer.cpp +++ b/Source/Core/Core/NetPlayServer.cpp @@ -196,14 +196,11 @@ unsigned int NetPlayServer::OnConnect(sf::SocketTCP& socket) socket.Send(spac); // sync values with new client - std::map::const_iterator - i, - e = m_players.end(); - for (i = m_players.begin(); i!=e; ++i) + for (const auto& p : m_players) { spac.Clear(); spac << (MessageId)NP_MSG_PLAYER_JOIN; - spac << i->second.pid << i->second.name << i->second.revision; + spac << p.second.pid << p.second.name << p.second.revision; socket.Send(spac); } @@ -613,7 +610,7 @@ void NetPlayServer::unmapPortThread() // discovers the IGD bool NetPlayServer::initUPnP() { - UPNPDev *devlist, *dev; + UPNPDev *devlist; std::vector igds; int descXMLsize = 0, upnperror = 0; char *descXML; @@ -642,18 +639,14 @@ bool NetPlayServer::initUPnP() } // Look for the IGD - dev = devlist; - while (dev) + for (UPNPDev* dev = devlist; dev; dev = dev->pNext) { if (strstr(dev->st, "InternetGatewayDevice")) igds.push_back(dev); - dev = dev->pNext; } - std::vector::iterator i; - for (i = igds.begin(); i != igds.end(); i++) + for (const UPNPDev* dev : igds) { - dev = *i; descXML = (char *) miniwget(dev->descURL, &descXMLsize, 0); if (descXML) { diff --git a/Source/Core/Core/PatchEngine.cpp b/Source/Core/Core/PatchEngine.cpp index 8b07bf18bb..2c2a4f30fc 100644 --- a/Source/Core/Core/PatchEngine.cpp +++ b/Source/Core/Core/PatchEngine.cpp @@ -53,8 +53,8 @@ void LoadPatchSection(const char *section, std::vector &patches, std::string enabledSectionName = std::string(section) + "_Enabled"; std::vector enabledLines; std::set enabledNames; - localIni.GetLines(enabledSectionName, enabledLines); - for (auto& line : enabledLines) + localIni.GetLines(enabledSectionName.c_str(), enabledLines); + for (const std::string& line : enabledLines) { if (line.size() != 0 && line[0] == '$') { @@ -71,7 +71,7 @@ void LoadPatchSection(const char *section, std::vector &patches, Patch currentPatch; inis[i]->GetLines(section, lines); - for (auto line : lines) + for (std::string& line : lines) { if (line.size() == 0) continue; @@ -124,10 +124,9 @@ static void LoadDiscList(const char *section, std::vector &_discLis if (!ini.GetLines(section, lines)) return; - for (std::vector::const_iterator iter = lines.begin(); iter != lines.end(); ++iter) + for (const std::string& line : lines) { - std::string line = *iter; - if (line.size()) + if (!line.empty()) _discList.push_back(line); } } @@ -136,9 +135,8 @@ static void LoadSpeedhacks(const char *section, std::map &hacks, IniFi { std::vector keys; ini.GetKeys(section, keys); - for (std::vector::const_iterator iter = keys.begin(); iter != keys.end(); ++iter) + for (const std::string& key : keys) { - std::string key = *iter; std::string value; ini.Get(section, key, &value, "BOGUS"); if (value != "BOGUS") @@ -184,15 +182,15 @@ void LoadPatches() void ApplyPatches(const std::vector &patches) { - for (const auto& patch : patches) + for (const Patch& patch : patches) { if (patch.active) { - for (std::vector::const_iterator iter2 = patch.entries.begin(); iter2 != patch.entries.end(); ++iter2) + for (const PatchEntry& entry : patch.entries) { - u32 addr = iter2->address; - u32 value = iter2->value; - switch (iter2->type) + u32 addr = entry.address; + u32 value = entry.value; + switch (entry.type) { case PATCH_8BIT: Memory::Write_U8((u8)value, addr); diff --git a/Source/Core/Core/PowerPC/Interpreter/Interpreter_FPUtils.h b/Source/Core/Core/PowerPC/Interpreter/Interpreter_FPUtils.h index 2c1b0f7076..d2c5c23c5a 100644 --- a/Source/Core/Core/PowerPC/Interpreter/Interpreter_FPUtils.h +++ b/Source/Core/Core/PowerPC/Interpreter/Interpreter_FPUtils.h @@ -70,7 +70,7 @@ inline void UpdateFPSCR() inline double ForceSingle(double _x) { // convert to float... - float x = _x; + float x = (float) _x; if (!cpu_info.bFlushToZero && FPSCR.NI) { x = FlushToZero(x); diff --git a/Source/Core/Core/PowerPC/Jit64/Jit_Integer.cpp b/Source/Core/Core/PowerPC/Jit64/Jit_Integer.cpp index 244a051aaa..696bf398f1 100644 --- a/Source/Core/Core/PowerPC/Jit64/Jit_Integer.cpp +++ b/Source/Core/Core/PowerPC/Jit64/Jit_Integer.cpp @@ -1789,7 +1789,7 @@ void Jit64::rlwimix(UGeckoInstruction inst) } else if (inst.SH) { - if (mask == -(1U << inst.SH)) + if (mask == 0U - (1U << inst.SH)) { MOV(32, R(EAX), gpr.R(s)); SHL(32, R(EAX), Imm8(inst.SH)); diff --git a/Source/Core/Core/PowerPC/JitCommon/JitCache.cpp b/Source/Core/Core/PowerPC/JitCommon/JitCache.cpp index d7c78d9d17..a7efa3d1c4 100644 --- a/Source/Core/Core/PowerPC/JitCommon/JitCache.cpp +++ b/Source/Core/Core/PowerPC/JitCommon/JitCache.cpp @@ -374,7 +374,7 @@ using namespace Gen; JitBlock &b = blocks[it2->second]; *GetICachePtr(b.originalAddress) = JIT_ICACHE_INVALID_WORD; DestroyBlock(it2->second, true); - it2++; + ++it2; } if (it1 != it2) { diff --git a/Source/Core/Core/PowerPC/PPCAnalyst.cpp b/Source/Core/Core/PowerPC/PPCAnalyst.cpp index 462d9503e4..67c92eaef0 100644 --- a/Source/Core/Core/PowerPC/PPCAnalyst.cpp +++ b/Source/Core/Core/PowerPC/PPCAnalyst.cpp @@ -196,7 +196,7 @@ void AnalyzeFunction2(Symbol *func) u32 flags = func->flags; bool nonleafcall = false; - for (auto c : func->calls) + for (const SCall& c : func->calls) { Symbol *called_func = g_symbolDB.GetSymbolFromAddr(c.function); if (called_func && (called_func->flags & FFLAG_LEAF) == 0) @@ -603,10 +603,10 @@ void FindFunctionsAfterBLR(PPCSymbolDB *func_db) { vector funcAddrs; - for (PPCSymbolDB::XFuncMap::iterator iter = func_db->GetIterator(); iter != func_db->End(); ++iter) - funcAddrs.push_back(iter->second.address + iter->second.size); + for (const auto& func : func_db->Symbols()) + funcAddrs.push_back(func.second.address + func.second.size); - for (auto location : funcAddrs) + for (u32& location : funcAddrs) { while (true) { @@ -637,15 +637,15 @@ void FindFunctions(u32 startAddr, u32 endAddr, PPCSymbolDB *func_db) int numLeafs = 0, numNice = 0, numUnNice = 0; int numTimer = 0, numRFI = 0, numStraightLeaf = 0; int leafSize = 0, niceSize = 0, unniceSize = 0; - for (PPCSymbolDB::XFuncMap::iterator iter = func_db->GetIterator(); iter != func_db->End(); ++iter) + for (auto& func : func_db->AccessSymbols()) { - if (iter->second.address == 4) + if (func.second.address == 4) { WARN_LOG(OSHLE, "Weird function"); continue; } - AnalyzeFunction2(&(iter->second)); - Symbol &f = iter->second; + AnalyzeFunction2(&(func.second)); + Symbol &f = func.second; if (f.name.substr(0, 3) == "zzz") { if (f.flags & FFLAG_LEAF) diff --git a/Source/Core/Core/PowerPC/PPCSymbolDB.cpp b/Source/Core/Core/PowerPC/PPCSymbolDB.cpp index 37621388fe..eb5b65a49e 100644 --- a/Source/Core/Core/PowerPC/PPCSymbolDB.cpp +++ b/Source/Core/Core/PowerPC/PPCSymbolDB.cpp @@ -119,12 +119,12 @@ void PPCSymbolDB::FillInCallers() p.second.callers.clear(); } - for (XFuncMap::iterator iter = functions.begin(); iter != functions.end(); ++iter) + for (auto& entry : functions) { - Symbol &f = iter->second; - for (auto& call : f.calls) + Symbol &f = entry.second; + for (const SCall& call : f.calls) { - SCall NewCall(iter->first, call.callAddress); + SCall NewCall(entry.first, call.callAddress); u32 FunctionAddress = call.function; XFuncMap::iterator FuncIterator = functions.find(FunctionAddress); @@ -149,12 +149,12 @@ void PPCSymbolDB::PrintCalls(u32 funcAddr) const { const Symbol &f = iter->second; INFO_LOG(OSHLE, "The function %s at %08x calls:", f.name.c_str(), f.address); - for (std::vector::const_iterator fiter = f.calls.begin(); fiter!=f.calls.end(); ++fiter) + for (const SCall& call : f.calls) { - XFuncMap::const_iterator n = functions.find(fiter->function); + XFuncMap::const_iterator n = functions.find(call.function); if (n != functions.end()) { - INFO_LOG(CONSOLE,"* %08x : %s", fiter->callAddress, n->second.name.c_str()); + INFO_LOG(CONSOLE,"* %08x : %s", call.callAddress, n->second.name.c_str()); } } } @@ -171,12 +171,12 @@ void PPCSymbolDB::PrintCallers(u32 funcAddr) const { const Symbol &f = iter->second; INFO_LOG(CONSOLE,"The function %s at %08x is called by:",f.name.c_str(),f.address); - for (std::vector::const_iterator fiter = f.callers.begin(); fiter != f.callers.end(); ++fiter) + for (const SCall& caller : f.callers) { - XFuncMap::const_iterator n = functions.find(fiter->function); + XFuncMap::const_iterator n = functions.find(caller.function); if (n != functions.end()) { - INFO_LOG(CONSOLE,"* %08x : %s", fiter->callAddress, n->second.name.c_str()); + INFO_LOG(CONSOLE,"* %08x : %s", caller.callAddress, n->second.name.c_str()); } } } diff --git a/Source/Core/Core/PowerPC/SignatureDB.cpp b/Source/Core/Core/PowerPC/SignatureDB.cpp index 4e91499306..82474fc03f 100644 --- a/Source/Core/Core/PowerPC/SignatureDB.cpp +++ b/Source/Core/Core/PowerPC/SignatureDB.cpp @@ -56,13 +56,13 @@ bool SignatureDB::Save(const char *filename) } u32 fcount = (u32)database.size(); f.WriteArray(&fcount, 1); - for (FuncDB::const_iterator iter = database.begin(); iter != database.end(); ++iter) + for (const auto& entry : database) { FuncDesc temp; memset(&temp, 0, sizeof(temp)); - temp.checkSum = iter->first; - temp.size = iter->second.size; - strncpy(temp.name, iter->second.name.c_str(), 127); + temp.checkSum = entry.first; + temp.size = entry.second.size; + strncpy(temp.name, entry.second.name.c_str(), 127); f.WriteArray(&temp, 1); } @@ -87,9 +87,9 @@ u32 SignatureDB::Add(u32 startAddr, u32 size, const char *name) void SignatureDB::List() { - for (FuncDB::iterator iter = database.begin(); iter != database.end(); ++iter) + for (const auto& entry : database) { - INFO_LOG(OSHLE, "%s : %i bytes, hash = %08x", iter->second.name.c_str(), iter->second.size, iter->first); + INFO_LOG(OSHLE, "%s : %i bytes, hash = %08x", entry.second.name.c_str(), entry.second.size, entry.first); } INFO_LOG(OSHLE, "%lu functions known in current database.", (unsigned long)database.size()); @@ -102,22 +102,23 @@ void SignatureDB::Clear() void SignatureDB::Apply(PPCSymbolDB *symbol_db) { - for (FuncDB::const_iterator iter = database.begin(); iter != database.end(); ++iter) + for (const auto& entry : database) { - u32 hash = iter->first; + u32 hash = entry.first; Symbol *function = symbol_db->GetSymbolFromHash(hash); if (function) { // Found the function. Let's rename it according to the symbol file. - if (iter->second.size == (unsigned int)function->size) + if (entry.second.size == (unsigned int)function->size) { - function->name = iter->second.name; - INFO_LOG(OSHLE, "Found %s at %08x (size: %08x)!", iter->second.name.c_str(), function->address, function->size); + function->name = entry.second.name; + INFO_LOG(OSHLE, "Found %s at %08x (size: %08x)!", entry.second.name.c_str(), function->address, function->size); } else { - function->name = iter->second.name; - ERROR_LOG(OSHLE, "Wrong size! Found %s at %08x (size: %08x instead of %08x)!", iter->second.name.c_str(), function->address, function->size, iter->second.size); + function->name = entry.second.name; + ERROR_LOG(OSHLE, "Wrong size! Found %s at %08x (size: %08x instead of %08x)!", + entry.second.name.c_str(), function->address, function->size, entry.second.size); } } } @@ -127,14 +128,14 @@ void SignatureDB::Apply(PPCSymbolDB *symbol_db) void SignatureDB::Initialize(PPCSymbolDB *symbol_db, const char *prefix) { std::string prefix_str(prefix); - for (PPCSymbolDB::XFuncMap::const_iterator iter = symbol_db->GetConstIterator(); iter != symbol_db->End(); ++iter) + for (const auto& symbol : symbol_db->Symbols()) { - if ((iter->second.name.substr(0, prefix_str.size()) == prefix_str) || prefix_str.empty()) + if ((symbol.second.name.substr(0, prefix_str.size()) == prefix_str) || prefix_str.empty()) { DBFunc temp_dbfunc; - temp_dbfunc.name = iter->second.name; - temp_dbfunc.size = iter->second.size; - database[iter->second.hash] = temp_dbfunc; + temp_dbfunc.name = symbol.second.name; + temp_dbfunc.size = symbol.second.size; + database[symbol.second.hash] = temp_dbfunc; } } } diff --git a/Source/Core/DiscIO/CompressedBlob.cpp b/Source/Core/DiscIO/CompressedBlob.cpp index c801ea3698..ac3050fd6f 100644 --- a/Source/Core/DiscIO/CompressedBlob.cpp +++ b/Source/Core/DiscIO/CompressedBlob.cpp @@ -21,9 +21,8 @@ namespace DiscIO { -CompressedBlobReader::CompressedBlobReader(const char *filename) +CompressedBlobReader::CompressedBlobReader(const char *filename) : file_name(filename) { - file_name = filename; m_file.Open(filename, "rb"); file_size = File::GetSize(filename); m_file.ReadArray(&header, 1); diff --git a/Source/Core/DiscIO/DiscScrubber.cpp b/Source/Core/DiscIO/DiscScrubber.cpp index 928383579e..445f25bfb1 100644 --- a/Source/Core/DiscIO/DiscScrubber.cpp +++ b/Source/Core/DiscIO/DiscScrubber.cpp @@ -267,7 +267,7 @@ bool ParsePartitionData(SPartition& _rPartition) IVolume *OldVolume = m_Disc; // Ready some stuff - m_Disc = CreateVolumeFromFilename(m_Filename.c_str(), _rPartition.GroupNumber, _rPartition.Number); + m_Disc = CreateVolumeFromFilename(m_Filename, _rPartition.GroupNumber, _rPartition.Number); IFileSystem *FileSystem = CreateFileSystem(m_Disc); if (!FileSystem) diff --git a/Source/Core/DiscIO/VolumeDirectory.cpp b/Source/Core/DiscIO/VolumeDirectory.cpp index f9f8f00ea8..a501a9c0fa 100644 --- a/Source/Core/DiscIO/VolumeDirectory.cpp +++ b/Source/Core/DiscIO/VolumeDirectory.cpp @@ -106,7 +106,7 @@ bool CVolumeDirectory::Read(u64 _Offset, u64 _Length, u8* _pBuffer) const WriteToBuffer(FST_ADDRESS, m_fstSize, m_FSTData, _Offset, _Length, _pBuffer); } - if(m_virtualDisk.size() == 0) + if(m_virtualDisk.empty()) return true; // Determine which file the offset refers to diff --git a/Source/Core/DolphinWX/Android/ButtonManager.cpp b/Source/Core/DolphinWX/Android/ButtonManager.cpp index 5c71a7197a..7d4fb97f3d 100644 --- a/Source/Core/DolphinWX/Android/ButtonManager.cpp +++ b/Source/Core/DolphinWX/Android/ButtonManager.cpp @@ -127,8 +127,8 @@ namespace ButtonManager bool pressed = false; pressed = m_buttons[std::make_pair(padID, button)]->Pressed(); - for (auto it = m_controllers.begin(); it != m_controllers.end(); ++it) - pressed |= it->second->ButtonValue(padID, button); + for (const auto& ctrl : m_controllers) + pressed |= ctrl.second->ButtonValue(padID, button); return pressed; } @@ -172,10 +172,10 @@ namespace ButtonManager } void Shutdown() { - for(auto it = m_buttons.begin(); it != m_buttons.end(); ++it) - delete it->second; - for (auto it = m_controllers.begin(); it != m_controllers.end(); ++it) - delete it->second; + for (const auto& button : m_buttons) + delete button.second; + for (const auto& controller : m_controllers) + delete controller.second; m_controllers.clear(); m_buttons.clear(); } diff --git a/Source/Core/DolphinWX/Android/ButtonManager.h b/Source/Core/DolphinWX/Android/ButtonManager.h index ff3b7f6bd4..07b3bfffbd 100644 --- a/Source/Core/DolphinWX/Android/ButtonManager.h +++ b/Source/Core/DolphinWX/Android/ButtonManager.h @@ -108,8 +108,8 @@ namespace ButtonManager : _dev(dev) {} ~InputDevice() { - for (auto it = _binds.begin(); it != _binds.end(); ++it) - delete it->second; + for (const auto& bind : _binds) + delete bind.second; } void AddBind(sBind *bind) { _binds[bind->_buttontype] = bind; _inputbinds[bind->_bind] = bind; } void PressEvent(int button, int action); diff --git a/Source/Core/DolphinWX/ConfigMain.cpp b/Source/Core/DolphinWX/ConfigMain.cpp index 46187d0da7..75f0d17d94 100644 --- a/Source/Core/DolphinWX/ConfigMain.cpp +++ b/Source/Core/DolphinWX/ConfigMain.cpp @@ -184,7 +184,7 @@ CConfigMain::CConfigMain(wxWindow* parent, wxWindowID id, const wxString& title, CreateGUIControls(); // Update selected ISO paths - for(auto& folder : SConfig::GetInstance().m_ISOFolder) + for(const std::string& folder : SConfig::GetInstance().m_ISOFolder) { ISOPaths->Append(StrToWxStr(folder)); } @@ -250,7 +250,7 @@ void CConfigMain::InitializeGUILists() arrayStringFor_Framelimit.Add(wxString::Format(wxT("%i"), i)); // Emulator Engine - for (auto& CPUCores_a : CPUCores) + for (const CPUCore& CPUCores_a : CPUCores) arrayStringFor_CPUEngine.Add(wxGetTranslation(CPUCores_a.name)); // DSP Engine @@ -979,12 +979,9 @@ void CConfigMain::AudioSettingsChanged(wxCommandEvent& event) void CConfigMain::AddAudioBackends() { - std::vector backends = AudioCommon::GetSoundBackends(); - // I'm sure Billiard will change this into an auto sometimes soon :P - for (std::vector::const_iterator iter = backends.begin(); - iter != backends.end(); ++iter) + for (const std::string& backend : AudioCommon::GetSoundBackends()) { - BackendSelection->Append(wxGetTranslation(StrToWxStr(*iter))); + BackendSelection->Append(wxGetTranslation(StrToWxStr(backend))); int num = BackendSelection-> FindString(StrToWxStr(SConfig::GetInstance().sBackend)); BackendSelection->SetSelection(num); diff --git a/Source/Core/DolphinWX/Debugger/CodeWindowFunctions.cpp b/Source/Core/DolphinWX/Debugger/CodeWindowFunctions.cpp index 4f8f71225c..be6d8e4c04 100644 --- a/Source/Core/DolphinWX/Debugger/CodeWindowFunctions.cpp +++ b/Source/Core/DolphinWX/Debugger/CodeWindowFunctions.cpp @@ -354,10 +354,10 @@ void CCodeWindow::NotifyMapLoaded() //symbols->Show(false); // hide it for faster filling symbols->Freeze(); // HyperIris: wx style fast filling symbols->Clear(); - for (PPCSymbolDB::XFuncMap::iterator iter = g_symbolDB.GetIterator(); iter != g_symbolDB.End(); ++iter) + for (const auto& symbol : g_symbolDB.Symbols()) { - int idx = symbols->Append(StrToWxStr(iter->second.name)); - symbols->SetClientData(idx, (void*)&iter->second); + int idx = symbols->Append(StrToWxStr(symbol.second.name)); + symbols->SetClientData(idx, (void*)&symbol.second); } symbols->Thaw(); //symbols->Show(true); diff --git a/Source/Core/DolphinWX/Debugger/DSPDebugWindow.cpp b/Source/Core/DolphinWX/Debugger/DSPDebugWindow.cpp index 3be7432eca..48435c73a2 100644 --- a/Source/Core/DolphinWX/Debugger/DSPDebugWindow.cpp +++ b/Source/Core/DolphinWX/Debugger/DSPDebugWindow.cpp @@ -205,11 +205,10 @@ void DSPDebuggerLLE::UpdateSymbolMap() m_SymbolList->Freeze(); // HyperIris: wx style fast filling m_SymbolList->Clear(); - for (SymbolDB::XFuncMap::iterator iter = DSPSymbols::g_dsp_symbol_db.GetIterator(); - iter != DSPSymbols::g_dsp_symbol_db.End(); ++iter) + for (const auto& symbol : DSPSymbols::g_dsp_symbol_db.Symbols()) { - int idx = m_SymbolList->Append(StrToWxStr(iter->second.name)); - m_SymbolList->SetClientData(idx, (void*)&iter->second); + int idx = m_SymbolList->Append(StrToWxStr(symbol.second.name)); + m_SymbolList->SetClientData(idx, (void*)&symbol.second); } m_SymbolList->Thaw(); } diff --git a/Source/Core/DolphinWX/Debugger/MemoryWindow.cpp b/Source/Core/DolphinWX/Debugger/MemoryWindow.cpp index bff24623e1..e49512afea 100644 --- a/Source/Core/DolphinWX/Debugger/MemoryWindow.cpp +++ b/Source/Core/DolphinWX/Debugger/MemoryWindow.cpp @@ -337,7 +337,7 @@ void CMemoryWindow::onSearch(wxCommandEvent& event) tmpstr = new char[newsize + 1]; memset(tmpstr, 0, newsize + 1); } - sprintf(tmpstr, "%s%s", tmpstr, WxStrToStr(rawData).c_str()); + strcat(tmpstr, WxStrToStr(rawData).c_str()); tmp2 = &Dest.front(); count = 0; for(i = 0; i < strlen(tmpstr); i++) diff --git a/Source/Core/DolphinWX/FifoPlayerDlg.cpp b/Source/Core/DolphinWX/FifoPlayerDlg.cpp index 0a957c7b06..5e3c7b0451 100644 --- a/Source/Core/DolphinWX/FifoPlayerDlg.cpp +++ b/Source/Core/DolphinWX/FifoPlayerDlg.cpp @@ -515,7 +515,7 @@ void FifoPlayerDlg::OnFindNextClick(wxCommandEvent& event) return; } - for (std::vector::iterator it = search_results.begin(); it != search_results.end(); ++it) + for (auto it = search_results.begin(); it != search_results.end(); ++it) { if (it->cmd_idx > cur_cmd_index) { @@ -534,7 +534,7 @@ void FifoPlayerDlg::OnFindPreviousClick(wxCommandEvent& event) return; } - for (std::vector::reverse_iterator it = search_results.rbegin(); it != search_results.rend(); ++it) + for (auto it = search_results.rbegin(); it != search_results.rend(); ++it) { if (it->cmd_idx < cur_cmd_index) { diff --git a/Source/Core/DolphinWX/ISOProperties.cpp b/Source/Core/DolphinWX/ISOProperties.cpp index d2bf7ca329..8899a5441b 100644 --- a/Source/Core/DolphinWX/ISOProperties.cpp +++ b/Source/Core/DolphinWX/ISOProperties.cpp @@ -1010,19 +1010,19 @@ void CISOProperties::LoadGameConfig() // First set values from default gameini, then apply values from local gameini int iTemp; GameIniDefault.Get("Video", "ProjectionHack", &iTemp); - PHackEnable->SetValue(iTemp); + PHackEnable->SetValue(!!iTemp); if (GameIniLocal.Get("Video", "ProjectionHack", &iTemp)) - PHackEnable->SetValue(iTemp); + PHackEnable->SetValue(!!iTemp); GameIniDefault.Get("Video", "PH_SZNear", &PHack_Data.PHackSZNear); if (GameIniLocal.GetIfExists("Video", "PH_SZNear", &iTemp)) - PHack_Data.PHackSZNear = iTemp; + PHack_Data.PHackSZNear = !!iTemp; GameIniDefault.Get("Video", "PH_SZFar", &PHack_Data.PHackSZFar); if (GameIniLocal.GetIfExists("Video", "PH_SZFar", &iTemp)) - PHack_Data.PHackSZFar = iTemp; + PHack_Data.PHackSZFar = !!iTemp; GameIniDefault.Get("Video", "PH_ExtraParam", &PHack_Data.PHackExP); if (GameIniLocal.GetIfExists("Video", "PH_ExtraParam", &iTemp)) - PHack_Data.PHackExP = iTemp; + PHack_Data.PHackExP = !!iTemp; std::string sTemp; GameIniDefault.Get("Video", "PH_ZNear", &PHack_Data.PHZNear); @@ -1242,9 +1242,9 @@ void CISOProperties::PatchList_Save() if (DefaultPatches.find(p.name) == DefaultPatches.end()) { lines.push_back("$" + p.name); - for (auto iter2 = p.entries.begin(); iter2 != p.entries.end(); ++iter2) + for (const PatchEngine::PatchEntry& entry : p.entries) { - std::string temp = StringFromFormat("0x%08X:%s:0x%08X", iter2->address, PatchEngine::PatchTypeStrings[iter2->type], iter2->value); + std::string temp = StringFromFormat("0x%08X:%s:0x%08X", entry.address, PatchEngine::PatchTypeStrings[entry.type], entry.value); lines.push_back(temp); } } @@ -1308,9 +1308,8 @@ void CISOProperties::ActionReplayList_Load() ActionReplay::LoadCodes(arCodes, GameIniDefault, GameIniLocal); u32 index = 0; - for (std::vector::const_iterator it = arCodes.begin(); it != arCodes.end(); ++it) + for (const ActionReplay::ARCode& arCode : arCodes) { - ActionReplay::ARCode arCode = *it; Cheats->Append(StrToWxStr(arCode.name)); Cheats->Check(index, arCode.active); if (!arCode.user_defined) @@ -1324,7 +1323,7 @@ void CISOProperties::ActionReplayList_Save() std::vector lines; std::vector enabledLines; u32 index = 0; - for (auto code : arCodes) + for (const ActionReplay::ARCode& code : arCodes) { if (Cheats->IsChecked(index)) enabledLines.push_back("$" + code.name); @@ -1333,7 +1332,7 @@ void CISOProperties::ActionReplayList_Save() if (DefaultCheats.find(code.name) == DefaultCheats.end()) { lines.push_back("$" + code.name); - for (auto& op : code.ops) + for (const ActionReplay::AREntry& op : code.ops) { lines.push_back(WxStrToStr(wxString::Format(wxT("%08X %08X"), op.cmd_addr, op.value))); } diff --git a/Source/Core/DolphinWX/LogWindow.cpp b/Source/Core/DolphinWX/LogWindow.cpp index 6579a8831e..5d6b5265fe 100644 --- a/Source/Core/DolphinWX/LogWindow.cpp +++ b/Source/Core/DolphinWX/LogWindow.cpp @@ -277,7 +277,7 @@ void CLogWindow::OnLogTimer(wxTimerEvent& WXUNUSED(event)) UpdateLog(); // Scroll to the last line - if (msgQueue.size() > 0) + if (!msgQueue.empty()) { m_Log->ScrollLines(1); m_Log->ShowPosition( m_Log->GetLastPosition() ); diff --git a/Source/Core/DolphinWX/MemoryCards/WiiSaveCrypted.cpp b/Source/Core/DolphinWX/MemoryCards/WiiSaveCrypted.cpp index 2ccc236395..0d1a8960ab 100644 --- a/Source/Core/DolphinWX/MemoryCards/WiiSaveCrypted.cpp +++ b/Source/Core/DolphinWX/MemoryCards/WiiSaveCrypted.cpp @@ -47,7 +47,7 @@ void CWiiSaveCrypted::ExportAllSaves() std::string folder = StringFromFormat("%s/%08x/", titleFolder.c_str(), pathMask | i); File::ScanDirectoryTree(folder, FST_Temp); - for (auto& entry : FST_Temp.children) + for (const File::FSTEntry& entry : FST_Temp.children) { if (entry.isDirectory) { @@ -65,7 +65,7 @@ void CWiiSaveCrypted::ExportAllSaves() } } SuccessAlertT("Found %x save files", (unsigned int) titles.size()); - for (auto& title : titles) + for (const u64& title : titles) { CWiiSaveCrypted* exportSave = new CWiiSaveCrypted("", title); delete exportSave; @@ -377,21 +377,21 @@ void CWiiSaveCrypted::ExportWiiSaveFiles() __name = FilesList[i].substr(WiiTitlePath.length()+1); - for (Common::replace_v::const_iterator iter = replacements.begin(); iter != replacements.end(); ++iter) + for (const Common::replace_t& repl : replacements) { - for (size_t j = 0; (j = __name.find(iter->second, j)) != __name.npos; ++j) + for (size_t j = 0; (j = __name.find(repl.second, j)) != __name.npos; ++j) { - __name.replace(j, iter->second.length(), 1, iter->first); + __name.replace(j, repl.second.length(), 1, repl.first); } } if (__name.length() > 0x44) { - PanicAlertT("%s is too long for the filename, max chars is 45", __name.c_str()); + PanicAlertT("\"%s\" is too long for the filename, max length is 0x44 + \\0", __name.c_str()); b_valid = false; return; } - strncpy((char *)tmpFileHDR.name, __name.c_str(), __name.length()); + strncpy((char *)tmpFileHDR.name, __name.c_str(), sizeof(tmpFileHDR.name)); { File::IOFile fpData_bin(encryptedSavePath, "ab"); @@ -583,7 +583,7 @@ void CWiiSaveCrypted::ScanForFiles(std::string savDir, std::vector& File::FSTEntry FST_Temp; File::ScanDirectoryTree(Directories[i], FST_Temp); - for (auto& elem : FST_Temp.children) + for (const File::FSTEntry& elem : FST_Temp.children) { if (strncmp(elem.virtualName.c_str(), "banner.bin", 10) != 0) { diff --git a/Source/Core/InputCommon/ControllerInterface/ExpressionParser.cpp b/Source/Core/InputCommon/ControllerInterface/ExpressionParser.cpp index 7f7954d3d8..802d1b8f0f 100644 --- a/Source/Core/InputCommon/ControllerInterface/ExpressionParser.cpp +++ b/Source/Core/InputCommon/ControllerInterface/ExpressionParser.cpp @@ -102,7 +102,7 @@ public: while (it != expr.end()) { char c = *it; - it++; + ++it; if (c == '`') return false; if (c > 0 && c == otherDelim) @@ -140,7 +140,7 @@ public: if (!isalpha(c)) break; name += c; - it++; + ++it; } ControlQualifier qualifier; diff --git a/Source/Core/VideoBackends/D3D/D3DUtil.cpp b/Source/Core/VideoBackends/D3D/D3DUtil.cpp index c64230f23d..df965dc58b 100644 --- a/Source/Core/VideoBackends/D3D/D3DUtil.cpp +++ b/Source/Core/VideoBackends/D3D/D3DUtil.cpp @@ -41,8 +41,8 @@ public: offset = 0; context->Map(buf, 0, D3D11_MAP_WRITE_DISCARD, 0, &map); - for(std::list::iterator it = observers.begin(); it != observers.end(); ++it) - **it = true; + for(bool* observer : observers) + *observer = true; } else { diff --git a/Source/Core/VideoBackends/D3D/LineGeometryShader.cpp b/Source/Core/VideoBackends/D3D/LineGeometryShader.cpp index 944dca38f2..1974a71f0d 100644 --- a/Source/Core/VideoBackends/D3D/LineGeometryShader.cpp +++ b/Source/Core/VideoBackends/D3D/LineGeometryShader.cpp @@ -149,9 +149,9 @@ void LineGeometryShader::Shutdown() { m_ready = false; - for (ComboMap::iterator it = m_shaders.begin(); it != m_shaders.end(); ++it) + for (auto& it : m_shaders) { - SAFE_RELEASE(it->second); + SAFE_RELEASE(it.second); } m_shaders.clear(); diff --git a/Source/Core/VideoBackends/D3D/PSTextureEncoder.cpp b/Source/Core/VideoBackends/D3D/PSTextureEncoder.cpp index badeb0f566..0a8243ed5c 100644 --- a/Source/Core/VideoBackends/D3D/PSTextureEncoder.cpp +++ b/Source/Core/VideoBackends/D3D/PSTextureEncoder.cpp @@ -1012,10 +1012,9 @@ void PSTextureEncoder::Shutdown() SAFE_RELEASE(m_classLinkage); SAFE_RELEASE(m_dynamicShader); - for (ComboMap::iterator it = m_staticShaders.begin(); - it != m_staticShaders.end(); ++it) + for (auto& it : m_staticShaders) { - SAFE_RELEASE(it->second); + SAFE_RELEASE(it.second); } m_staticShaders.clear(); diff --git a/Source/Core/VideoBackends/D3D/PixelShaderCache.cpp b/Source/Core/VideoBackends/D3D/PixelShaderCache.cpp index d8716c85f2..bb87720891 100644 --- a/Source/Core/VideoBackends/D3D/PixelShaderCache.cpp +++ b/Source/Core/VideoBackends/D3D/PixelShaderCache.cpp @@ -410,8 +410,8 @@ void PixelShaderCache::Init() // ONLY to be used during shutdown. void PixelShaderCache::Clear() { - for (PSCache::iterator iter = PixelShaders.begin(); iter != PixelShaders.end(); iter++) - iter->second.Destroy(); + for (auto& iter : PixelShaders) + iter.second.Destroy(); PixelShaders.clear(); pixel_uid_checker.Invalidate(); diff --git a/Source/Core/VideoBackends/D3D/PointGeometryShader.cpp b/Source/Core/VideoBackends/D3D/PointGeometryShader.cpp index 34d87efb0f..d8dc17317b 100644 --- a/Source/Core/VideoBackends/D3D/PointGeometryShader.cpp +++ b/Source/Core/VideoBackends/D3D/PointGeometryShader.cpp @@ -143,9 +143,9 @@ void PointGeometryShader::Shutdown() { m_ready = false; - for (ComboMap::iterator it = m_shaders.begin(); it != m_shaders.end(); ++it) + for (auto& it : m_shaders) { - SAFE_RELEASE(it->second); + SAFE_RELEASE(it.second); } m_shaders.clear(); diff --git a/Source/Core/VideoBackends/D3D/VertexShaderCache.cpp b/Source/Core/VideoBackends/D3D/VertexShaderCache.cpp index e17f273a85..b3a399ed5e 100644 --- a/Source/Core/VideoBackends/D3D/VertexShaderCache.cpp +++ b/Source/Core/VideoBackends/D3D/VertexShaderCache.cpp @@ -157,8 +157,8 @@ void VertexShaderCache::Init() void VertexShaderCache::Clear() { - for (VSCache::iterator iter = vshaders.begin(); iter != vshaders.end(); ++iter) - iter->second.Destroy(); + for (auto& iter : vshaders) + iter.second.Destroy(); vshaders.clear(); vertex_uid_checker.Invalidate(); diff --git a/Source/Core/VideoBackends/OGL/Render.cpp b/Source/Core/VideoBackends/OGL/Render.cpp index 8921fdd2ae..6d4d73da38 100644 --- a/Source/Core/VideoBackends/OGL/Render.cpp +++ b/Source/Core/VideoBackends/OGL/Render.cpp @@ -710,15 +710,14 @@ void Renderer::DrawDebugInfo() int a = 0; GLfloat color[3] = {0.0f, 1.0f, 1.0f}; - for (std::vector::const_iterator it = stats.efb_regions.begin(); - it != stats.efb_regions.end(); ++it) + for (const EFBRectangle& rect : stats.efb_regions) { GLfloat halfWidth = EFB_WIDTH / 2.0f; GLfloat halfHeight = EFB_HEIGHT / 2.0f; - GLfloat x = (GLfloat) -1.0f + ((GLfloat)it->left / halfWidth); - GLfloat y = (GLfloat) 1.0f - ((GLfloat)it->top / halfHeight); - GLfloat x2 = (GLfloat) -1.0f + ((GLfloat)it->right / halfWidth); - GLfloat y2 = (GLfloat) 1.0f - ((GLfloat)it->bottom / halfHeight); + GLfloat x = (GLfloat) -1.0f + ((GLfloat)rect.left / halfWidth); + GLfloat y = (GLfloat) 1.0f - ((GLfloat)rect.top / halfHeight); + GLfloat x2 = (GLfloat) -1.0f + ((GLfloat)rect.right / halfWidth); + GLfloat y2 = (GLfloat) 1.0f - ((GLfloat)rect.bottom / halfHeight); Vertices[a++] = x; Vertices[a++] = y; @@ -1782,7 +1781,7 @@ void Renderer::FlipImageData(u8 *data, int w, int h, int pixel_width) { for(int x = 0; x < w; ++x) { - for (auto delta = 0; delta < pixel_width; ++delta) + for (int delta = 0; delta < pixel_width; ++delta) std::swap(data[(y * w + x) * pixel_width + delta], data[((h - 1 - y) * w + x) * pixel_width + delta]); } } diff --git a/Source/Core/VideoCommon/TextureCacheBase.cpp b/Source/Core/VideoCommon/TextureCacheBase.cpp index a3224bcf08..6903f778c7 100644 --- a/Source/Core/VideoCommon/TextureCacheBase.cpp +++ b/Source/Core/VideoCommon/TextureCacheBase.cpp @@ -172,7 +172,7 @@ void TextureCache::MakeRangeDynamic(u32 start_address, u32 size) tcend = textures.upper_bound(start_address + size); if (iter != textures.begin()) - iter--; + --iter; for (; iter != tcend; ++iter) { diff --git a/Source/Core/VideoCommon/VertexLoaderManager.cpp b/Source/Core/VideoCommon/VertexLoaderManager.cpp index d1f1acf9a4..fbc48e5fb7 100644 --- a/Source/Core/VideoCommon/VertexLoaderManager.cpp +++ b/Source/Core/VideoCommon/VertexLoaderManager.cpp @@ -43,7 +43,7 @@ static VertexLoaderMap g_VertexLoaderMap; void Init() { MarkAllDirty(); - for (auto& vertexLoader : g_VertexLoaders) + for (VertexLoader*& vertexLoader : g_VertexLoaders) vertexLoader = NULL; RecomputeCachedArraybases(); } @@ -75,19 +75,19 @@ void AppendListToString(std::string *dest) std::vector entries; size_t total_size = 0; - for (VertexLoaderMap::const_iterator iter = g_VertexLoaderMap.begin(); iter != g_VertexLoaderMap.end(); ++iter) + for (const auto& map_entry : g_VertexLoaderMap) { entry e; - iter->second->AppendToString(&e.text); - e.num_verts = iter->second->GetNumLoadedVerts(); + map_entry.second->AppendToString(&e.text); + e.num_verts = map_entry.second->GetNumLoadedVerts(); entries.push_back(e); total_size += e.text.size() + 1; } sort(entries.begin(), entries.end()); dest->reserve(dest->size() + total_size); - for (std::vector::const_iterator iter = entries.begin(); iter != entries.end(); ++iter) + for (const entry& entry : entries) { - dest->append(iter->text); + dest->append(entry.text); } } diff --git a/Source/Core/VideoCommon/VideoBackendBase.cpp b/Source/Core/VideoCommon/VideoBackendBase.cpp index b99b6743c9..7e9fbfd033 100644 --- a/Source/Core/VideoCommon/VideoBackendBase.cpp +++ b/Source/Core/VideoCommon/VideoBackendBase.cpp @@ -48,7 +48,7 @@ void VideoBackend::PopulateList() #endif g_available_video_backends.push_back(backends[3] = new SW::VideoSoftware); - for (auto& backend : backends) + for (VideoBackend* backend : backends) { if (backend) { @@ -72,7 +72,7 @@ void VideoBackend::ActivateBackend(const std::string& name) if (name.length() == 0) // If NULL, set it to the default backend (expected behavior) g_video_backend = s_default_backend; - for (std::vector::const_iterator it = g_available_video_backends.begin(); it != g_available_video_backends.end(); ++it) - if (name == (*it)->GetName()) - g_video_backend = *it; + for (VideoBackend* backend : g_available_video_backends) + if (name == backend->GetName()) + g_video_backend = backend; }