diff --git a/Source/Core/Common/Assert.h b/Source/Core/Common/Assert.h index afe4ead4ee..24d8b73202 100644 --- a/Source/Core/Common/Assert.h +++ b/Source/Core/Common/Assert.h @@ -9,28 +9,6 @@ #include "Common/Logging/Log.h" #include "Common/MsgHandler.h" -#ifdef _WIN32 -#define ASSERT_MSG(_t_, _a_, _fmt_, ...) \ - do \ - { \ - if (!(_a_)) \ - { \ - if (!PanicYesNo(_fmt_, __VA_ARGS__)) \ - Crash(); \ - } \ - } while (0) - -#define DEBUG_ASSERT_MSG(_t_, _a_, _msg_, ...) \ - do \ - { \ - if (MAX_LOGLEVEL >= Common::Log::LOG_LEVELS::LDEBUG && !(_a_)) \ - { \ - ERROR_LOG(_t_, _msg_, __VA_ARGS__); \ - if (!PanicYesNo(_msg_, __VA_ARGS__)) \ - Crash(); \ - } \ - } while (0) -#else #define ASSERT_MSG(_t_, _a_, _fmt_, ...) \ do \ { \ @@ -44,14 +22,16 @@ #define DEBUG_ASSERT_MSG(_t_, _a_, _msg_, ...) \ do \ { \ - if (MAX_LOGLEVEL >= Common::Log::LOG_LEVELS::LDEBUG && !(_a_)) \ + if constexpr (MAX_LOGLEVEL >= Common::Log::LOG_LEVELS::LDEBUG) \ { \ - ERROR_LOG(_t_, _msg_, ##__VA_ARGS__); \ - if (!PanicYesNo(_msg_, ##__VA_ARGS__)) \ - Crash(); \ + if (!(_a_)) \ + { \ + ERROR_LOG(_t_, _msg_, ##__VA_ARGS__); \ + if (!PanicYesNo(_msg_, ##__VA_ARGS__)) \ + Crash(); \ + } \ } \ } while (0) -#endif #define ASSERT(_a_) \ do \ @@ -64,6 +44,6 @@ #define DEBUG_ASSERT(_a_) \ do \ { \ - if (MAX_LOGLEVEL >= Common::Log::LOG_LEVELS::LDEBUG) \ + if constexpr (MAX_LOGLEVEL >= Common::Log::LOG_LEVELS::LDEBUG) \ ASSERT(_a_); \ } while (0) diff --git a/Source/Core/Common/CompatPatches.cpp b/Source/Core/Common/CompatPatches.cpp index f2b179eb12..260488cd6a 100644 --- a/Source/Core/Common/CompatPatches.cpp +++ b/Source/Core/Common/CompatPatches.cpp @@ -183,7 +183,7 @@ static bool GetModuleVersion(const wchar_t* name, Version* version) if (!data_len) return false; std::vector block(data_len); - if (!GetFileVersionInfoW(path->c_str(), handle, data_len, block.data())) + if (!GetFileVersionInfoW(path->c_str(), 0, data_len, block.data())) return false; void* buf; UINT buf_len; diff --git a/Source/Core/Common/FileSearch.cpp b/Source/Core/Common/FileSearch.cpp index 6b28b93b4c..bbcdc12026 100644 --- a/Source/Core/Common/FileSearch.cpp +++ b/Source/Core/Common/FileSearch.cpp @@ -98,7 +98,7 @@ std::vector DoFileSearch(const std::vector& directorie }; for (const auto& directory : directories) { - const fs::path directory_path = StringToPath(directory); + fs::path directory_path = StringToPath(directory); if (fs::is_directory(directory_path)) // Can't create iterators for non-existant directories { if (recursive) @@ -125,9 +125,11 @@ std::vector DoFileSearch(const std::vector& directorie // std::filesystem uses the OS separator. constexpr fs::path::value_type os_separator = fs::path::preferred_separator; static_assert(os_separator == DIR_SEP_CHR || os_separator == '\\', "Unsupported path separator"); - if (os_separator != DIR_SEP_CHR) + if constexpr (os_separator != DIR_SEP_CHR) + { for (auto& path : result) std::replace(path.begin(), path.end(), '\\', DIR_SEP_CHR); + } return result; } diff --git a/Source/Core/Common/FileUtil.cpp b/Source/Core/Common/FileUtil.cpp index d5ba4d03a0..b3efa6b868 100644 --- a/Source/Core/Common/FileUtil.cpp +++ b/Source/Core/Common/FileUtil.cpp @@ -600,7 +600,7 @@ std::string GetCurrentDir() if (!dir) { ERROR_LOG(COMMON, "GetCurrentDirectory failed: %s", LastStrerrorString().c_str()); - return nullptr; + return ""; } std::string strDir = dir; free(dir); @@ -621,10 +621,15 @@ std::string CreateTempDir() return ""; GUID guid; - CoCreateGuid(&guid); - TCHAR tguid[40]; - StringFromGUID2(guid, tguid, 39); - tguid[39] = 0; + if (FAILED(CoCreateGuid(&guid))) + { + return ""; + } + OLECHAR tguid[40]{}; + if (!StringFromGUID2(guid, tguid, _countof(tguid))) + { + return ""; + } std::string dir = TStrToUTF8(temp) + "/" + TStrToUTF8(tguid); if (!CreateDir(dir)) return ""; diff --git a/Source/Core/Common/GekkoDisassembler.cpp b/Source/Core/Common/GekkoDisassembler.cpp index 040ac84980..828adcaf03 100644 --- a/Source/Core/Common/GekkoDisassembler.cpp +++ b/Source/Core/Common/GekkoDisassembler.cpp @@ -1470,7 +1470,7 @@ u32* GekkoDisassembler::DoDisassembly(bool big_endian) break; case 30: - switch (in & 0x1c) + switch ((in >> 2) & 0x7) { case 0: rld(in, "icl", 0); // rldicl diff --git a/Source/Core/Common/MsgHandler.h b/Source/Core/Common/MsgHandler.h index 946a34dbb3..aadef05ea7 100644 --- a/Source/Core/Common/MsgHandler.h +++ b/Source/Core/Common/MsgHandler.h @@ -32,39 +32,6 @@ bool MsgAlert(bool yes_no, MsgType style, const char* format, ...) void SetEnableAlert(bool enable); } // namespace Common -#if defined(_WIN32) && (!defined(_MSVC_TRADITIONAL) || _MSVC_TRADITIONAL == 1) -#define SuccessAlert(format, ...) \ - Common::MsgAlert(false, Common::MsgType::Information, format, __VA_ARGS__) - -#define PanicAlert(format, ...) \ - Common::MsgAlert(false, Common::MsgType::Warning, format, __VA_ARGS__) - -#define PanicYesNo(format, ...) \ - Common::MsgAlert(true, Common::MsgType::Warning, format, __VA_ARGS__) - -#define AskYesNo(format, ...) Common::MsgAlert(true, Common::MsgType::Question, format, __VA_ARGS__) - -#define CriticalAlert(format, ...) \ - Common::MsgAlert(false, Common::MsgType::Critical, format, __VA_ARGS__) - -// Use these macros (that do the same thing) if the message should be translated. - -#define SuccessAlertT(format, ...) \ - Common::MsgAlert(false, Common::MsgType::Information, format, __VA_ARGS__) - -#define PanicAlertT(format, ...) \ - Common::MsgAlert(false, Common::MsgType::Warning, format, __VA_ARGS__) - -#define PanicYesNoT(format, ...) \ - Common::MsgAlert(true, Common::MsgType::Warning, format, __VA_ARGS__) - -#define AskYesNoT(format, ...) \ - Common::MsgAlert(true, Common::MsgType::Question, format, __VA_ARGS__) - -#define CriticalAlertT(format, ...) \ - Common::MsgAlert(false, Common::MsgType::Critical, format, __VA_ARGS__) - -#else #define SuccessAlert(format, ...) \ Common::MsgAlert(false, Common::MsgType::Information, format, ##__VA_ARGS__) @@ -95,4 +62,3 @@ void SetEnableAlert(bool enable); #define CriticalAlertT(format, ...) \ Common::MsgAlert(false, Common::MsgType::Critical, format, ##__VA_ARGS__) -#endif diff --git a/Source/Core/Common/SDCardUtil.cpp b/Source/Core/Common/SDCardUtil.cpp index 22284a008f..16f855f6ea 100644 --- a/Source/Core/Common/SDCardUtil.cpp +++ b/Source/Core/Common/SDCardUtil.cpp @@ -247,7 +247,7 @@ bool SDCardCreate(u64 disk_size /*in MB*/, const std::string& filename) if (!write_sector(file, s_fsinfo_sector)) goto FailWrite; - if (BACKUP_BOOT_SECTOR > 0) + if constexpr (BACKUP_BOOT_SECTOR > 0) { if (!write_empty(file, BACKUP_BOOT_SECTOR - 2)) goto FailWrite; diff --git a/Source/Core/Common/Semaphore.h b/Source/Core/Common/Semaphore.h index d132288f2a..731d070929 100644 --- a/Source/Core/Common/Semaphore.h +++ b/Source/Core/Common/Semaphore.h @@ -6,9 +6,6 @@ #ifdef _WIN32 -#ifndef WIN32_LEAN_AND_MEAN -#define WIN32_LEAN_AND_MEAN -#endif #include namespace Common diff --git a/Source/Core/Common/Timer.cpp b/Source/Core/Common/Timer.cpp index 81fb792ff3..d33d1951eb 100644 --- a/Source/Core/Common/Timer.cpp +++ b/Source/Core/Common/Timer.cpp @@ -254,7 +254,7 @@ std::string Timer::GetDateTimeFormatted(double time) #ifdef _WIN32 wchar_t tmp[32] = {}; - wcsftime(tmp, sizeof(tmp), L"%x %X", localTime); + wcsftime(tmp, std::size(tmp), L"%x %X", localTime); return WStringToUTF8(tmp); #else char tmp[32] = {}; diff --git a/Source/Core/Core/HW/EXI/BBA/TAP_Win32.cpp b/Source/Core/Core/HW/EXI/BBA/TAP_Win32.cpp index a421484005..1b4a47433b 100644 --- a/Source/Core/Core/HW/EXI/BBA/TAP_Win32.cpp +++ b/Source/Core/Core/HW/EXI/BBA/TAP_Win32.cpp @@ -35,7 +35,7 @@ bool IsTAPDevice(const TCHAR* guid) TCHAR net_cfg_instance_id[256]; DWORD data_type; - len = sizeof(enum_name); + len = _countof(enum_name); status = RegEnumKeyEx(netcard_key, i, enum_name, &len, nullptr, nullptr, nullptr, nullptr); if (status == ERROR_NO_MORE_ITEMS) @@ -43,7 +43,8 @@ bool IsTAPDevice(const TCHAR* guid) else if (status != ERROR_SUCCESS) return false; - _sntprintf(unit_string, sizeof(unit_string), _T("%s\\%s"), ADAPTER_KEY, enum_name); + _sntprintf(unit_string, _countof(unit_string), _T("%s\\%s"), ADAPTER_KEY, enum_name); + unit_string[_countof(unit_string) - 1] = _T('\0'); status = RegOpenKeyEx(HKEY_LOCAL_MACHINE, unit_string, 0, KEY_READ, &unit_key); @@ -110,14 +111,15 @@ bool GetGUIDs(std::vector>& guids) DWORD name_type; const TCHAR name_string[] = _T("Name"); - len = sizeof(enum_name); + len = _countof(enum_name); status = RegEnumKeyEx(control_net_key, i, enum_name, &len, nullptr, nullptr, nullptr, nullptr); if (status != ERROR_SUCCESS) continue; - _sntprintf(connection_string, sizeof(connection_string), _T("%s\\%s\\Connection"), + _sntprintf(connection_string, _countof(connection_string), _T("%s\\%s\\Connection"), NETWORK_CONNECTIONS_KEY, enum_name); + connection_string[_countof(connection_string) - 1] = _T('\0'); status = RegOpenKeyEx(HKEY_LOCAL_MACHINE, connection_string, 0, KEY_READ, &connection_key); @@ -196,7 +198,7 @@ bool CEXIETHERNET::TAPNetworkInterface::Activate() } /* get driver version info */ - ULONG info[3]; + ULONG info[3]{}; if (DeviceIoControl(mHAdapter, TAP_IOCTL_GET_VERSION, &info, sizeof(info), &info, sizeof(info), &len, nullptr)) { diff --git a/Source/Core/Core/HW/WiimoteCommon/WiimoteHid.h b/Source/Core/Core/HW/WiimoteCommon/WiimoteHid.h index fbcbd8b9e2..6afa1fc38c 100644 --- a/Source/Core/Core/HW/WiimoteCommon/WiimoteHid.h +++ b/Source/Core/Core/HW/WiimoteCommon/WiimoteHid.h @@ -54,7 +54,7 @@ struct TypedHIDInputData T data; - static_assert(std::is_pod()); + static_assert(std::is_standard_layout_v && std::is_trivially_copyable_v); u8* GetData() { return reinterpret_cast(this); } const u8* GetData() const { return reinterpret_cast(this); } diff --git a/Source/Core/Core/HW/WiimoteEmu/I2CBus.h b/Source/Core/Core/HW/WiimoteEmu/I2CBus.h index f20719af32..256f386cd9 100644 --- a/Source/Core/Core/HW/WiimoteEmu/I2CBus.h +++ b/Source/Core/Core/HW/WiimoteEmu/I2CBus.h @@ -26,7 +26,7 @@ protected: template static int RawRead(T* reg_data, u8 addr, int count, u8* data_out) { - static_assert(std::is_pod::value); + static_assert(std::is_standard_layout_v && std::is_trivially_copyable_v); static_assert(0x100 == sizeof(T)); // TODO: addr wraps around after 0xff @@ -42,7 +42,7 @@ protected: template static int RawWrite(T* reg_data, u8 addr, int count, const u8* data_in) { - static_assert(std::is_pod::value); + static_assert(std::is_standard_layout_v && std::is_trivially_copyable_v); static_assert(0x100 == sizeof(T)); // TODO: addr wraps around after 0xff diff --git a/Source/Core/Core/HW/WiimoteReal/IOWin.cpp b/Source/Core/Core/HW/WiimoteReal/IOWin.cpp index f755eedb6b..74cfe5cb88 100644 --- a/Source/Core/Core/HW/WiimoteReal/IOWin.cpp +++ b/Source/Core/Core/HW/WiimoteReal/IOWin.cpp @@ -418,6 +418,10 @@ int WriteToHandle(HANDLE& dev_handle, WinWriteMethod& method, const u8* buf, siz { OVERLAPPED hid_overlap_write = OVERLAPPED(); hid_overlap_write.hEvent = CreateEvent(nullptr, true, false, nullptr); + if (!hid_overlap_write.hEvent) + { + return 0; + } DWORD written = 0; IOWrite(dev_handle, hid_overlap_write, method, buf, size, &written); @@ -431,6 +435,10 @@ int ReadFromHandle(HANDLE& dev_handle, u8* buf) { OVERLAPPED hid_overlap_read = OVERLAPPED(); hid_overlap_read.hEvent = CreateEvent(nullptr, true, false, nullptr); + if (!hid_overlap_read.hEvent) + { + return 0; + } const int read = IORead(dev_handle, hid_overlap_read, buf, 1); CloseHandle(hid_overlap_read.hEvent); return read; @@ -533,7 +541,6 @@ void WiimoteScannerWindows::FindWiimotes(std::vector& found_wiimotes, SP_DEVICE_INTERFACE_DATA device_data = {}; device_data.cbSize = sizeof(device_data); - PSP_DEVICE_INTERFACE_DETAIL_DATA detail_data = nullptr; for (int index = 0; SetupDiEnumDeviceInterfaces(device_info, nullptr, &device_id, index, &device_data); ++index) @@ -541,7 +548,8 @@ void WiimoteScannerWindows::FindWiimotes(std::vector& found_wiimotes, // Get the size of the data block required DWORD len; SetupDiGetDeviceInterfaceDetail(device_info, &device_data, nullptr, 0, &len, nullptr); - detail_data = (PSP_DEVICE_INTERFACE_DETAIL_DATA)malloc(len); + auto detail_data_buf = std::make_unique(len); + auto detail_data = reinterpret_cast(detail_data_buf.get()); detail_data->cbSize = sizeof(SP_DEVICE_INTERFACE_DETAIL_DATA); SP_DEVINFO_DATA device_info_data = {}; @@ -558,7 +566,6 @@ void WiimoteScannerWindows::FindWiimotes(std::vector& found_wiimotes, if (!IsNewWiimote(WStringToUTF8(device_path)) || !IsWiimote(device_path, write_method)) { - free(detail_data); continue; } @@ -568,8 +575,6 @@ void WiimoteScannerWindows::FindWiimotes(std::vector& found_wiimotes, else found_wiimotes.push_back(wiimote); } - - free(detail_data); } SetupDiDestroyDeviceInfoList(device_info); diff --git a/Source/Core/Core/IOS/ES/Formats.cpp b/Source/Core/Core/IOS/ES/Formats.cpp index c1c815aef4..6e9a31f55c 100644 --- a/Source/Core/Core/IOS/ES/Formats.cpp +++ b/Source/Core/Core/IOS/ES/Formats.cpp @@ -621,7 +621,7 @@ UIDSys::UIDSys(std::shared_ptr fs) : m_fs{fs} { while (true) { - const std::pair entry = ReadUidSysEntry(*file); + std::pair entry = ReadUidSysEntry(*file); if (!entry.first && !entry.second) break; @@ -766,7 +766,7 @@ std::map ParseCertChain(const std::vector& chain) return certs; processed += cert_reader.GetBytes().size(); - const std::string name = cert_reader.GetName(); + std::string name = cert_reader.GetName(); certs.emplace(std::move(name), std::move(cert_reader)); } return certs; diff --git a/Source/Core/Core/IOS/IOS.cpp b/Source/Core/Core/IOS/IOS.cpp index ede48baf1b..b5fe88b709 100644 --- a/Source/Core/Core/IOS/IOS.cpp +++ b/Source/Core/Core/IOS/IOS.cpp @@ -824,7 +824,8 @@ void Init() if (!s_ios) return; - auto device = static_cast(s_ios->GetDeviceByName("/dev/sdio/slot0").get()); + auto sdio_slot0 = s_ios->GetDeviceByName("/dev/sdio/slot0"); + auto device = static_cast(sdio_slot0.get()); if (device) device->EventNotify(); }); diff --git a/Source/Core/Core/IOS/Network/IP/Top.cpp b/Source/Core/Core/IOS/Network/IP/Top.cpp index 5f8ee3282a..2cd38142fd 100644 --- a/Source/Core/Core/IOS/Network/IP/Top.cpp +++ b/Source/Core/Core/IOS/Network/IP/Top.cpp @@ -86,13 +86,12 @@ static constexpr u32 inet_addr(u8 a, u8 b, u8 c, u8 d) static int inet_pton(const char* src, unsigned char* dst) { - int saw_digit, octets; + int saw_digit = 0; + int octets = 0; + unsigned char tmp[4]{}; + unsigned char* tp = tmp; char ch; - unsigned char tmp[4], *tp; - saw_digit = 0; - octets = 0; - *(tp = tmp) = 0; while ((ch = *src++) != '\0') { if (ch >= '0' && ch <= '9') @@ -927,8 +926,9 @@ IPCCommandResult NetIPTop::HandleRecvFromRequest(const IOCtlVRequest& request) IPCCommandResult NetIPTop::HandleGetAddressInfoRequest(const IOCtlVRequest& request) { addrinfo hints; + const bool hints_valid = request.in_vectors.size() > 2 && request.in_vectors[2].size; - if (request.in_vectors.size() > 2 && request.in_vectors[2].size) + if (hints_valid) { hints.ai_flags = Memory::Read_U32(request.in_vectors[2].address); hints.ai_family = Memory::Read_U32(request.in_vectors[2].address + 0x4); @@ -959,9 +959,7 @@ IPCCommandResult NetIPTop::HandleGetAddressInfoRequest(const IOCtlVRequest& requ } addrinfo* result = nullptr; - int ret = getaddrinfo( - pNodeName, pServiceName, - (request.in_vectors.size() > 2 && request.in_vectors[2].size) ? &hints : nullptr, &result); + int ret = getaddrinfo(pNodeName, pServiceName, hints_valid ? &hints : nullptr, &result); u32 addr = request.io_vectors[0].address; u32 sockoffset = addr + 0x460; if (ret == 0) diff --git a/Source/Core/Core/IOS/USB/USB_HID/HIDv4.cpp b/Source/Core/Core/IOS/USB/USB_HID/HIDv4.cpp index b8513df344..661398b351 100644 --- a/Source/Core/Core/IOS/USB/USB_HID/HIDv4.cpp +++ b/Source/Core/Core/IOS/USB/USB_HID/HIDv4.cpp @@ -208,7 +208,7 @@ static void CopyDescriptorToBuffer(std::vector* buffer, T descriptor) descriptor.Swap(); buffer->insert(buffer->end(), reinterpret_cast(&descriptor), reinterpret_cast(&descriptor) + size); - const size_t number_of_padding_bytes = Common::AlignUp(size, 4) - size; + constexpr size_t number_of_padding_bytes = Common::AlignUp(size, 4) - size; buffer->insert(buffer->end(), number_of_padding_bytes, 0); } diff --git a/Source/Core/Core/PowerPC/Interpreter/Interpreter_LoadStorePaired.cpp b/Source/Core/Core/PowerPC/Interpreter/Interpreter_LoadStorePaired.cpp index a81fae3dc1..5d1a6ed21d 100644 --- a/Source/Core/Core/PowerPC/Interpreter/Interpreter_LoadStorePaired.cpp +++ b/Source/Core/Core/PowerPC/Interpreter/Interpreter_LoadStorePaired.cpp @@ -61,8 +61,8 @@ template SType ScaleAndClamp(double ps, u32 stScale) { float convPS = (float)ps * m_quantizeTable[stScale]; - float min = (float)std::numeric_limits::min(); - float max = (float)std::numeric_limits::max(); + constexpr float min = (float)std::numeric_limits::min(); + constexpr float max = (float)std::numeric_limits::max(); return (SType)std::clamp(convPS, min, max); } diff --git a/Source/Core/Core/PowerPC/PPCSymbolDB.cpp b/Source/Core/Core/PowerPC/PPCSymbolDB.cpp index fc02b54bbb..30a2f5b857 100644 --- a/Source/Core/Core/PowerPC/PPCSymbolDB.cpp +++ b/Source/Core/Core/PowerPC/PPCSymbolDB.cpp @@ -247,7 +247,7 @@ bool PPCSymbolDB::LoadMap(const std::string& filename, bool bad) continue; } - char temp[256]; + char temp[256]{}; sscanf(line, "%255s", temp); if (strcmp(temp, "UNUSED") == 0) diff --git a/Source/Core/DolphinQt/Config/ControllerInterface/DualShockUDPClientWidget.cpp b/Source/Core/DolphinQt/Config/ControllerInterface/DualShockUDPClientWidget.cpp index 4c7f41c5e4..1b18435544 100644 --- a/Source/Core/DolphinQt/Config/ControllerInterface/DualShockUDPClientWidget.cpp +++ b/Source/Core/DolphinQt/Config/ControllerInterface/DualShockUDPClientWidget.cpp @@ -28,7 +28,7 @@ void DualShockUDPClientWidget::CreateWidgets() m_servers_enabled = new QCheckBox(tr("Enable")); m_servers_enabled->setChecked(Config::Get(ciface::DualShockUDPClient::Settings::SERVERS_ENABLED)); - main_layout->addWidget(m_servers_enabled, 0, 0); + main_layout->addWidget(m_servers_enabled, 0, {}); m_server_list = new QListWidget(); main_layout->addWidget(m_server_list); diff --git a/Source/Core/DolphinQt/Config/ControllersWindow.cpp b/Source/Core/DolphinQt/Config/ControllersWindow.cpp index 2f3d03ed43..82e6da599b 100644 --- a/Source/Core/DolphinQt/Config/ControllersWindow.cpp +++ b/Source/Core/DolphinQt/Config/ControllersWindow.cpp @@ -131,9 +131,12 @@ static int GetLayoutHorizontalSpacing(const QGridLayout* layout) // Docs claim this is deprecated, but on macOS with Qt 5.8 this is the only one that actually // works. float pixel_ratio = QGuiApplication::primaryScreen()->devicePixelRatio(); +#ifdef __APPLE__ + // TODO is this still required? hspacing = pixel_ratio * style->pixelMetric(QStyle::PM_DefaultLayoutSpacing); if (hspacing >= 0) return hspacing; +#endif // Ripped from qtbase/src/widgets/styles/qcommonstyle.cpp return pixel_ratio * 6; diff --git a/Source/Core/DolphinQt/Debugger/MemoryViewWidget.cpp b/Source/Core/DolphinQt/Debugger/MemoryViewWidget.cpp index 00070d2146..60d32a8a25 100644 --- a/Source/Core/DolphinQt/Debugger/MemoryViewWidget.cpp +++ b/Source/Core/DolphinQt/Debugger/MemoryViewWidget.cpp @@ -156,7 +156,7 @@ void MemoryViewWidget::Update() } else { - hex_item->setFlags(0); + hex_item->setFlags({}); hex_item->setText(QStringLiteral("-")); } } diff --git a/Source/Core/DolphinQt/DolphinQt.vcxproj b/Source/Core/DolphinQt/DolphinQt.vcxproj index 89ecbafd2e..3d93fb43e4 100644 --- a/Source/Core/DolphinQt/DolphinQt.vcxproj +++ b/Source/Core/DolphinQt/DolphinQt.vcxproj @@ -21,7 +21,7 @@ 5054;%(DisableSpecificWarnings) - ($ProjectDir)Config\Graphics;%(AdditionalIncludeDirectories) + $(ProjectDir)Config\Graphics;%(AdditionalIncludeDirectories) $(ProjectDir)Config;%(AdditionalIncludeDirectories) $(ProjectDir)Config\ControllerInterface;%(AdditionalIncludeDirectories) $(ProjectDir)Config\Mapping;%(AdditionalIncludeDirectories) diff --git a/Source/Core/DolphinQt/QtUtils/FlowLayout.cpp b/Source/Core/DolphinQt/QtUtils/FlowLayout.cpp index b20d42f96e..bd481ea624 100644 --- a/Source/Core/DolphinQt/QtUtils/FlowLayout.cpp +++ b/Source/Core/DolphinQt/QtUtils/FlowLayout.cpp @@ -120,7 +120,7 @@ QLayoutItem* FlowLayout::takeAt(int index) Qt::Orientations FlowLayout::expandingDirections() const { - return 0; + return {}; } bool FlowLayout::hasHeightForWidth() const diff --git a/Source/Core/DolphinQt/Settings/InterfacePane.cpp b/Source/Core/DolphinQt/Settings/InterfacePane.cpp index af5545565f..99d3993942 100644 --- a/Source/Core/DolphinQt/Settings/InterfacePane.cpp +++ b/Source/Core/DolphinQt/Settings/InterfacePane.cpp @@ -186,9 +186,9 @@ void InterfacePane::ConnectLayout() connect(m_checkbox_use_covers, &QCheckBox::toggled, this, &InterfacePane::OnSaveConfig); connect(m_checkbox_show_debugging_ui, &QCheckBox::toggled, this, &InterfacePane::OnSaveConfig); connect(m_checkbox_focused_hotkeys, &QCheckBox::toggled, this, &InterfacePane::OnSaveConfig); - connect(m_combobox_theme, qOverload(&QComboBox::currentIndexChanged), - &Settings::Instance(), &Settings::SetThemeName); - connect(m_combobox_userstyle, qOverload(&QComboBox::currentIndexChanged), this, + connect(m_combobox_theme, qOverload(&QComboBox::currentIndexChanged), this, + [=](int index) { Settings::Instance().SetThemeName(m_combobox_theme->itemText(index)); }); + connect(m_combobox_userstyle, qOverload(&QComboBox::currentIndexChanged), this, &InterfacePane::OnSaveConfig); connect(m_combobox_language, qOverload(&QComboBox::currentIndexChanged), this, &InterfacePane::OnSaveConfig); diff --git a/Source/Core/DolphinQt/Settings/USBDeviceAddToWhitelistDialog.cpp b/Source/Core/DolphinQt/Settings/USBDeviceAddToWhitelistDialog.cpp index ba531093f0..5f9fdceca5 100644 --- a/Source/Core/DolphinQt/Settings/USBDeviceAddToWhitelistDialog.cpp +++ b/Source/Core/DolphinQt/Settings/USBDeviceAddToWhitelistDialog.cpp @@ -168,10 +168,9 @@ void USBDeviceAddToWhitelistDialog::OnDeviceSelection() { // Not the nicest way of doing this but... QString device = usb_inserted_devices_list->currentItem()->text().left(9); - QString* vid = new QString( - device.split(QString::fromStdString(":"), QString::SplitBehavior::KeepEmptyParts)[0]); - QString* pid = new QString( - device.split(QString::fromStdString(":"), QString::SplitBehavior::KeepEmptyParts)[1]); + QStringList split = device.split(QString::fromStdString(":")); + QString* vid = new QString(split[0]); + QString* pid = new QString(split[1]); device_vid_textbox->setText(*vid); device_pid_textbox->setText(*pid); } diff --git a/Source/Core/DolphinQt/Settings/WiiPane.cpp b/Source/Core/DolphinQt/Settings/WiiPane.cpp index 6ee0dd5558..e482a1ca3f 100644 --- a/Source/Core/DolphinQt/Settings/WiiPane.cpp +++ b/Source/Core/DolphinQt/Settings/WiiPane.cpp @@ -279,10 +279,9 @@ void WiiPane::OnUSBWhitelistAddButton() void WiiPane::OnUSBWhitelistRemoveButton() { QString device = m_whitelist_usb_list->currentItem()->text().left(9); - QString vid = - QString(device.split(QString::fromStdString(":"), QString::SplitBehavior::KeepEmptyParts)[0]); - QString pid = - QString(device.split(QString::fromStdString(":"), QString::SplitBehavior::KeepEmptyParts)[1]); + QStringList split = device.split(QString::fromStdString(":")); + QString vid = QString(split[0]); + QString pid = QString(split[1]); const u16 vid_u16 = static_cast(std::stoul(vid.toStdString(), nullptr, 16)); const u16 pid_u16 = static_cast(std::stoul(pid.toStdString(), nullptr, 16)); SConfig::GetInstance().m_usb_passthrough_devices.erase({vid_u16, pid_u16}); diff --git a/Source/Core/UICommon/CommandLineParse.cpp b/Source/Core/UICommon/CommandLineParse.cpp index c89a5784f0..6c06cb2ef2 100644 --- a/Source/Core/UICommon/CommandLineParse.cpp +++ b/Source/Core/UICommon/CommandLineParse.cpp @@ -45,7 +45,7 @@ public: std::getline(buffer, section, '.'); std::getline(buffer, key, '='); std::getline(buffer, value, '='); - const std::optional system = Config::GetSystemFromName(system_str); + std::optional system = Config::GetSystemFromName(system_str); if (system) { m_values.emplace_back( diff --git a/Source/Core/VideoBackends/D3D/D3DBase.h b/Source/Core/VideoBackends/D3D/D3DBase.h index 7fed1bb2c3..c61d505457 100644 --- a/Source/Core/VideoBackends/D3D/D3DBase.h +++ b/Source/Core/VideoBackends/D3D/D3DBase.h @@ -15,12 +15,6 @@ #include "Common/CommonTypes.h" #include "Common/MsgHandler.h" -#define CHECK(cond, Message, ...) \ - if (!(cond)) \ - { \ - PanicAlert("%s failed in %s at line %d: " Message, __func__, __FILE__, __LINE__, __VA_ARGS__); \ - } - namespace DX11 { using Microsoft::WRL::ComPtr; diff --git a/Source/Core/VideoBackends/D3D12/Common.h b/Source/Core/VideoBackends/D3D12/Common.h index 47d0307350..f0b4b29d96 100644 --- a/Source/Core/VideoBackends/D3D12/Common.h +++ b/Source/Core/VideoBackends/D3D12/Common.h @@ -9,13 +9,6 @@ #include "Common/MsgHandler.h" #include "VideoBackends/D3DCommon/Common.h" -#define CHECK(cond, Message, ...) \ - if (!(cond)) \ - { \ - PanicAlert(__FUNCTION__ " failed in %s at line %d: " Message, __FILE__, __LINE__, \ - __VA_ARGS__); \ - } - namespace DX12 { using Microsoft::WRL::ComPtr; diff --git a/Source/Core/VideoBackends/D3D12/VertexManager.cpp b/Source/Core/VideoBackends/D3D12/VertexManager.cpp index bdf5fbe8e8..ecaec7c9c1 100644 --- a/Source/Core/VideoBackends/D3D12/VertexManager.cpp +++ b/Source/Core/VideoBackends/D3D12/VertexManager.cpp @@ -195,10 +195,10 @@ void VertexManager::UploadAllConstants() { // We are free to re-use parts of the buffer now since we're uploading all constants. const u32 pixel_constants_offset = 0; - const u32 vertex_constants_offset = + constexpr u32 vertex_constants_offset = Common::AlignUp(pixel_constants_offset + sizeof(PixelShaderConstants), D3D12_CONSTANT_BUFFER_DATA_PLACEMENT_ALIGNMENT); - const u32 geometry_constants_offset = + constexpr u32 geometry_constants_offset = Common::AlignUp(vertex_constants_offset + sizeof(VertexShaderConstants), D3D12_CONSTANT_BUFFER_DATA_PLACEMENT_ALIGNMENT); const u32 allocation_size = geometry_constants_offset + sizeof(GeometryShaderConstants); diff --git a/Source/Core/VideoBackends/D3DCommon/Common.h b/Source/Core/VideoBackends/D3DCommon/Common.h index 5f05c82978..4dced9af91 100644 --- a/Source/Core/VideoBackends/D3DCommon/Common.h +++ b/Source/Core/VideoBackends/D3DCommon/Common.h @@ -12,6 +12,13 @@ #include "Common/CommonTypes.h" +#define CHECK(cond, Message, ...) \ + if (!(cond)) \ + { \ + PanicAlert("%s failed in %s at line %d: " Message, __func__, __FILE__, __LINE__, \ + ##__VA_ARGS__); \ + } + struct IDXGIFactory; enum class AbstractTextureFormat : u32; diff --git a/Source/Core/VideoBackends/OGL/ProgramShaderCache.cpp b/Source/Core/VideoBackends/OGL/ProgramShaderCache.cpp index a738a98fa2..ec976676c4 100644 --- a/Source/Core/VideoBackends/OGL/ProgramShaderCache.cpp +++ b/Source/Core/VideoBackends/OGL/ProgramShaderCache.cpp @@ -38,7 +38,7 @@ namespace OGL { u32 ProgramShaderCache::s_ubo_buffer_size; -s32 ProgramShaderCache::s_ubo_align; +s32 ProgramShaderCache::s_ubo_align = 1; GLuint ProgramShaderCache::s_attributeless_VBO = 0; GLuint ProgramShaderCache::s_attributeless_VAO = 0; GLuint ProgramShaderCache::s_last_VAO = 0; diff --git a/Source/Core/VideoCommon/VideoCommon.h b/Source/Core/VideoCommon/VideoCommon.h index 65f8d2820b..3f2de54c71 100644 --- a/Source/Core/VideoCommon/VideoCommon.h +++ b/Source/Core/VideoCommon/VideoCommon.h @@ -20,11 +20,7 @@ constexpr u32 MAX_XFB_WIDTH = 720; // that are next to each other in memory (TODO: handle that situation). constexpr u32 MAX_XFB_HEIGHT = 576; -#if defined(_WIN32) && (!defined(_MSVC_TRADITIONAL) || _MSVC_TRADITIONAL == 1) -#define PRIM_LOG(...) DEBUG_LOG(VIDEO, __VA_ARGS__) -#else #define PRIM_LOG(...) DEBUG_LOG(VIDEO, ##__VA_ARGS__) -#endif // warning: mapping buffer should be disabled to use this // #define LOG_VTX() DEBUG_LOG(VIDEO, "vtx: %f %f %f, ", ((float*)g_vertex_manager_write_ptr)[-3], diff --git a/Source/VSProps/Base.props b/Source/VSProps/Base.props index 348d58fe53..64a0ee636f 100644 --- a/Source/VSProps/Base.props +++ b/Source/VSProps/Base.props @@ -2,15 +2,11 @@ - $(BuildRootDir)$(Platform)\$(Configuration)\$(ProjectName)\ $(IntDir)bin\ $(ProjectName)$(TargetSuffix) + + false @@ -53,7 +49,15 @@ $(ExternalsDir)zlib;%(AdditionalIncludeDirectories) $(ExternalsDir)zstd\lib;%(AdditionalIncludeDirectories) FMT_HEADER_ONLY=1;%(PreprocessorDefinitions) - _CRT_SECURE_NO_WARNINGS;_CRT_SECURE_NO_DEPRECATE;%(PreprocessorDefinitions) + + _CRT_SECURE_NO_WARNINGS;_CRT_NONSTDC_NO_WARNINGS;%(PreprocessorDefinitions) + + _WINSOCK_DEPRECATED_NO_WARNINGS;%(PreprocessorDefinitions) + + _SILENCE_CXX17_CODECVT_HEADER_DEPRECATION_WARNING;%(PreprocessorDefinitions) USE_UPNP;USE_USBDK;__LIBUSB__;%(PreprocessorDefinitions) SFML_STATIC;%(PreprocessorDefinitions) USE_ANALYTICS=1;%(PreprocessorDefinitions) @@ -73,26 +77,20 @@ true false false + true true stdcpplatest true - - /Zc:throwingNew /volatile:iso %(AdditionalOptions) + + /Zc:externConstexpr,lambda,preprocessor,throwingNew /volatile:iso %(AdditionalOptions) /Zo %(AdditionalOptions) /utf-8 %(AdditionalOptions) OldStyle Caret - - 4996;4351;%(DisableSpecificWarnings) 4245;%(DisableSpecificWarnings) + + 5105;%(DisableSpecificWarnings) /w44263 /w44265 /w44946 %(AdditionalOptions) + /Brepro %(AdditionalOptions) + + /experimental:deterministic %(AdditionalOptions) - true _DEBUG;_SECURE_SCL=1;%(PreprocessorDefinitions) MultiThreadedDebugDLL Disabled - true AnySuitable Speed true true MultiThreadedDLL false - false _SECURE_SCL=0;%(PreprocessorDefinitions) + /Gw %(AdditionalOptions) + true true true + /Brepro %(AdditionalOptions) @@ -151,11 +160,12 @@ enableCompatPatches - /NODEFAULTLIB:libcmt /Brepro %(AdditionalOptions) + /NODEFAULTLIB:libcmt %(AdditionalOptions) true true + /Brepro %(AdditionalOptions) + x64 true