From 4000009e8b66a904b51072e9e67a273bfef317a3 Mon Sep 17 00:00:00 2001 From: Shawn Hoffman Date: Wed, 7 Jun 2017 04:06:04 -0700 Subject: [PATCH 01/23] msbuild: disable warnings from Externals\enet --- Externals/enet/enet.vcxproj | 1 + 1 file changed, 1 insertion(+) diff --git a/Externals/enet/enet.vcxproj b/Externals/enet/enet.vcxproj index 71e0086faf..ac6fe790b1 100644 --- a/Externals/enet/enet.vcxproj +++ b/Externals/enet/enet.vcxproj @@ -61,6 +61,7 @@ + From 4f9dd7277b8d2f1f56071f753081451d361bb7e2 Mon Sep 17 00:00:00 2001 From: Shawn Hoffman Date: Wed, 7 Jun 2017 04:09:26 -0700 Subject: [PATCH 02/23] msvc: disable unused symbol warning in Core/Common/Crypto/ec.cpp --- Source/Core/Common/Crypto/ec.cpp | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/Source/Core/Common/Crypto/ec.cpp b/Source/Core/Common/Crypto/ec.cpp index 9dca32878b..5fe7e9bb2b 100644 --- a/Source/Core/Common/Crypto/ec.cpp +++ b/Source/Core/Common/Crypto/ec.cpp @@ -15,6 +15,11 @@ #include "Common/Crypto/bn.h" #include "Common/Crypto/ec.h" +#ifdef _MSC_VER +#pragma warning(push) +#pragma warning(disable : 4505) +#endif + // y**2 + x*y = x**3 + x + b UNUSED static const u8 ec_b[30] = {0x00, 0x66, 0x64, 0x7e, 0xde, 0x6c, 0x33, 0x2c, 0x7f, 0x8c, 0x09, 0x23, 0xbb, 0x58, 0x21, 0x3b, 0x33, 0x3b, 0x20, 0xe9, @@ -404,3 +409,7 @@ void ec_priv_to_pub(const u8* k, u8* Q) { point_mul(Q, k, ec_G); } + +#ifdef _MSC_VER +#pragma warning(pop) +#endif From f7f1d5d2ca1e5de5eda350a7af3bd46519bde2f8 Mon Sep 17 00:00:00 2001 From: Shawn Hoffman Date: Wed, 7 Jun 2017 04:10:23 -0700 Subject: [PATCH 03/23] msvc: disable meaningless constant truncation warnings in SDCardUtil --- Source/Core/Common/SDCardUtil.cpp | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/Source/Core/Common/SDCardUtil.cpp b/Source/Core/Common/SDCardUtil.cpp index 1bb09878b6..9e72990747 100644 --- a/Source/Core/Common/SDCardUtil.cpp +++ b/Source/Core/Common/SDCardUtil.cpp @@ -49,6 +49,11 @@ #include // for unlink() #endif +#ifdef _MSC_VER +#pragma warning(push) +#pragma warning(disable : 4310) +#endif + /* Believe me, you *don't* want to change these constants !! */ #define BYTES_PER_SECTOR 512 #define RESERVED_SECTORS 32 @@ -289,3 +294,7 @@ FailWrite: ERROR_LOG(COMMON, "unlink(%s) failed: %s", filename.c_str(), GetLastErrorMsg().c_str()); return false; } + +#ifdef _MSC_VER +#pragma warning(pop) +#endif From be7c6a081918ac2240f6a2e4e51ca6e3daa0f032 Mon Sep 17 00:00:00 2001 From: Shawn Hoffman Date: Wed, 7 Jun 2017 04:11:23 -0700 Subject: [PATCH 04/23] msvc: disable warning about using setjmp w/c++ objects in scope --- Source/Core/VideoCommon/ImageWrite.cpp | 31 +++++++++++++++++++++----- 1 file changed, 25 insertions(+), 6 deletions(-) diff --git a/Source/Core/VideoCommon/ImageWrite.cpp b/Source/Core/VideoCommon/ImageWrite.cpp index 6156ca2cb1..e7930a18c6 100644 --- a/Source/Core/VideoCommon/ImageWrite.cpp +++ b/Source/Core/VideoCommon/ImageWrite.cpp @@ -21,6 +21,11 @@ bool SaveData(const std::string& filename, const std::string& data) return true; } +#ifdef _MSC_VER +#pragma warning(push) +#pragma warning(disable : 4611) +#endif + /* TextureToPng @@ -31,20 +36,16 @@ row_stride: Determines the amount of bytes per row of pixels. bool TextureToPng(const u8* data, int row_stride, const std::string& filename, int width, int height, bool saveAlpha) { - bool success = false; - if (!data) return false; + bool success = false; char title[] = "Dolphin Screenshot"; char title_key[] = "Title"; png_structp png_ptr = nullptr; png_infop info_ptr = nullptr; std::vector buffer; - if (!saveAlpha) - buffer.resize(width * 4); - // Open file for writing (binary mode) File::IOFile fp(filename, "wb"); if (!fp.IsOpen()) @@ -70,13 +71,22 @@ bool TextureToPng(const u8* data, int row_stride, const std::string& filename, i goto finalise; } - // Setup Exception handling + // Classical libpng error handling uses longjmp to do C-style unwind. + // Modern libpng does support a user callback, but it's required to operate + // in the same way (just gives a chance to do stuff before the longjmp). + // Instead of futzing with it, we use gotos specifically so the compiler + // will still generate proper destructor calls for us (hopefully). + // We also do not use any local variables outside the region longjmp may + // have been called from if they were modified inside that region (they + // would need to be volatile). if (setjmp(png_jmpbuf(png_ptr))) { PanicAlert("Screenshot failed: Error during PNG creation"); goto finalise; } + // Begin region which may call longjmp + png_init_io(png_ptr, fp.GetHandle()); // Write header (8 bit color depth) @@ -91,6 +101,9 @@ bool TextureToPng(const u8* data, int row_stride, const std::string& filename, i png_write_info(png_ptr, info_ptr); + if (!saveAlpha) + buffer.resize(width * 4); + // Write image data for (auto y = 0; y < height; ++y) { @@ -114,6 +127,8 @@ bool TextureToPng(const u8* data, int row_stride, const std::string& filename, i // End write png_write_end(png_ptr, nullptr); + // End region which may call longjmp + success = true; finalise: @@ -124,3 +139,7 @@ finalise: return success; } + +#ifdef _MSC_VER +#pragma warning(pop) +#endif From e1a3e41bf33bf6a366760ede17c2e3bd2b106116 Mon Sep 17 00:00:00 2001 From: Shawn Hoffman Date: Wed, 7 Jun 2017 04:16:02 -0700 Subject: [PATCH 05/23] fix various instances of -1 being assigned to unsigned types --- Source/Core/Common/FileUtil.cpp | 2 +- Source/Core/Common/MathUtil.h | 2 +- Source/Core/Common/Profiler.cpp | 6 +++--- Source/Core/Common/Thread.cpp | 9 +++------ Source/Core/Core/Debugger/Dump.cpp | 4 ++-- .../Core/PowerPC/Interpreter/Interpreter_Integer.cpp | 2 +- Source/Core/Core/PowerPC/PPCAnalyst.cpp | 4 ++-- Source/Core/DiscIO/CISOBlob.h | 2 +- Source/Core/DiscIO/VolumeDirectory.cpp | 2 +- Source/Core/DiscIO/VolumeWii.cpp | 3 ++- Source/Core/DolphinWX/Debugger/DSPDebugWindow.cpp | 2 +- Source/Core/VideoBackends/OGL/TextureCache.cpp | 8 ++++---- Source/Core/VideoCommon/IndexGenerator.cpp | 2 +- Source/Core/VideoCommon/TextureCacheBase.cpp | 2 +- Source/Core/VideoCommon/VertexLoaderBase.h | 2 +- 15 files changed, 25 insertions(+), 27 deletions(-) diff --git a/Source/Core/Common/FileUtil.cpp b/Source/Core/Common/FileUtil.cpp index ebab9e9c48..2ae063673f 100644 --- a/Source/Core/Common/FileUtil.cpp +++ b/Source/Core/Common/FileUtil.cpp @@ -986,7 +986,7 @@ u64 IOFile::Tell() const if (IsOpen()) return ftello(m_file); else - return -1; + return UINT64_MAX; } bool IOFile::Flush() diff --git a/Source/Core/Common/MathUtil.h b/Source/Core/Common/MathUtil.h index 7e48e38d80..becaf09792 100644 --- a/Source/Core/Common/MathUtil.h +++ b/Source/Core/Common/MathUtil.h @@ -198,7 +198,7 @@ inline int IntLog2(u64 val) return 63 - __builtin_clzll(val); #elif defined(_MSC_VER) - unsigned long result = -1; + unsigned long result = ULONG_MAX; _BitScanReverse64(&result, val); return result; diff --git a/Source/Core/Common/Profiler.cpp b/Source/Core/Common/Profiler.cpp index fdc356a164..0be14073bd 100644 --- a/Source/Core/Common/Profiler.cpp +++ b/Source/Core/Common/Profiler.cpp @@ -29,8 +29,8 @@ std::string Profiler::s_lazy_result = ""; int Profiler::s_lazy_delay = 0; Profiler::Profiler(const std::string& name) - : m_name(name), m_usecs(0), m_usecs_min(-1), m_usecs_max(0), m_usecs_quad(0), m_calls(0), - m_depth(0) + : m_name(name), m_usecs(0), m_usecs_min(UINT64_MAX), m_usecs_max(0), m_usecs_quad(0), + m_calls(0), m_depth(0) { m_time = Common::Timer::GetTimeUs(); s_max_length = std::max(s_max_length, u32(m_name.length())); @@ -154,7 +154,7 @@ std::string Profiler::Read() buffer << std::setw(PROFILER_FIELD_LENGTH) << std::right << m_usecs_max; m_usecs = 0; - m_usecs_min = -1; + m_usecs_min = UINT64_MAX; m_usecs_max = 0; m_usecs_quad = 0; m_calls = 0; diff --git a/Source/Core/Common/Thread.cpp b/Source/Core/Common/Thread.cpp index 190653ee31..fa81314795 100644 --- a/Source/Core/Common/Thread.cpp +++ b/Source/Core/Common/Thread.cpp @@ -62,11 +62,8 @@ void SwitchCurrentThread() } // Sets the debugger-visible name of the current thread. -// Uses undocumented (actually, it is now documented) trick. -// http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vsdebug/html/vxtsksettingthreadname.asp - -// This is implemented much nicer in upcoming msvc++, see: -// http://msdn.microsoft.com/en-us/library/xcb2z8hs(VS.100).aspx +// Uses trick documented in: +// https://docs.microsoft.com/en-us/visualstudio/debugger/how-to-set-a-thread-name-in-native-code void SetCurrentThreadName(const char* szThreadName) { static const DWORD MS_VC_EXCEPTION = 0x406D1388; @@ -83,7 +80,7 @@ void SetCurrentThreadName(const char* szThreadName) info.dwType = 0x1000; info.szName = szThreadName; - info.dwThreadID = -1; // dwThreadID; + info.dwThreadID = static_cast(-1); info.dwFlags = 0; __try diff --git a/Source/Core/Core/Debugger/Dump.cpp b/Source/Core/Core/Debugger/Dump.cpp index 45f8fde926..a7ee736caf 100644 --- a/Source/Core/Core/Debugger/Dump.cpp +++ b/Source/Core/Core/Debugger/Dump.cpp @@ -42,7 +42,7 @@ u32 CDump::GetGPR(int _step, int _gpr) u32 offset = _step * STRUCTUR_SIZE; if (offset >= m_size) - return -1; + return UINT32_MAX; return Read32(offset + OFFSET_GPR + (_gpr * 4)); } @@ -52,7 +52,7 @@ u32 CDump::GetPC(int _step) u32 offset = _step * STRUCTUR_SIZE; if (offset >= m_size) - return -1; + return UINT32_MAX; return Read32(offset + OFFSET_PC); } diff --git a/Source/Core/Core/PowerPC/Interpreter/Interpreter_Integer.cpp b/Source/Core/Core/PowerPC/Interpreter/Interpreter_Integer.cpp index 480ee662da..65b8547b98 100644 --- a/Source/Core/Core/PowerPC/Interpreter/Interpreter_Integer.cpp +++ b/Source/Core/Core/PowerPC/Interpreter/Interpreter_Integer.cpp @@ -495,7 +495,7 @@ void Interpreter::divwx(UGeckoInstruction inst) } if (((u32)a & 0x80000000) && b == 0) - rGPR[inst.RD] = -1; + rGPR[inst.RD] = UINT32_MAX; else rGPR[inst.RD] = 0; } diff --git a/Source/Core/Core/PowerPC/PPCAnalyst.cpp b/Source/Core/Core/PowerPC/PPCAnalyst.cpp index 733bf6d3b1..c34cfd72fc 100644 --- a/Source/Core/Core/PowerPC/PPCAnalyst.cpp +++ b/Source/Core/Core/PowerPC/PPCAnalyst.cpp @@ -730,8 +730,8 @@ u32 PPCAnalyzer::Analyze(u32 address, CodeBlock* block, CodeBuffer* buffer, u32 code[i].opinfo = opinfo; code[i].address = address; code[i].inst = inst; - code[i].branchTo = -1; - code[i].branchToIndex = -1; + code[i].branchTo = UINT32_MAX; + code[i].branchToIndex = UINT32_MAX; code[i].skip = false; block->m_stats->numCycles += opinfo->numCycles; block->m_physical_addresses.insert(result.physical_address); diff --git a/Source/Core/DiscIO/CISOBlob.h b/Source/Core/DiscIO/CISOBlob.h index b674dedc18..a1c8c97b40 100644 --- a/Source/Core/DiscIO/CISOBlob.h +++ b/Source/Core/DiscIO/CISOBlob.h @@ -48,7 +48,7 @@ private: CISOFileReader(File::IOFile file); typedef u16 MapType; - static const MapType UNUSED_BLOCK_ID = -1; + static const MapType UNUSED_BLOCK_ID = UINT16_MAX; File::IOFile m_file; u64 m_size; diff --git a/Source/Core/DiscIO/VolumeDirectory.cpp b/Source/Core/DiscIO/VolumeDirectory.cpp index ed965983e6..f6f603d8ff 100644 --- a/Source/Core/DiscIO/VolumeDirectory.cpp +++ b/Source/Core/DiscIO/VolumeDirectory.cpp @@ -35,7 +35,7 @@ const size_t VolumeDirectory::MAX_ID_LENGTH; VolumeDirectory::VolumeDirectory(const std::string& directory, bool is_wii, const std::string& apploader, const std::string& dol) - : m_data_start_address(-1), m_disk_header(DISKHEADERINFO_ADDRESS), + : m_data_start_address(UINT64_MAX), m_disk_header(DISKHEADERINFO_ADDRESS), m_disk_header_info(std::make_unique()), m_fst_address(0), m_dol_address(0) { m_root_directory = ExtractDirectoryName(directory); diff --git a/Source/Core/DiscIO/VolumeWii.cpp b/Source/Core/DiscIO/VolumeWii.cpp index f928bbcdf3..4b6ef56539 100644 --- a/Source/Core/DiscIO/VolumeWii.cpp +++ b/Source/Core/DiscIO/VolumeWii.cpp @@ -32,7 +32,8 @@ namespace DiscIO constexpr u64 PARTITION_DATA_OFFSET = 0x20000; VolumeWii::VolumeWii(std::unique_ptr reader) - : m_pReader(std::move(reader)), m_game_partition(PARTITION_NONE), m_last_decrypted_block(-1) + : m_pReader(std::move(reader)), m_game_partition(PARTITION_NONE), + m_last_decrypted_block(UINT64_MAX) { _assert_(m_pReader); diff --git a/Source/Core/DolphinWX/Debugger/DSPDebugWindow.cpp b/Source/Core/DolphinWX/Debugger/DSPDebugWindow.cpp index 922fd3c0c7..8c4be0c3f4 100644 --- a/Source/Core/DolphinWX/Debugger/DSPDebugWindow.cpp +++ b/Source/Core/DolphinWX/Debugger/DSPDebugWindow.cpp @@ -32,7 +32,7 @@ static DSPDebuggerLLE* m_DebuggerFrame = nullptr; DSPDebuggerLLE::DSPDebuggerLLE(wxWindow* parent, wxWindowID id) : wxPanel(parent, id, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL, _("DSP LLE Debugger")), - m_CachedStepCounter(-1), m_toolbar_item_size(FromDIP(wxSize(16, 16))) + m_CachedStepCounter(UINT64_MAX), m_toolbar_item_size(FromDIP(wxSize(16, 16))) { Bind(wxEVT_MENU, &DSPDebuggerLLE::OnChangeState, this, ID_RUNTOOL, ID_SHOWPCTOOL); diff --git a/Source/Core/VideoBackends/OGL/TextureCache.cpp b/Source/Core/VideoBackends/OGL/TextureCache.cpp index 2031d7e220..169dec0bc5 100644 --- a/Source/Core/VideoBackends/OGL/TextureCache.cpp +++ b/Source/Core/VideoBackends/OGL/TextureCache.cpp @@ -370,9 +370,9 @@ TextureCache::TextureCache() { CompileShaders(); - s_ActiveTexture = -1; + s_ActiveTexture = UINT32_MAX; for (auto& gtex : s_Textures) - gtex = -1; + gtex = UINT32_MAX; if (g_ActiveConfig.backend_info.bSupportsPaletteConversion) { @@ -519,8 +519,8 @@ bool TextureCache::CompileShaders() s_ColorMatrixUniform = glGetUniformLocation(s_ColorMatrixProgram.glprogid, "colmat"); s_DepthMatrixUniform = glGetUniformLocation(s_DepthMatrixProgram.glprogid, "colmat"); - s_ColorCbufid = -1; - s_DepthCbufid = -1; + s_ColorCbufid = UINT32_MAX; + s_DepthCbufid = UINT32_MAX; s_ColorCopyPositionUniform = glGetUniformLocation(s_ColorCopyProgram.glprogid, "copy_position"); s_ColorMatrixPositionUniform = diff --git a/Source/Core/VideoCommon/IndexGenerator.cpp b/Source/Core/VideoCommon/IndexGenerator.cpp index 79dbc92597..74f6a8a728 100644 --- a/Source/Core/VideoCommon/IndexGenerator.cpp +++ b/Source/Core/VideoCommon/IndexGenerator.cpp @@ -16,7 +16,7 @@ u16* IndexGenerator::index_buffer_current; u16* IndexGenerator::BASEIptr; u32 IndexGenerator::base_index; -static const u16 s_primitive_restart = -1; +static const u16 s_primitive_restart = UINT16_MAX; static u16* (*primitive_table[8])(u16*, u32, u32); diff --git a/Source/Core/VideoCommon/TextureCacheBase.cpp b/Source/Core/VideoCommon/TextureCacheBase.cpp index 613f2dfed9..72978f6752 100644 --- a/Source/Core/VideoCommon/TextureCacheBase.cpp +++ b/Source/Core/VideoCommon/TextureCacheBase.cpp @@ -994,7 +994,7 @@ void TextureCacheBase::CopyRenderTargetToTexture(u32 dstAddr, unsigned int dstFo float* const ColorMask = colmat + 20; ColorMask[0] = ColorMask[1] = ColorMask[2] = ColorMask[3] = 255.0f; ColorMask[4] = ColorMask[5] = ColorMask[6] = ColorMask[7] = 1.0f / 255.0f; - unsigned int cbufid = -1; + unsigned int cbufid = UINT_MAX; u32 srcFormat = bpmem.zcontrol.pixel_format; bool efbHasAlpha = srcFormat == PEControl::RGBA6_Z24; diff --git a/Source/Core/VideoCommon/VertexLoaderBase.h b/Source/Core/VideoCommon/VertexLoaderBase.h index a895300466..509ccb4310 100644 --- a/Source/Core/VideoCommon/VertexLoaderBase.h +++ b/Source/Core/VideoCommon/VertexLoaderBase.h @@ -36,7 +36,7 @@ public: private: size_t CalculateHash() const { - size_t h = -1; + size_t h = SIZE_MAX; for (auto word : vid) { From f730b775b6663d7957c51b0cd234dfe73c189905 Mon Sep 17 00:00:00 2001 From: Shawn Hoffman Date: Wed, 7 Jun 2017 04:17:34 -0700 Subject: [PATCH 06/23] quiet warnings about possibly-uninitialized variable usage --- Source/Core/Core/HW/DVD/DVDInterface.cpp | 4 ++-- Source/Core/Core/IOS/USB/Bluetooth/BTReal.cpp | 2 +- Source/Core/Core/PowerPC/Jit64/Jit_LoadStore.cpp | 2 +- Source/Core/DolphinWX/Debugger/MemoryCheckDlg.cpp | 2 +- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/Source/Core/Core/HW/DVD/DVDInterface.cpp b/Source/Core/Core/HW/DVD/DVDInterface.cpp index 2ea86942da..ee02b90533 100644 --- a/Source/Core/Core/HW/DVD/DVDInterface.cpp +++ b/Source/Core/Core/HW/DVD/DVDInterface.cpp @@ -349,8 +349,8 @@ static void DTKStreamingCallback(const std::vector& audio_data, s64 cycles_l // Determine which audio data to read next. static const int MAXIMUM_SAMPLES = 48000 / 2000 * 7; // 3.5ms of 48kHz samples - u64 read_offset; - u32 read_length; + u64 read_offset = 0; + u32 read_length = 0; if (s_stream && AudioInterface::IsPlaying()) { read_offset = s_audio_position; diff --git a/Source/Core/Core/IOS/USB/Bluetooth/BTReal.cpp b/Source/Core/Core/IOS/USB/Bluetooth/BTReal.cpp index caf3136ff4..d3aa66fc7c 100644 --- a/Source/Core/Core/IOS/USB/Bluetooth/BTReal.cpp +++ b/Source/Core/Core/IOS/USB/Bluetooth/BTReal.cpp @@ -533,7 +533,7 @@ void BluetoothReal::LoadLinkKeys() std::reverse(address.begin(), address.end()); const std::string& key_string = pair.substr(index + 1); - linkkey_t key; + linkkey_t key{}; size_t pos = 0; for (size_t i = 0; i < key_string.length(); i = i + 2) { diff --git a/Source/Core/Core/PowerPC/Jit64/Jit_LoadStore.cpp b/Source/Core/Core/PowerPC/Jit64/Jit_LoadStore.cpp index 1d34bf4796..fc6e1f262a 100644 --- a/Source/Core/Core/PowerPC/Jit64/Jit_LoadStore.cpp +++ b/Source/Core/Core/PowerPC/Jit64/Jit_LoadStore.cpp @@ -202,7 +202,7 @@ void Jit64::lXXx(UGeckoInstruction inst) // If we're using reg+reg mode and b is an immediate, pretend we're using constant offset mode bool use_constant_offset = inst.OPCD != 31 || gpr.R(b).IsImm(); - s32 offset; + s32 offset = 0; if (use_constant_offset) offset = inst.OPCD == 31 ? gpr.R(b).SImm32() : (s32)inst.SIMM_16; // Depending on whether we have an immediate and/or update, find the optimum way to calculate diff --git a/Source/Core/DolphinWX/Debugger/MemoryCheckDlg.cpp b/Source/Core/DolphinWX/Debugger/MemoryCheckDlg.cpp index 6d6b1450e7..ac870c8804 100644 --- a/Source/Core/DolphinWX/Debugger/MemoryCheckDlg.cpp +++ b/Source/Core/DolphinWX/Debugger/MemoryCheckDlg.cpp @@ -154,7 +154,7 @@ void MemoryCheckDlg::OnOK(wxCommandEvent& event) bool Log = m_radioLog->GetValue() || m_radioBreakLog->GetValue(); bool Break = m_radioBreak->GetValue() || m_radioBreakLog->GetValue(); - u32 StartAddress, EndAddress; + u32 StartAddress = UINT32_MAX, EndAddress = 0; bool EndAddressOK = EndAddressString.Len() && AsciiToHex(WxStrToStr(EndAddressString), EndAddress); From 90f863a7a301558a3da553f06d4c1d3ff162eac0 Mon Sep 17 00:00:00 2001 From: Shawn Hoffman Date: Wed, 7 Jun 2017 04:18:23 -0700 Subject: [PATCH 07/23] HLE: fix unreachable code warning --- Source/Core/Core/HLE/HLE.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Source/Core/Core/HLE/HLE.cpp b/Source/Core/Core/HLE/HLE.cpp index cc166768da..5fb7fac59c 100644 --- a/Source/Core/Core/HLE/HLE.cpp +++ b/Source/Core/Core/HLE/HLE.cpp @@ -247,8 +247,10 @@ u32 UnPatch(const std::string& patch_name) return addr; } - for (const auto& symbol : g_symbolDB.GetSymbolsFromName(patch_name)) + const auto& symbols = g_symbolDB.GetSymbolsFromName(patch_name); + if (symbols.size()) { + const auto& symbol = symbols[0]; for (u32 addr = symbol->address; addr < symbol->address + symbol->size; addr += 4) { s_original_instructions.erase(addr); From 7e75a052a4877c876f9ab8c48ecbd009d4e6637d Mon Sep 17 00:00:00 2001 From: Shawn Hoffman Date: Wed, 7 Jun 2017 04:19:28 -0700 Subject: [PATCH 08/23] windows/bba: pass c_str() instead of std::string object through a va_list --- Source/Core/Core/HW/EXI/BBA-TAP/TAP_Win32.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Source/Core/Core/HW/EXI/BBA-TAP/TAP_Win32.cpp b/Source/Core/Core/HW/EXI/BBA-TAP/TAP_Win32.cpp index f825f5eef6..58e497a8fb 100644 --- a/Source/Core/Core/HW/EXI/BBA-TAP/TAP_Win32.cpp +++ b/Source/Core/Core/HW/EXI/BBA-TAP/TAP_Win32.cpp @@ -157,7 +157,7 @@ bool OpenTAP(HANDLE& adapter, const std::basic_string& device_guid) if (adapter == INVALID_HANDLE_VALUE) { - INFO_LOG(SP1, "Failed to open TAP at %s", device_path); + INFO_LOG(SP1, "Failed to open TAP at %s", device_path.c_str()); return false; } return true; From 4a1b32afe4e2ab41be63b9d145100e6a0bffc424 Mon Sep 17 00:00:00 2001 From: Shawn Hoffman Date: Wed, 7 Jun 2017 04:20:26 -0700 Subject: [PATCH 09/23] windows: use proper type/constant for NET_IFINDEX in ios hle --- Source/Core/Core/IOS/Network/IP/Top.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/Source/Core/Core/IOS/Network/IP/Top.cpp b/Source/Core/Core/IOS/Network/IP/Top.cpp index cd25283e1a..2b15ae6e46 100644 --- a/Source/Core/Core/IOS/Network/IP/Top.cpp +++ b/Source/Core/Core/IOS/Network/IP/Top.cpp @@ -431,7 +431,7 @@ IPCCommandResult NetIPTop::HandleGetHostIDRequest(const IOCtlRequest& request) #ifdef _WIN32 DWORD forwardTableSize, ipTableSize, result; - DWORD ifIndex = -1; + NET_IFINDEX ifIndex = NET_IFINDEX_UNSPECIFIED; std::unique_ptr forwardTable; std::unique_ptr ipTable; @@ -462,13 +462,14 @@ IPCCommandResult NetIPTop::HandleGetHostIDRequest(const IOCtlRequest& request) } } - if (result == NO_ERROR || ifIndex != -1) + if (result == NO_ERROR || ifIndex != NET_IFINDEX_UNSPECIFIED) break; result = GetIpForwardTable(forwardTable.get(), &forwardTableSize, FALSE); } - if (ifIndex != -1 && GetIpAddrTable(ipTable.get(), &ipTableSize, FALSE) == NO_ERROR) + if (ifIndex != NET_IFINDEX_UNSPECIFIED && + GetIpAddrTable(ipTable.get(), &ipTableSize, FALSE) == NO_ERROR) { for (DWORD i = 0; i < ipTable->dwNumEntries; ++i) { From 8f12d7fb3cdb5138d28ede4bdcd6fa5a7cc9537e Mon Sep 17 00:00:00 2001 From: Shawn Hoffman Date: Wed, 7 Jun 2017 04:22:07 -0700 Subject: [PATCH 10/23] ios/net/ip/top: introduce a helper to write ip addr (quiets warning) --- Source/Core/Core/IOS/Network/IP/Top.cpp | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/Source/Core/Core/IOS/Network/IP/Top.cpp b/Source/Core/Core/IOS/Network/IP/Top.cpp index 2b15ae6e46..b11800e12d 100644 --- a/Source/Core/Core/IOS/Network/IP/Top.cpp +++ b/Source/Core/Core/IOS/Network/IP/Top.cpp @@ -76,6 +76,11 @@ NetIPTop::~NetIPTop() #endif } +static constexpr u32 inet_addr(u8 a, u8 b, u8 c, u8 d) +{ + return (static_cast(a) << 24) | (static_cast(b) << 16) | (static_cast(c) << 8) | d; +} + static int inet_pton(const char* src, unsigned char* dst) { int saw_digit, octets; @@ -818,9 +823,9 @@ IPCCommandResult NetIPTop::HandleGetInterfaceOptRequest(const IOCtlVRequest& req case 0x4003: // ip addr table Memory::Write_U32(0xC, request.io_vectors[1].address); - Memory::Write_U32(10 << 24 | 1 << 8 | 30, request.io_vectors[0].address); - Memory::Write_U32(255 << 24 | 255 << 16 | 255 << 8 | 0, request.io_vectors[0].address + 4); - Memory::Write_U32(10 << 24 | 0 << 16 | 255 << 8 | 255, request.io_vectors[0].address + 8); + Memory::Write_U32(inet_addr(10, 0, 1, 30), request.io_vectors[0].address); + Memory::Write_U32(inet_addr(255, 255, 255, 0), request.io_vectors[0].address + 4); + Memory::Write_U32(inet_addr(10, 0, 255, 255), request.io_vectors[0].address + 8); break; case 0x4005: // hardcoded value From ebd3d43b7d8b338f179378b600083e96e46e09d1 Mon Sep 17 00:00:00 2001 From: Shawn Hoffman Date: Wed, 7 Jun 2017 04:25:30 -0700 Subject: [PATCH 11/23] ios/es: make fd s32 -> quiets warnings --- Source/Core/Core/IOS/ES/ES.cpp | 2 +- Source/Core/Core/IOS/ES/ES.h | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Source/Core/Core/IOS/ES/ES.cpp b/Source/Core/Core/IOS/ES/ES.cpp index 430045705a..6023325681 100644 --- a/Source/Core/Core/IOS/ES/ES.cpp +++ b/Source/Core/Core/IOS/ES/ES.cpp @@ -328,7 +328,7 @@ void ES::DoState(PointerWrap& p) } } -ES::ContextArray::iterator ES::FindActiveContext(u32 fd) +ES::ContextArray::iterator ES::FindActiveContext(s32 fd) { return std::find_if(m_contexts.begin(), m_contexts.end(), [fd](const auto& context) { return context.ipc_fd == fd && context.active; }); diff --git a/Source/Core/Core/IOS/ES/ES.h b/Source/Core/Core/IOS/ES/ES.h index 1deb3919d7..b56ac57b69 100644 --- a/Source/Core/Core/IOS/ES/ES.h +++ b/Source/Core/Core/IOS/ES/ES.h @@ -94,7 +94,7 @@ public: TitleExportContext title_export; bool active = false; // We use this to associate an IPC fd with an ES context. - u32 ipc_fd = -1; + s32 ipc_fd = -1; }; // Title management @@ -277,7 +277,7 @@ private: IPCCommandResult DIGetTMDSize(const IOCtlVRequest& request); IPCCommandResult DIGetTMD(const IOCtlVRequest& request); - ContextArray::iterator FindActiveContext(u32 fd); + ContextArray::iterator FindActiveContext(s32 fd); ContextArray::iterator FindInactiveContext(); bool LaunchIOS(u64 ios_title_id); From 5b5c630afb14178e17385229ea4675f155a4ec7c Mon Sep 17 00:00:00 2001 From: Shawn Hoffman Date: Wed, 7 Jun 2017 04:26:36 -0700 Subject: [PATCH 12/23] set underlying type of some enums to quiet warnings --- Source/Core/Core/HW/DSPHLE/UCodes/UCodes.h | 2 +- Source/Core/Core/HW/Memmap.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Source/Core/Core/HW/DSPHLE/UCodes/UCodes.h b/Source/Core/Core/HW/DSPHLE/UCodes/UCodes.h index 6cc8b45242..07dc0f3e1d 100644 --- a/Source/Core/Core/HW/DSPHLE/UCodes/UCodes.h +++ b/Source/Core/Core/HW/DSPHLE/UCodes/UCodes.h @@ -63,7 +63,7 @@ protected: CMailHandler& m_mail_handler; - enum EDSP_Codes + enum EDSP_Codes : u32 { DSP_INIT = 0xDCD10000, DSP_RESUME = 0xDCD10001, diff --git a/Source/Core/Core/HW/Memmap.cpp b/Source/Core/Core/HW/Memmap.cpp index 9be01f9612..ac69e4cd6c 100644 --- a/Source/Core/Core/HW/Memmap.cpp +++ b/Source/Core/Core/HW/Memmap.cpp @@ -99,7 +99,7 @@ struct PhysicalMemoryRegion u8** out_pointer; u32 physical_address; u32 size; - enum + enum : u32 { ALWAYS = 0, FAKE_VMEM = 1, From 983f70c9eaae4eb4028339624bbb0c9a52a1f8d3 Mon Sep 17 00:00:00 2001 From: Shawn Hoffman Date: Wed, 7 Jun 2017 04:27:32 -0700 Subject: [PATCH 13/23] ios: treat return values as s32 --- Source/Core/Core/IOS/IOS.h | 7 +++ Source/Core/Core/IOS/Network/KD/NWC24Config.h | 2 +- .../Core/Core/IOS/Network/KD/NetKDRequest.cpp | 16 +++---- Source/Core/Core/IOS/Network/SSL.cpp | 48 +++++++++---------- Source/Core/Core/IOS/Network/SSL.h | 2 +- Source/Core/Core/IOS/Network/Socket.cpp | 28 +++++------ Source/Core/Core/IOS/SDIO/SDIOSlot0.cpp | 4 +- Source/Core/Core/IOS/SDIO/SDIOSlot0.h | 2 +- Source/Core/Core/IOS/WFS/WFSI.cpp | 2 +- 9 files changed, 59 insertions(+), 52 deletions(-) diff --git a/Source/Core/Core/IOS/IOS.h b/Source/Core/Core/IOS/IOS.h index 32bcdc1694..6c49a70ec4 100644 --- a/Source/Core/Core/IOS/IOS.h +++ b/Source/Core/Core/IOS/IOS.h @@ -14,6 +14,7 @@ #include "Common/CommonTypes.h" #include "Core/CoreTiming.h" +#include "Core/HW/Memmap.h" #include "Core/HW/SystemTimers.h" #include "Core/IOS/IOSC.h" @@ -82,6 +83,12 @@ enum ProcessId : u32 PID_UNKNOWN = 19, }; +template +void WriteReturnValue(T value, u32 address) +{ + Memory::Write_U32(static_cast(value), address); +} + // HLE for the IOS kernel: IPC, device management, syscalls, and Dolphin-specific, IOS-wide calls. class Kernel { diff --git a/Source/Core/Core/IOS/Network/KD/NWC24Config.h b/Source/Core/Core/IOS/Network/KD/NWC24Config.h index 8aa07fc979..f25fb7b5fb 100644 --- a/Source/Core/Core/IOS/Network/KD/NWC24Config.h +++ b/Source/Core/Core/IOS/Network/KD/NWC24Config.h @@ -13,7 +13,7 @@ namespace HLE { namespace NWC24 { -enum ErrorCode : int +enum ErrorCode : s32 { WC24_OK = 0, WC24_ERR_FATAL = -1, diff --git a/Source/Core/Core/IOS/Network/KD/NetKDRequest.cpp b/Source/Core/Core/IOS/Network/KD/NetKDRequest.cpp index 48c9e27da0..cbcf245fe9 100644 --- a/Source/Core/Core/IOS/Network/KD/NetKDRequest.cpp +++ b/Source/Core/Core/IOS/Network/KD/NetKDRequest.cpp @@ -41,7 +41,7 @@ IPCCommandResult NetKDRequest::IOCtl(const IOCtlRequest& request) case IOCTL_NWC24_SUSPEND_SCHEDULAR: // NWC24iResumeForCloseLib from NWC24SuspendScheduler (Input: none, Output: 32 bytes) INFO_LOG(IOS_WC24, "NET_KD_REQ: IOCTL_NWC24_SUSPEND_SCHEDULAR - NI"); - Memory::Write_U32(0, request.buffer_out); // no error + WriteReturnValue(0, request.buffer_out); // no error break; case IOCTL_NWC24_EXEC_TRY_SUSPEND_SCHEDULAR: // NWC24iResumeForCloseLib @@ -50,11 +50,11 @@ IPCCommandResult NetKDRequest::IOCtl(const IOCtlRequest& request) case IOCTL_NWC24_EXEC_RESUME_SCHEDULAR: // NWC24iResumeForCloseLib INFO_LOG(IOS_WC24, "NET_KD_REQ: IOCTL_NWC24_EXEC_RESUME_SCHEDULAR - NI"); - Memory::Write_U32(0, request.buffer_out); // no error + WriteReturnValue(0, request.buffer_out); // no error break; case IOCTL_NWC24_STARTUP_SOCKET: // NWC24iStartupSocket - Memory::Write_U32(0, request.buffer_out); + WriteReturnValue(0, request.buffer_out); Memory::Write_U32(0, request.buffer_out + 4); return_value = 0; INFO_LOG(IOS_WC24, "NET_KD_REQ: IOCTL_NWC24_STARTUP_SOCKET - NI"); @@ -74,7 +74,7 @@ IPCCommandResult NetKDRequest::IOCtl(const IOCtlRequest& request) case IOCTL_NWC24_REQUEST_REGISTER_USER_ID: INFO_LOG(IOS_WC24, "NET_KD_REQ: IOCTL_NWC24_REQUEST_REGISTER_USER_ID"); - Memory::Write_U32(0, request.buffer_out); + WriteReturnValue(0, request.buffer_out); Memory::Write_U32(0, request.buffer_out + 4); break; @@ -110,20 +110,20 @@ IPCCommandResult NetKDRequest::IOCtl(const IOCtlRequest& request) config.SetCreationStage(NWC24::NWC24Config::NWC24_IDCS_GENERATED); config.WriteConfig(); - Memory::Write_U32(ret, request.buffer_out); + WriteReturnValue(ret, request.buffer_out); } else { - Memory::Write_U32(NWC24::WC24_ERR_FATAL, request.buffer_out); + WriteReturnValue(NWC24::WC24_ERR_FATAL, request.buffer_out); } } else if (config.CreationStage() == NWC24::NWC24Config::NWC24_IDCS_GENERATED) { - Memory::Write_U32(NWC24::WC24_ERR_ID_GENERATED, request.buffer_out); + WriteReturnValue(NWC24::WC24_ERR_ID_GENERATED, request.buffer_out); } else if (config.CreationStage() == NWC24::NWC24Config::NWC24_IDCS_REGISTERED) { - Memory::Write_U32(NWC24::WC24_ERR_ID_REGISTERED, request.buffer_out); + WriteReturnValue(NWC24::WC24_ERR_ID_REGISTERED, request.buffer_out); } Memory::Write_U64(config.Id(), request.buffer_out + 4); Memory::Write_U32(config.CreationStage(), request.buffer_out + 0xC); diff --git a/Source/Core/Core/IOS/Network/SSL.cpp b/Source/Core/Core/IOS/Network/SSL.cpp index ef826a7a58..925ab34f56 100644 --- a/Source/Core/Core/IOS/Network/SSL.cpp +++ b/Source/Core/Core/IOS/Network/SSL.cpp @@ -221,12 +221,12 @@ IPCCommandResult NetSSL::IOCtlV(const IOCtlVRequest& request) mbedtls_ssl_set_hostname(&ssl->ctx, ssl->hostname.c_str()); ssl->active = true; - Memory::Write_U32(freeSSL, BufferIn); + WriteReturnValue(freeSSL, BufferIn); } else { _SSL_NEW_ERROR: - Memory::Write_U32(SSL_ERR_FAILED, BufferIn); + WriteReturnValue(SSL_ERR_FAILED, BufferIn); } INFO_LOG(IOS_SSL, "IOCTLV_NET_SSL_NEW (%d, %s) " @@ -260,11 +260,11 @@ IPCCommandResult NetSSL::IOCtlV(const IOCtlVRequest& request) ssl->active = false; - Memory::Write_U32(SSL_OK, BufferIn); + WriteReturnValue(SSL_OK, BufferIn); } else { - Memory::Write_U32(SSL_ERR_ID, BufferIn); + WriteReturnValue(SSL_ERR_ID, BufferIn); } INFO_LOG(IOS_SSL, "IOCTLV_NET_SSL_SHUTDOWN " "BufferIn: (%08x, %i), BufferIn2: (%08x, %i), " @@ -298,19 +298,19 @@ IPCCommandResult NetSSL::IOCtlV(const IOCtlVRequest& request) if (ret) { - Memory::Write_U32(SSL_ERR_FAILED, BufferIn); + WriteReturnValue(SSL_ERR_FAILED, BufferIn); } else { mbedtls_ssl_conf_ca_chain(&ssl->config, &ssl->cacert, nullptr); - Memory::Write_U32(SSL_OK, BufferIn); + WriteReturnValue(SSL_OK, BufferIn); } INFO_LOG(IOS_SSL, "IOCTLV_NET_SSL_SETROOTCA = %d", ret); } else { - Memory::Write_U32(SSL_ERR_ID, BufferIn); + WriteReturnValue(SSL_ERR_ID, BufferIn); } break; } @@ -339,19 +339,19 @@ IPCCommandResult NetSSL::IOCtlV(const IOCtlVRequest& request) { mbedtls_x509_crt_free(&ssl->clicert); mbedtls_pk_free(&ssl->pk); - Memory::Write_U32(SSL_ERR_FAILED, BufferIn); + WriteReturnValue(SSL_ERR_FAILED, BufferIn); } else { mbedtls_ssl_conf_own_cert(&ssl->config, &ssl->clicert, &ssl->pk); - Memory::Write_U32(SSL_OK, BufferIn); + WriteReturnValue(SSL_OK, BufferIn); } INFO_LOG(IOS_SSL, "IOCTLV_NET_SSL_SETBUILTINCLIENTCERT = (%d, %d)", ret, pk_ret); } else { - Memory::Write_U32(SSL_ERR_ID, BufferIn); + WriteReturnValue(SSL_ERR_ID, BufferIn); INFO_LOG(IOS_SSL, "IOCTLV_NET_SSL_SETBUILTINCLIENTCERT invalid sslID = %d", sslID); } break; @@ -373,11 +373,11 @@ IPCCommandResult NetSSL::IOCtlV(const IOCtlVRequest& request) mbedtls_pk_free(&ssl->pk); mbedtls_ssl_conf_own_cert(&ssl->config, nullptr, nullptr); - Memory::Write_U32(SSL_OK, BufferIn); + WriteReturnValue(SSL_OK, BufferIn); } else { - Memory::Write_U32(SSL_ERR_ID, BufferIn); + WriteReturnValue(SSL_ERR_ID, BufferIn); INFO_LOG(IOS_SSL, "IOCTLV_NET_SSL_SETBUILTINCLIENTCERT invalid sslID = %d", sslID); } break; @@ -395,18 +395,18 @@ IPCCommandResult NetSSL::IOCtlV(const IOCtlVRequest& request) if (ret) { mbedtls_x509_crt_free(&ssl->clicert); - Memory::Write_U32(SSL_ERR_FAILED, BufferIn); + WriteReturnValue(SSL_ERR_FAILED, BufferIn); } else { mbedtls_ssl_conf_ca_chain(&ssl->config, &ssl->cacert, nullptr); - Memory::Write_U32(SSL_OK, BufferIn); + WriteReturnValue(SSL_OK, BufferIn); } INFO_LOG(IOS_SSL, "IOCTLV_NET_SSL_SETBUILTINROOTCA = %d", ret); } else { - Memory::Write_U32(SSL_ERR_ID, BufferIn); + WriteReturnValue(SSL_ERR_ID, BufferIn); } INFO_LOG(IOS_SSL, "IOCTLV_NET_SSL_SETBUILTINROOTCA " "BufferIn: (%08x, %i), BufferIn2: (%08x, %i), " @@ -428,11 +428,11 @@ IPCCommandResult NetSSL::IOCtlV(const IOCtlVRequest& request) ssl->hostfd = sm.GetHostSocket(ssl->sockfd); INFO_LOG(IOS_SSL, "IOCTLV_NET_SSL_CONNECT socket = %d", ssl->sockfd); mbedtls_ssl_set_bio(&ssl->ctx, &ssl->hostfd, mbedtls_net_send, mbedtls_net_recv, nullptr); - Memory::Write_U32(SSL_OK, BufferIn); + WriteReturnValue(SSL_OK, BufferIn); } else { - Memory::Write_U32(SSL_ERR_ID, BufferIn); + WriteReturnValue(SSL_ERR_ID, BufferIn); } INFO_LOG(IOS_SSL, "IOCTLV_NET_SSL_CONNECT " "BufferIn: (%08x, %i), BufferIn2: (%08x, %i), " @@ -453,7 +453,7 @@ IPCCommandResult NetSSL::IOCtlV(const IOCtlVRequest& request) } else { - Memory::Write_U32(SSL_ERR_ID, BufferIn); + WriteReturnValue(SSL_ERR_ID, BufferIn); } break; } @@ -468,7 +468,7 @@ IPCCommandResult NetSSL::IOCtlV(const IOCtlVRequest& request) } else { - Memory::Write_U32(SSL_ERR_ID, BufferIn); + WriteReturnValue(SSL_ERR_ID, BufferIn); } INFO_LOG(IOS_SSL, "IOCTLV_NET_SSL_WRITE " "BufferIn: (%08x, %i), BufferIn2: (%08x, %i), " @@ -491,7 +491,7 @@ IPCCommandResult NetSSL::IOCtlV(const IOCtlVRequest& request) } else { - Memory::Write_U32(SSL_ERR_ID, BufferIn); + WriteReturnValue(SSL_ERR_ID, BufferIn); } INFO_LOG(IOS_SSL, "IOCTLV_NET_SSL_READ(%d)" @@ -507,11 +507,11 @@ IPCCommandResult NetSSL::IOCtlV(const IOCtlVRequest& request) int sslID = Memory::Read_U32(BufferOut) - 1; if (SSLID_VALID(sslID)) { - Memory::Write_U32(SSL_OK, BufferIn); + WriteReturnValue(SSL_OK, BufferIn); } else { - Memory::Write_U32(SSL_ERR_ID, BufferIn); + WriteReturnValue(SSL_ERR_ID, BufferIn); } INFO_LOG(IOS_SSL, "IOCTLV_NET_SSL_SETROOTCADEFAULT " "BufferIn: (%08x, %i), BufferIn2: (%08x, %i), " @@ -533,11 +533,11 @@ IPCCommandResult NetSSL::IOCtlV(const IOCtlVRequest& request) int sslID = Memory::Read_U32(BufferOut) - 1; if (SSLID_VALID(sslID)) { - Memory::Write_U32(SSL_OK, BufferIn); + WriteReturnValue(SSL_OK, BufferIn); } else { - Memory::Write_U32(SSL_ERR_ID, BufferIn); + WriteReturnValue(SSL_ERR_ID, BufferIn); } break; } diff --git a/Source/Core/Core/IOS/Network/SSL.h b/Source/Core/Core/IOS/Network/SSL.h index c1253e8189..a8a8d55bd2 100644 --- a/Source/Core/Core/IOS/Network/SSL.h +++ b/Source/Core/Core/IOS/Network/SSL.h @@ -32,7 +32,7 @@ namespace HLE #define SSLID_VALID(x) \ (x >= 0 && x < NET_SSL_MAXINSTANCES && ::IOS::HLE::Device::NetSSL::_SSL[x].active) -enum ssl_err_t +enum ssl_err_t : s32 { SSL_OK = 0, SSL_ERR_FAILED = -1, diff --git a/Source/Core/Core/IOS/Network/Socket.cpp b/Source/Core/Core/IOS/Network/Socket.cpp index b5968568a1..ce79f8dfcb 100644 --- a/Source/Core/Core/IOS/Network/Socket.cpp +++ b/Source/Core/Core/IOS/Network/Socket.cpp @@ -335,15 +335,15 @@ void WiiSocket::Update(bool read, bool write, bool except) switch (ret) { case 0: - Memory::Write_U32(SSL_OK, BufferIn); + WriteReturnValue(SSL_OK, BufferIn); break; case MBEDTLS_ERR_SSL_WANT_READ: - Memory::Write_U32(SSL_ERR_RAGAIN, BufferIn); + WriteReturnValue(SSL_ERR_RAGAIN, BufferIn); if (!nonBlock) ReturnValue = SSL_ERR_RAGAIN; break; case MBEDTLS_ERR_SSL_WANT_WRITE: - Memory::Write_U32(SSL_ERR_WAGAIN, BufferIn); + WriteReturnValue(SSL_ERR_WAGAIN, BufferIn); if (!nonBlock) ReturnValue = SSL_ERR_WAGAIN; break; @@ -366,13 +366,13 @@ void WiiSocket::Update(bool read, bool write, bool except) else res = SSL_ERR_FAILED; - Memory::Write_U32(res, BufferIn); + WriteReturnValue(res, BufferIn); if (!nonBlock) ReturnValue = res; break; } default: - Memory::Write_U32(SSL_ERR_FAILED, BufferIn); + WriteReturnValue(SSL_ERR_FAILED, BufferIn); break; } @@ -412,24 +412,24 @@ void WiiSocket::Update(bool read, bool write, bool except) if (ret >= 0) { // Return bytes written or SSL_ERR_ZERO if none - Memory::Write_U32((ret == 0) ? SSL_ERR_ZERO : ret, BufferIn); + WriteReturnValue((ret == 0) ? SSL_ERR_ZERO : ret, BufferIn); } else { switch (ret) { case MBEDTLS_ERR_SSL_WANT_READ: - Memory::Write_U32(SSL_ERR_RAGAIN, BufferIn); + WriteReturnValue(SSL_ERR_RAGAIN, BufferIn); if (!nonBlock) ReturnValue = SSL_ERR_RAGAIN; break; case MBEDTLS_ERR_SSL_WANT_WRITE: - Memory::Write_U32(SSL_ERR_WAGAIN, BufferIn); + WriteReturnValue(SSL_ERR_WAGAIN, BufferIn); if (!nonBlock) ReturnValue = SSL_ERR_WAGAIN; break; default: - Memory::Write_U32(SSL_ERR_FAILED, BufferIn); + WriteReturnValue(SSL_ERR_FAILED, BufferIn); break; } } @@ -450,24 +450,24 @@ void WiiSocket::Update(bool read, bool write, bool except) if (ret >= 0) { // Return bytes read or SSL_ERR_ZERO if none - Memory::Write_U32((ret == 0) ? SSL_ERR_ZERO : ret, BufferIn); + WriteReturnValue((ret == 0) ? SSL_ERR_ZERO : ret, BufferIn); } else { switch (ret) { case MBEDTLS_ERR_SSL_WANT_READ: - Memory::Write_U32(SSL_ERR_RAGAIN, BufferIn); + WriteReturnValue(SSL_ERR_RAGAIN, BufferIn); if (!nonBlock) ReturnValue = SSL_ERR_RAGAIN; break; case MBEDTLS_ERR_SSL_WANT_WRITE: - Memory::Write_U32(SSL_ERR_WAGAIN, BufferIn); + WriteReturnValue(SSL_ERR_WAGAIN, BufferIn); if (!nonBlock) ReturnValue = SSL_ERR_WAGAIN; break; default: - Memory::Write_U32(SSL_ERR_FAILED, BufferIn); + WriteReturnValue(SSL_ERR_FAILED, BufferIn); break; } } @@ -479,7 +479,7 @@ void WiiSocket::Update(bool read, bool write, bool except) } else { - Memory::Write_U32(SSL_ERR_ID, BufferIn); + WriteReturnValue(SSL_ERR_ID, BufferIn); } } else diff --git a/Source/Core/Core/IOS/SDIO/SDIOSlot0.cpp b/Source/Core/Core/IOS/SDIO/SDIOSlot0.cpp index 3884baefdb..14a739e601 100644 --- a/Source/Core/Core/IOS/SDIO/SDIOSlot0.cpp +++ b/Source/Core/Core/IOS/SDIO/SDIOSlot0.cpp @@ -134,7 +134,7 @@ IPCCommandResult SDIOSlot0::IOCtlV(const IOCtlVRequest& request) return GetDefaultReply(IPC_SUCCESS); } -u32 SDIOSlot0::ExecuteCommand(const Request& request, u32 _BufferIn, u32 _BufferInSize, +s32 SDIOSlot0::ExecuteCommand(const Request& request, u32 _BufferIn, u32 _BufferInSize, u32 _rwBuffer, u32 _rwBufferSize, u32 _BufferOut, u32 _BufferOutSize) { // The game will send us a SendCMD with this information. To be able to read and write @@ -164,7 +164,7 @@ u32 SDIOSlot0::ExecuteCommand(const Request& request, u32 _BufferIn, u32 _Buffer // Note: req.addr is the virtual address of _rwBuffer - u32 ret = RET_OK; + s32 ret = RET_OK; switch (req.command) { diff --git a/Source/Core/Core/IOS/SDIO/SDIOSlot0.h b/Source/Core/Core/IOS/SDIO/SDIOSlot0.h index 55bfabf8da..5e69389b30 100644 --- a/Source/Core/Core/IOS/SDIO/SDIOSlot0.h +++ b/Source/Core/Core/IOS/SDIO/SDIOSlot0.h @@ -128,7 +128,7 @@ private: IPCCommandResult SendCommand(const IOCtlVRequest& request); - u32 ExecuteCommand(const Request& request, u32 BufferIn, u32 BufferInSize, u32 BufferIn2, + s32 ExecuteCommand(const Request& request, u32 BufferIn, u32 BufferInSize, u32 BufferIn2, u32 BufferInSize2, u32 _BufferOut, u32 BufferOutSize); void OpenInternal(); diff --git a/Source/Core/Core/IOS/WFS/WFSI.cpp b/Source/Core/Core/IOS/WFS/WFSI.cpp index a5464151b6..34e4d4e8b7 100644 --- a/Source/Core/Core/IOS/WFS/WFSI.cpp +++ b/Source/Core/Core/IOS/WFS/WFSI.cpp @@ -86,7 +86,7 @@ WFSI::WFSI(Kernel& ios, const std::string& device_name) : Device(ios, device_nam IPCCommandResult WFSI::IOCtl(const IOCtlRequest& request) { - u32 return_error_code = IPC_SUCCESS; + s32 return_error_code = IPC_SUCCESS; switch (request.request) { From ead4f19654d23b77c56b7d072bc4437db65df4a0 Mon Sep 17 00:00:00 2001 From: Shawn Hoffman Date: Wed, 7 Jun 2017 04:28:48 -0700 Subject: [PATCH 14/23] ios/usbv4: initialize TransferCommand::data_address to 0 --- Source/Core/Core/IOS/USB/USBV4.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Source/Core/Core/IOS/USB/USBV4.cpp b/Source/Core/Core/IOS/USB/USBV4.cpp index c2b9825cd6..3d963c9598 100644 --- a/Source/Core/Core/IOS/USB/USBV4.cpp +++ b/Source/Core/Core/IOS/USB/USBV4.cpp @@ -49,7 +49,7 @@ struct HIDRequest }; #pragma pack(pop) -V4CtrlMessage::V4CtrlMessage(Kernel& ios, const IOCtlRequest& ioctl) : CtrlMessage(ios, ioctl, -1) +V4CtrlMessage::V4CtrlMessage(Kernel& ios, const IOCtlRequest& ioctl) : CtrlMessage(ios, ioctl, 0) { HIDRequest hid_request; Memory::CopyFromEmu(&hid_request, ioctl.buffer_in, sizeof(hid_request)); @@ -65,7 +65,7 @@ V4CtrlMessage::V4CtrlMessage(Kernel& ios, const IOCtlRequest& ioctl) : CtrlMessa // (US for the language and replacing non-ASCII characters with '?'), // we can simply submit it as a usual control request. V4GetUSStringMessage::V4GetUSStringMessage(Kernel& ios, const IOCtlRequest& ioctl) - : CtrlMessage(ios, ioctl, -1) + : CtrlMessage(ios, ioctl, 0) { HIDRequest hid_request; Memory::CopyFromEmu(&hid_request, ioctl.buffer_in, sizeof(hid_request)); @@ -87,7 +87,7 @@ void V4GetUSStringMessage::OnTransferComplete(s32 return_value) const TransferCommand::OnTransferComplete(return_value); } -V4IntrMessage::V4IntrMessage(Kernel& ios, const IOCtlRequest& ioctl) : IntrMessage(ios, ioctl, -1) +V4IntrMessage::V4IntrMessage(Kernel& ios, const IOCtlRequest& ioctl) : IntrMessage(ios, ioctl, 0) { HIDRequest hid_request; Memory::CopyFromEmu(&hid_request, ioctl.buffer_in, sizeof(hid_request)); From ab4a785f1b9f5d52071c0ba2414f7fa3c64c72ab Mon Sep 17 00:00:00 2001 From: Shawn Hoffman Date: Wed, 7 Jun 2017 04:30:57 -0700 Subject: [PATCH 15/23] d3d: silence variable shadowing warning --- Source/Core/VideoBackends/D3D/D3DBase.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Source/Core/VideoBackends/D3D/D3DBase.cpp b/Source/Core/VideoBackends/D3D/D3DBase.cpp index 8000f15a31..b1ba228b96 100644 --- a/Source/Core/VideoBackends/D3D/D3DBase.cpp +++ b/Source/Core/VideoBackends/D3D/D3DBase.cpp @@ -240,12 +240,12 @@ D3D_FEATURE_LEVEL GetFeatureLevel(IDXGIAdapter* adapter) return feat_level; } -static bool SupportsS3TCTextures(ID3D11Device* device) +static bool SupportsS3TCTextures(ID3D11Device* dev) { UINT bc1_support, bc2_support, bc3_support; - if (FAILED(device->CheckFormatSupport(DXGI_FORMAT_BC1_UNORM, &bc1_support)) || - FAILED(device->CheckFormatSupport(DXGI_FORMAT_BC2_UNORM, &bc2_support)) || - FAILED(device->CheckFormatSupport(DXGI_FORMAT_BC3_UNORM, &bc3_support))) + if (FAILED(dev->CheckFormatSupport(DXGI_FORMAT_BC1_UNORM, &bc1_support)) || + FAILED(dev->CheckFormatSupport(DXGI_FORMAT_BC2_UNORM, &bc2_support)) || + FAILED(dev->CheckFormatSupport(DXGI_FORMAT_BC3_UNORM, &bc3_support))) { return false; } From e6c15e993bb351ea5414506440174a93e4fa0703 Mon Sep 17 00:00:00 2001 From: Shawn Hoffman Date: Wed, 7 Jun 2017 04:33:15 -0700 Subject: [PATCH 16/23] quiet some sign-conversion-in-parameter warnings --- Source/Core/Core/NetPlayServer.cpp | 2 +- Source/Core/VideoCommon/Fifo.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Source/Core/Core/NetPlayServer.cpp b/Source/Core/Core/NetPlayServer.cpp index 3b0112772a..1e86cf0e2d 100644 --- a/Source/Core/Core/NetPlayServer.cpp +++ b/Source/Core/Core/NetPlayServer.cpp @@ -367,7 +367,7 @@ unsigned int NetPlayServer::OnDisconnect(const Client& player) sf::Packet spac; spac << (MessageId)NP_MSG_DISABLE_GAME; // this thread doesn't need players lock - SendToClients(spac, -1); + SendToClients(spac, static_cast(-1)); break; } } diff --git a/Source/Core/VideoCommon/Fifo.cpp b/Source/Core/VideoCommon/Fifo.cpp index 377d7d5010..cedbea5432 100644 --- a/Source/Core/VideoCommon/Fifo.cpp +++ b/Source/Core/VideoCommon/Fifo.cpp @@ -353,7 +353,7 @@ void RunGpuLoop() DataReader(s_video_buffer_read_ptr, write_ptr), &cyclesExecuted, false); Common::AtomicStore(fifo.CPReadPointer, readPtr); - Common::AtomicAdd(fifo.CPReadWriteDistance, -32); + Common::AtomicAdd(fifo.CPReadWriteDistance, static_cast(-32)); if ((write_ptr - s_video_buffer_read_ptr) == 0) Common::AtomicStore(fifo.SafeCPReadPointer, fifo.CPReadPointer); From a97d07913891c29db135994dbd52488d3ccc37aa Mon Sep 17 00:00:00 2001 From: Shawn Hoffman Date: Wed, 7 Jun 2017 04:33:41 -0700 Subject: [PATCH 17/23] jit64: quiet variable init warnings --- Source/Core/Core/PowerPC/Jit64/JitRegCache.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Source/Core/Core/PowerPC/Jit64/JitRegCache.cpp b/Source/Core/Core/PowerPC/Jit64/JitRegCache.cpp index 601bf42248..e9db74a0ad 100644 --- a/Source/Core/Core/PowerPC/Jit64/JitRegCache.cpp +++ b/Source/Core/Core/PowerPC/Jit64/JitRegCache.cpp @@ -30,7 +30,7 @@ void RegCache::Start() xreg.free = true; xreg.dirty = false; xreg.locked = false; - xreg.ppcReg = INVALID_REG; + xreg.ppcReg = static_cast(INVALID_REG); } for (size_t i = 0; i < m_regs.size(); i++) { @@ -63,7 +63,7 @@ void RegCache::DiscardRegContentsIfCached(size_t preg) X64Reg xr = m_regs[preg].location.GetSimpleReg(); m_xregs[xr].free = true; m_xregs[xr].dirty = false; - m_xregs[xr].ppcReg = INVALID_REG; + m_xregs[xr].ppcReg = static_cast(INVALID_REG); m_regs[preg].away = false; m_regs[preg].location = GetDefaultLocation(preg); } @@ -216,7 +216,7 @@ void RegCache::StoreFromRegister(size_t i, FlushMode mode) if (mode == FlushMode::All) { m_xregs[xr].free = true; - m_xregs[xr].ppcReg = INVALID_REG; + m_xregs[xr].ppcReg = static_cast(INVALID_REG); m_xregs[xr].dirty = false; } } From ef9090d7da50d6ef7ac90d365d1c5e2549ce30ce Mon Sep 17 00:00:00 2001 From: Shawn Hoffman Date: Wed, 7 Jun 2017 04:34:34 -0700 Subject: [PATCH 18/23] powerpc: silence an int->u32 init warning --- Source/Core/Core/PowerPC/PowerPC.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Source/Core/Core/PowerPC/PowerPC.h b/Source/Core/Core/PowerPC/PowerPC.h index 1ca6e6aa61..9e53c239b9 100644 --- a/Source/Core/Core/PowerPC/PowerPC.h +++ b/Source/Core/Core/PowerPC/PowerPC.h @@ -296,7 +296,7 @@ constexpr int BAT_INDEX_SHIFT = 17; constexpr u32 BAT_PAGE_SIZE = 1 << BAT_INDEX_SHIFT; constexpr u32 BAT_MAPPED_BIT = 0x1; constexpr u32 BAT_PHYSICAL_BIT = 0x2; -constexpr u32 BAT_RESULT_MASK = ~0x3; +constexpr u32 BAT_RESULT_MASK = UINT32_C(~0x3); using BatTable = std::array; // 128 KB extern BatTable ibat_table; extern BatTable dbat_table; From 50f34f8b05ea64c42f465d6bd384208e886ba88f Mon Sep 17 00:00:00 2001 From: Shawn Hoffman Date: Wed, 7 Jun 2017 04:35:07 -0700 Subject: [PATCH 19/23] jit64: silence signedness comparison warnings --- Source/Core/Core/PowerPC/Jit64/Jit.h | 2 +- Source/Core/Core/PowerPC/Jit64/Jit_FloatingPoint.cpp | 2 +- Source/Core/Core/PowerPC/Jit64/Jit_Integer.cpp | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/Source/Core/Core/PowerPC/Jit64/Jit.h b/Source/Core/Core/PowerPC/Jit64/Jit.h index 4fe96f5bfc..97ca0af716 100644 --- a/Source/Core/Core/PowerPC/Jit64/Jit.h +++ b/Source/Core/Core/PowerPC/Jit64/Jit.h @@ -87,7 +87,7 @@ public: // Use to extract bytes from a register using the regcache. offset is in bytes. Gen::OpArg ExtractFromReg(int reg, int offset); void AndWithMask(Gen::X64Reg reg, u32 mask); - bool CheckMergedBranch(int crf); + bool CheckMergedBranch(u32 crf); void DoMergedBranch(); void DoMergedBranchCondition(); void DoMergedBranchImmediate(s64 val); diff --git a/Source/Core/Core/PowerPC/Jit64/Jit_FloatingPoint.cpp b/Source/Core/Core/PowerPC/Jit64/Jit_FloatingPoint.cpp index 63ac8ff7d5..12da80f64a 100644 --- a/Source/Core/Core/PowerPC/Jit64/Jit_FloatingPoint.cpp +++ b/Source/Core/Core/PowerPC/Jit64/Jit_FloatingPoint.cpp @@ -486,7 +486,7 @@ void Jit64::FloatCompare(UGeckoInstruction inst, bool upper) // bool ordered = !!(inst.SUBOP10 & 32); int a = inst.FA; int b = inst.FB; - int crf = inst.CRFD; + u32 crf = inst.CRFD; int output[4] = {CR_SO, CR_EQ, CR_GT, CR_LT}; // Merge neighboring fcmp and cror (the primary use of cror). diff --git a/Source/Core/Core/PowerPC/Jit64/Jit_Integer.cpp b/Source/Core/Core/PowerPC/Jit64/Jit_Integer.cpp index 5f25fd5d22..2ff5e1bffe 100644 --- a/Source/Core/Core/PowerPC/Jit64/Jit_Integer.cpp +++ b/Source/Core/Core/PowerPC/Jit64/Jit_Integer.cpp @@ -339,7 +339,7 @@ void Jit64::reg_imm(UGeckoInstruction inst) } } -bool Jit64::CheckMergedBranch(int crf) +bool Jit64::CheckMergedBranch(u32 crf) { if (!analyzer.HasOption(PPCAnalyst::PPCAnalyzer::OPTION_BRANCH_MERGE)) return false; @@ -473,7 +473,7 @@ void Jit64::cmpXX(UGeckoInstruction inst) JITDISABLE(bJITIntegerOff); int a = inst.RA; int b = inst.RB; - int crf = inst.CRFD; + u32 crf = inst.CRFD; bool merge_branch = CheckMergedBranch(crf); OpArg comparand; From 9357cee2ef96fbe345a82ac2f6af7c715d1e6027 Mon Sep 17 00:00:00 2001 From: Shawn Hoffman Date: Wed, 7 Jun 2017 04:42:41 -0700 Subject: [PATCH 20/23] do not assign in conditional statements --- Source/Core/Common/FileUtil.cpp | 4 ++-- Source/Core/Common/GL/GLInterface/WGL.cpp | 7 ++++--- Source/Core/Core/ARDecrypt.cpp | 3 ++- .../Debugger/CodeWindowFunctions.cpp | 7 ++++--- Source/Core/InputCommon/GCAdapter.cpp | 19 +++++++++---------- Source/Core/VideoCommon/AVIDump.cpp | 16 +++++++++------- 6 files changed, 30 insertions(+), 26 deletions(-) diff --git a/Source/Core/Common/FileUtil.cpp b/Source/Core/Common/FileUtil.cpp index 2ae063673f..203ddbac4b 100644 --- a/Source/Core/Common/FileUtil.cpp +++ b/Source/Core/Common/FileUtil.cpp @@ -631,9 +631,9 @@ void CopyDir(const std::string& source_path, const std::string& dest_path) // Returns the current directory std::string GetCurrentDir() { - char* dir; // Get the current working directory (getcwd uses malloc) - if (!(dir = __getcwd(nullptr, 0))) + char* dir = __getcwd(nullptr, 0); + if (!dir) { ERROR_LOG(COMMON, "GetCurrentDirectory failed: %s", GetLastErrorMsg().c_str()); return nullptr; diff --git a/Source/Core/Common/GL/GLInterface/WGL.cpp b/Source/Core/Common/GL/GLInterface/WGL.cpp index 57c46cb42b..3e500f5866 100644 --- a/Source/Core/Common/GL/GLInterface/WGL.cpp +++ b/Source/Core/Common/GL/GLInterface/WGL.cpp @@ -248,8 +248,8 @@ bool cInterfaceWGL::Create(void* window_handle, bool core) return false; } - int pixel_format; - if (!(pixel_format = ChoosePixelFormat(m_dc, &pfd))) + int pixel_format = ChoosePixelFormat(m_dc, &pfd); + if (!pixel_format) { PanicAlert("(2) Can't find a suitable PixelFormat."); return false; @@ -261,7 +261,8 @@ bool cInterfaceWGL::Create(void* window_handle, bool core) return false; } - if (!(m_rc = wglCreateContext(m_dc))) + m_rc = wglCreateContext(m_dc); + if (!m_rc) { PanicAlert("(4) Can't create an OpenGL rendering context."); return false; diff --git a/Source/Core/Core/ARDecrypt.cpp b/Source/Core/Core/ARDecrypt.cpp index 40d43a3619..77bfc175d3 100644 --- a/Source/Core/Core/ARDecrypt.cpp +++ b/Source/Core/Core/ARDecrypt.cpp @@ -471,7 +471,8 @@ void DecryptARCode(std::vector vCodes, std::vector* ops) std::transform(s.begin(), s.end(), s.begin(), toupper); } - if ((ret = alphatobin(uCodes, vCodes, (int)vCodes.size()))) + ret = alphatobin(uCodes, vCodes, (int)vCodes.size()); + if (ret) { // Return value is index + 1, 0 being the success flag value. PanicAlertT("Action Replay Code Decryption Error:\nParity Check Failed\n\nCulprit Code:\n%s", diff --git a/Source/Core/DolphinWX/Debugger/CodeWindowFunctions.cpp b/Source/Core/DolphinWX/Debugger/CodeWindowFunctions.cpp index 2452e85b38..2a536c95e6 100644 --- a/Source/Core/DolphinWX/Debugger/CodeWindowFunctions.cpp +++ b/Source/Core/DolphinWX/Debugger/CodeWindowFunctions.cpp @@ -146,11 +146,12 @@ void CCodeWindow::OnProfilerMenu(wxCommandEvent& event) File::CreateFullPath(filename); Profiler::WriteProfileResults(filename); - wxFileType* filetype = nullptr; - if (!(filetype = wxTheMimeTypesManager->GetFileTypeFromExtension("txt"))) + wxFileType* filetype = wxTheMimeTypesManager->GetFileTypeFromExtension("txt"); + if (!filetype) { // From extension failed, trying with MIME type now - if (!(filetype = wxTheMimeTypesManager->GetFileTypeFromMimeType("text/plain"))) + filetype = wxTheMimeTypesManager->GetFileTypeFromMimeType("text/plain"); + if (!filetype) // MIME type failed, aborting mission break; } diff --git a/Source/Core/InputCommon/GCAdapter.cpp b/Source/Core/InputCommon/GCAdapter.cpp index 2cb7819d9d..a422e2635e 100644 --- a/Source/Core/InputCommon/GCAdapter.cpp +++ b/Source/Core/InputCommon/GCAdapter.cpp @@ -266,27 +266,26 @@ static bool CheckDeviceAccess(libusb_device* device) } return false; } - else if ((ret = libusb_kernel_driver_active(s_handle, 0)) == 1) + else { - if ((ret = libusb_detach_kernel_driver(s_handle, 0)) && ret != LIBUSB_ERROR_NOT_SUPPORTED) + ret = libusb_kernel_driver_active(s_handle, 0); + if (ret == 1) { - ERROR_LOG(SERIALINTERFACE, "libusb_detach_kernel_driver failed with error: %d", ret); + ret = libusb_detach_kernel_driver(s_handle, 0); + if (ret != 0 && ret != LIBUSB_ERROR_NOT_SUPPORTED) + ERROR_LOG(SERIALINTERFACE, "libusb_detach_kernel_driver failed with error: %d", ret); } } // this split is needed so that we don't avoid claiming the interface when // detaching the kernel driver is successful if (ret != 0 && ret != LIBUSB_ERROR_NOT_SUPPORTED) - { return false; - } - else if ((ret = libusb_claim_interface(s_handle, 0))) - { + + ret = libusb_claim_interface(s_handle, 0); + if (ret) ERROR_LOG(SERIALINTERFACE, "libusb_claim_interface failed with error: %d", ret); - } else - { return true; - } } return false; } diff --git a/Source/Core/VideoCommon/AVIDump.cpp b/Source/Core/VideoCommon/AVIDump.cpp index dc4e806f6a..6a7590f034 100644 --- a/Source/Core/VideoCommon/AVIDump.cpp +++ b/Source/Core/VideoCommon/AVIDump.cpp @@ -159,8 +159,9 @@ bool AVIDump::CreateVideoFile() const AVCodec* codec = nullptr; - if (!(codec = avcodec_find_encoder(codec_id)) || - !(s_codec_context = avcodec_alloc_context3(codec))) + codec = avcodec_find_encoder(codec_id); + s_codec_context = avcodec_alloc_context3(codec); + if (!codec || !s_codec_context) { ERROR_LOG(VIDEO, "Could not find encoder or allocate codec context"); return false; @@ -203,8 +204,8 @@ bool AVIDump::CreateVideoFile() return false; #endif - if (!(s_stream = avformat_new_stream(s_format_context, codec)) || - !AVStreamCopyContext(s_stream, s_codec_context)) + s_stream = avformat_new_stream(s_format_context, codec); + if (!s_stream || !AVStreamCopyContext(s_stream, s_codec_context)) { ERROR_LOG(VIDEO, "Could not create stream"); return false; @@ -299,9 +300,10 @@ void AVIDump::AddFrame(const u8* data, int width, int height, int stride, const s_src_frame->height = s_height; // Convert image from {BGR24, RGBA} to desired pixel format - if ((s_sws_context = - sws_getCachedContext(s_sws_context, width, height, s_pix_fmt, s_width, s_height, - s_codec_context->pix_fmt, SWS_BICUBIC, nullptr, nullptr, nullptr))) + s_sws_context = + sws_getCachedContext(s_sws_context, width, height, s_pix_fmt, s_width, s_height, + s_codec_context->pix_fmt, SWS_BICUBIC, nullptr, nullptr, nullptr); + if (s_sws_context) { sws_scale(s_sws_context, s_src_frame->data, s_src_frame->linesize, 0, height, s_scaled_frame->data, s_scaled_frame->linesize); From 5480efdff2f6e51245aa690a0ccb152a2b0a438e Mon Sep 17 00:00:00 2001 From: Shawn Hoffman Date: Wed, 7 Jun 2017 04:30:39 -0700 Subject: [PATCH 21/23] video: change multisample/AA setting to u32 --- Source/Core/Core/Config/GraphicsSettings.cpp | 2 +- Source/Core/Core/Config/GraphicsSettings.h | 2 +- Source/Core/DolphinWX/VideoConfigDiag.cpp | 6 +++--- Source/Core/VideoBackends/D3D/D3DBase.cpp | 2 +- Source/Core/VideoBackends/OGL/Render.cpp | 4 ++-- Source/Core/VideoBackends/Vulkan/Renderer.cpp | 2 +- Source/Core/VideoCommon/VideoConfig.h | 4 ++-- 7 files changed, 11 insertions(+), 11 deletions(-) diff --git a/Source/Core/Core/Config/GraphicsSettings.cpp b/Source/Core/Core/Config/GraphicsSettings.cpp index dcde16a17d..870fb1971c 100644 --- a/Source/Core/Core/Config/GraphicsSettings.cpp +++ b/Source/Core/Core/Config/GraphicsSettings.cpp @@ -57,7 +57,7 @@ const ConfigInfo GFX_ENABLE_GPU_TEXTURE_DECODING{ const ConfigInfo GFX_ENABLE_PIXEL_LIGHTING{{System::GFX, "Settings", "EnablePixelLighting"}, false}; const ConfigInfo GFX_FAST_DEPTH_CALC{{System::GFX, "Settings", "FastDepthCalc"}, true}; -const ConfigInfo GFX_MSAA{{System::GFX, "Settings", "MSAA"}, 1}; +const ConfigInfo GFX_MSAA{{System::GFX, "Settings", "MSAA"}, 1}; const ConfigInfo GFX_SSAA{{System::GFX, "Settings", "SSAA"}, false}; const ConfigInfo GFX_EFB_SCALE{{System::GFX, "Settings", "EFBScale"}, static_cast(SCALE_1X)}; diff --git a/Source/Core/Core/Config/GraphicsSettings.h b/Source/Core/Core/Config/GraphicsSettings.h index 7ff7b2b667..0b3b98ee06 100644 --- a/Source/Core/Core/Config/GraphicsSettings.h +++ b/Source/Core/Core/Config/GraphicsSettings.h @@ -47,7 +47,7 @@ extern const ConfigInfo GFX_INTERNAL_RESOLUTION_FRAME_DUMPS; extern const ConfigInfo GFX_ENABLE_GPU_TEXTURE_DECODING; extern const ConfigInfo GFX_ENABLE_PIXEL_LIGHTING; extern const ConfigInfo GFX_FAST_DEPTH_CALC; -extern const ConfigInfo GFX_MSAA; +extern const ConfigInfo GFX_MSAA; extern const ConfigInfo GFX_SSAA; extern const ConfigInfo GFX_EFB_SCALE; extern const ConfigInfo GFX_TEXFMT_OVERLAY_ENABLE; diff --git a/Source/Core/DolphinWX/VideoConfigDiag.cpp b/Source/Core/DolphinWX/VideoConfigDiag.cpp index 65dc4c3603..22490e4ad5 100644 --- a/Source/Core/DolphinWX/VideoConfigDiag.cpp +++ b/Source/Core/DolphinWX/VideoConfigDiag.cpp @@ -1322,11 +1322,11 @@ void VideoConfigDiag::PopulatePostProcessingShaders() void VideoConfigDiag::PopulateAAList() { - const std::vector& aa_modes = vconfig.backend_info.AAModes; + const auto& aa_modes = vconfig.backend_info.AAModes; const bool supports_ssaa = vconfig.backend_info.bSupportsSSAA; m_msaa_modes = 0; - for (int mode : aa_modes) + for (auto mode : aa_modes) { if (mode == 1) { @@ -1342,7 +1342,7 @@ void VideoConfigDiag::PopulateAAList() if (supports_ssaa) { - for (int mode : aa_modes) + for (auto mode : aa_modes) { if (mode != 1) choice_aamode->AppendString(std::to_string(mode) + "x SSAA"); diff --git a/Source/Core/VideoBackends/D3D/D3DBase.cpp b/Source/Core/VideoBackends/D3D/D3DBase.cpp index b1ba228b96..327fece109 100644 --- a/Source/Core/VideoBackends/D3D/D3DBase.cpp +++ b/Source/Core/VideoBackends/D3D/D3DBase.cpp @@ -320,7 +320,7 @@ HRESULT Create(HWND wnd) return desc.Count == g_Config.iMultisamples; }) == aa_modes.end()) { - Config::SetCurrent(Config::GFX_MSAA, 1); + Config::SetCurrent(Config::GFX_MSAA, UINT32_C(1)); UpdateActiveConfig(); } diff --git a/Source/Core/VideoBackends/OGL/Render.cpp b/Source/Core/VideoBackends/OGL/Render.cpp index ebec5e98a9..ec709c152b 100644 --- a/Source/Core/VideoBackends/OGL/Render.cpp +++ b/Source/Core/VideoBackends/OGL/Render.cpp @@ -63,7 +63,7 @@ static std::unique_ptr s_raster_font; // 1 for no MSAA. Use s_MSAASamples > 1 to check for MSAA. static int s_MSAASamples = 1; -static int s_last_multisamples = 1; +static u32 s_last_multisamples = 1; static bool s_last_stereo_mode = false; static bool s_last_xfb_mode = false; @@ -519,7 +519,7 @@ Renderer::Renderer() { // GLES 3.1 can't support stereo rendering and MSAA OSD::AddMessage("MSAA Stereo rendering isn't supported by your GPU.", 10000); - Config::SetCurrent(Config::GFX_MSAA, 1); + Config::SetCurrent(Config::GFX_MSAA, UINT32_C(1)); } } else diff --git a/Source/Core/VideoBackends/Vulkan/Renderer.cpp b/Source/Core/VideoBackends/Vulkan/Renderer.cpp index 94087bdc1f..81bd7671cd 100644 --- a/Source/Core/VideoBackends/Vulkan/Renderer.cpp +++ b/Source/Core/VideoBackends/Vulkan/Renderer.cpp @@ -1106,7 +1106,7 @@ void Renderer::CheckForSurfaceChange() void Renderer::CheckForConfigChanges() { // Save the video config so we can compare against to determine which settings have changed. - int old_multisamples = g_ActiveConfig.iMultisamples; + u32 old_multisamples = g_ActiveConfig.iMultisamples; int old_anisotropy = g_ActiveConfig.iMaxAnisotropy; int old_stereo_mode = g_ActiveConfig.iStereoMode; int old_aspect_ratio = g_ActiveConfig.iAspectRatio; diff --git a/Source/Core/VideoCommon/VideoConfig.h b/Source/Core/VideoCommon/VideoConfig.h index 707afae84c..03d102eb62 100644 --- a/Source/Core/VideoCommon/VideoConfig.h +++ b/Source/Core/VideoCommon/VideoConfig.h @@ -70,7 +70,7 @@ struct VideoConfig final bool bShaderCache; // Enhancements - int iMultisamples; + u32 iMultisamples; bool bSSAA; int iEFBScale; bool bForceFiltering; @@ -167,7 +167,7 @@ struct VideoConfig final APIType api_type; std::vector Adapters; // for D3D - std::vector AAModes; + std::vector AAModes; // TODO: merge AdapterName and Adapters array std::string AdapterName; // for OpenGL From 1065dc44384675f35df1b3a62f0173c4f9cc0d5a Mon Sep 17 00:00:00 2001 From: Shawn Hoffman Date: Wed, 7 Jun 2017 04:43:08 -0700 Subject: [PATCH 22/23] msbuild: set warning level 4 --- Source/VSProps/Base.props | 27 +++++++++++++++++++++------ 1 file changed, 21 insertions(+), 6 deletions(-) diff --git a/Source/VSProps/Base.props b/Source/VSProps/Base.props index 4fe3f0e379..77732dc364 100644 --- a/Source/VSProps/Base.props +++ b/Source/VSProps/Base.props @@ -76,7 +76,7 @@ higher declaration can be contained to just the XAudio2/XInput related code. --> _WIN32_WINNT=0x0602;%(PreprocessorDefinitions) - Level3 + Level4 true true false @@ -95,13 +95,28 @@ OldStyle Caret 4996;4351 + + 4201;4127;4100;4244;4121;4324;4714;%(DisableSpecificWarnings) + + 4245;%(DisableSpecificWarnings) From fd166032abec349b9fae7240830133bf7e0c77b5 Mon Sep 17 00:00:00 2001 From: Shawn Hoffman Date: Wed, 7 Jun 2017 15:25:13 -0700 Subject: [PATCH 23/23] msbuild: obey some warnings about missing virtual destructors --- Source/Core/AudioCommon/XAudio2Stream.cpp | 3 +-- Source/Core/AudioCommon/XAudio2_7Stream.cpp | 3 +-- Source/Core/Common/Config/Section.h | 1 + Source/Core/Core/HW/MMIO.cpp | 16 ++++++++++------ Source/VSProps/Base.props | 8 ++++++++ 5 files changed, 21 insertions(+), 10 deletions(-) diff --git a/Source/Core/AudioCommon/XAudio2Stream.cpp b/Source/Core/AudioCommon/XAudio2Stream.cpp index 12954fc5bf..69c503f310 100644 --- a/Source/Core/AudioCommon/XAudio2Stream.cpp +++ b/Source/Core/AudioCommon/XAudio2Stream.cpp @@ -25,8 +25,7 @@ private: public: StreamingVoiceContext(IXAudio2* pXAudio2, CMixer* pMixer, Common::Event& pSyncEvent); - - ~StreamingVoiceContext(); + virtual ~StreamingVoiceContext(); void Stop(); void Play(); diff --git a/Source/Core/AudioCommon/XAudio2_7Stream.cpp b/Source/Core/AudioCommon/XAudio2_7Stream.cpp index 06fb645c95..1abf6d2096 100644 --- a/Source/Core/AudioCommon/XAudio2_7Stream.cpp +++ b/Source/Core/AudioCommon/XAudio2_7Stream.cpp @@ -25,8 +25,7 @@ private: public: StreamingVoiceContext2_7(IXAudio2* pXAudio2, CMixer* pMixer, Common::Event& pSyncEvent); - - ~StreamingVoiceContext2_7(); + virtual ~StreamingVoiceContext2_7(); void Stop(); void Play(); diff --git a/Source/Core/Common/Config/Section.h b/Source/Core/Common/Config/Section.h index 8b36ce157e..0a4662d156 100644 --- a/Source/Core/Common/Config/Section.h +++ b/Source/Core/Common/Config/Section.h @@ -27,6 +27,7 @@ class Section public: Section(LayerType layer, System system, const std::string& name); + virtual ~Section() = default; virtual bool Exists(const std::string& key) const; bool Delete(const std::string& key); diff --git a/Source/Core/Core/HW/MMIO.cpp b/Source/Core/Core/HW/MMIO.cpp index 8ee341554d..a6dcdeebd6 100644 --- a/Source/Core/Core/HW/MMIO.cpp +++ b/Source/Core/Core/HW/MMIO.cpp @@ -20,14 +20,14 @@ template class ReadHandlingMethod { public: - virtual ~ReadHandlingMethod() {} + virtual ~ReadHandlingMethod() = default; virtual void AcceptReadVisitor(ReadHandlingMethodVisitor& v) const = 0; }; template class WriteHandlingMethod { public: - virtual ~WriteHandlingMethod() {} + virtual ~WriteHandlingMethod() = default; virtual void AcceptWriteVisitor(WriteHandlingMethodVisitor& v) const = 0; }; @@ -39,7 +39,7 @@ class ConstantHandlingMethod : public ReadHandlingMethod { public: explicit ConstantHandlingMethod(T value) : value_(value) {} - virtual ~ConstantHandlingMethod() {} + virtual ~ConstantHandlingMethod() = default; void AcceptReadVisitor(ReadHandlingMethodVisitor& v) const override { v.VisitConstant(value_); @@ -62,7 +62,7 @@ class NopHandlingMethod : public WriteHandlingMethod { public: NopHandlingMethod() {} - virtual ~NopHandlingMethod() {} + virtual ~NopHandlingMethod() = default; void AcceptWriteVisitor(WriteHandlingMethodVisitor& v) const override { v.VisitNop(); } }; template @@ -79,7 +79,7 @@ class DirectHandlingMethod : public ReadHandlingMethod, public WriteHandlingM { public: DirectHandlingMethod(T* addr, u32 mask) : addr_(addr), mask_(mask) {} - virtual ~DirectHandlingMethod() {} + virtual ~DirectHandlingMethod() = default; void AcceptReadVisitor(ReadHandlingMethodVisitor& v) const override { v.VisitDirect(addr_, mask_); @@ -132,7 +132,7 @@ public: { } - virtual ~ComplexHandlingMethod() {} + virtual ~ComplexHandlingMethod() = default; void AcceptReadVisitor(ReadHandlingMethodVisitor& v) const override { v.VisitComplex(&read_lambda_); @@ -304,6 +304,8 @@ void ReadHandler::ResetMethod(ReadHandlingMethod* method) struct FuncCreatorVisitor : public ReadHandlingMethodVisitor { + virtual ~FuncCreatorVisitor() = default; + std::function ret; void VisitConstant(T value) override @@ -356,6 +358,8 @@ void WriteHandler::ResetMethod(WriteHandlingMethod* method) struct FuncCreatorVisitor : public WriteHandlingMethodVisitor { + virtual ~FuncCreatorVisitor() = default; + std::function ret; void VisitNop() override diff --git a/Source/VSProps/Base.props b/Source/VSProps/Base.props index 77732dc364..31336f3c07 100644 --- a/Source/VSProps/Base.props +++ b/Source/VSProps/Base.props @@ -117,6 +117,14 @@ Currently jits use some annoying code patterns which makes this common --> 4245;%(DisableSpecificWarnings) + +