From 69fcf277991b02716f680b663b967332f9aa23ce Mon Sep 17 00:00:00 2001 From: "Dr. Dystopia" Date: Mon, 19 Aug 2024 11:12:39 +0200 Subject: [PATCH] Join declarations and assignments --- Source/Core/Common/Timer.cpp | 4 +- Source/Core/Core/ARDecrypt.cpp | 16 ++--- Source/Core/Core/DSP/DSPAssembler.cpp | 4 +- Source/Core/Core/HW/DSPHLE/UCodes/Zelda.cpp | 4 +- Source/Core/Core/HW/EXI/BBA/BuiltIn.cpp | 3 +- Source/Core/Core/HW/EXI/BBA/TAP_Win32.cpp | 8 +-- Source/Core/Core/HW/EXI/EXI_DeviceAGP.cpp | 3 +- Source/Core/Core/HW/GCMemcard/GCMemcard.cpp | 12 ++-- Source/Core/Core/HW/WiimoteReal/IOWin.cpp | 3 +- Source/Core/Core/IOS/Network/IP/Top.cpp | 4 +- .../Core/Core/IOS/USB/Emulated/Infinity.cpp | 3 +- Source/Core/Core/NetPlayClient.cpp | 3 +- Source/Core/Core/PowerPC/GDBStub.cpp | 59 +++++++------------ .../Core/DolphinQt/Debugger/MemoryWidget.cpp | 3 +- Source/Core/DolphinQt/RenderWidget.cpp | 3 +- .../SkylanderPortal/SkylanderPortalWindow.cpp | 9 ++- .../Core/VideoBackends/D3D/D3DBoundingBox.cpp | 3 +- .../Core/VideoBackends/Vulkan/VKSwapChain.cpp | 5 +- .../Core/VideoBackends/Vulkan/VKTexture.cpp | 5 +- .../VideoCommon/TextureDecoder_Common.cpp | 9 ++- .../Core/VideoCommon/TextureDecoder_x64.cpp | 18 +++--- .../Core/VideoCommon/VertexLoader_Color.cpp | 8 +-- Source/UnitTests/Common/BitSetTest.cpp | 4 +- .../UnitTests/Core/IOS/FS/FileSystemTest.cpp | 4 +- 24 files changed, 76 insertions(+), 121 deletions(-) diff --git a/Source/Core/Common/Timer.cpp b/Source/Core/Common/Timer.cpp index 91381eebd3..93d6e7c503 100644 --- a/Source/Core/Common/Timer.cpp +++ b/Source/Core/Common/Timer.cpp @@ -72,7 +72,7 @@ u64 Timer::GetLocalTimeSinceJan1970() // std::chrono::current_zone() until 19H1, and other compilers don't even provide support for // timezone-related parts of chrono. Someday! // see https://bugs.dolphin-emu.org/issues/13007#note-4 - time_t sysTime, tzDiff, tzDST; + time_t sysTime, tzDST; time(&sysTime); tm* gmTime = localtime(&sysTime); @@ -84,7 +84,7 @@ u64 Timer::GetLocalTimeSinceJan1970() // Lazy way to get local time in sec gmTime = gmtime(&sysTime); - tzDiff = sysTime - mktime(gmTime); + time_t tzDiff = sysTime - mktime(gmTime); return static_cast(sysTime + tzDiff + tzDST); } diff --git a/Source/Core/Core/ARDecrypt.cpp b/Source/Core/Core/ARDecrypt.cpp index 46ca74d159..ed695ceb82 100644 --- a/Source/Core/Core/ARDecrypt.cpp +++ b/Source/Core/Core/ARDecrypt.cpp @@ -247,11 +247,9 @@ static u8 verifycode(const u32* codes, u16 size) static void unscramble1(u32* addr, u32* val) { - u32 tmp; - *val = std::rotl(*val, 4); - tmp = ((*addr ^ *val) & 0xF0F0F0F0); + u32 tmp = ((*addr ^ *val) & 0xF0F0F0F0); *addr ^= tmp; *val = std::rotr((*val ^ tmp), 0x14); @@ -274,11 +272,9 @@ static void unscramble1(u32* addr, u32* val) static void unscramble2(u32* addr, u32* val) { - u32 tmp; - *val = std::rotr(*val, 1); - tmp = ((*addr ^ *val) & 0xAAAAAAAA); + u32 tmp = ((*addr ^ *val) & 0xAAAAAAAA); *val ^= tmp; *addr = std::rotr((*addr ^ tmp), 9); @@ -302,15 +298,14 @@ static void unscramble2(u32* addr, u32* val) static void decryptcode(const u32* seeds, u32* code) { u32 addr, val; - u32 tmp, tmp2; int i = 0; getcode(code, &addr, &val); unscramble1(&addr, &val); while (i < 32) { - tmp = (std::rotr(val, 4) ^ seeds[i++]); - tmp2 = (val ^ seeds[i++]); + u32 tmp = (std::rotr(val, 4) ^ seeds[i++]); + u32 tmp2 = (val ^ seeds[i++]); addr ^= (table6[tmp & 0x3F] ^ table4[(tmp >> 8) & 0x3F] ^ table2[(tmp >> 16) & 0x3F] ^ table0[(tmp >> 24) & 0x3F] ^ table7[tmp2 & 0x3F] ^ table5[(tmp2 >> 8) & 0x3F] ^ table3[(tmp2 >> 16) & 0x3F] ^ table1[(tmp2 >> 24) & 0x3F]); @@ -417,7 +412,6 @@ static int alphatobin(u32* dst, const std::vector& alpha, int size) int ret = 0; int org = size + 1; u32 bin[2]; - u8 parity; for (; size; --size) { @@ -439,7 +433,7 @@ static int alphatobin(u32* dst, const std::vector& alpha, int size) // verify parity bit int k = 0; - parity = 0; + u8 parity = 0; for (int i = 0; i < 64; i++) { if (i == 32) diff --git a/Source/Core/Core/DSP/DSPAssembler.cpp b/Source/Core/Core/DSP/DSPAssembler.cpp index cb42085fb9..5cff9f7762 100644 --- a/Source/Core/Core/DSP/DSPAssembler.cpp +++ b/Source/Core/Core/DSP/DSPAssembler.cpp @@ -276,9 +276,7 @@ char* DSPAssembler::FindBrackets(char* src, char* dst) s32 len = (s32)strlen(src); s32 first = -1; s32 count = 0; - s32 i, j; - j = 0; - for (i = 0; i < len; i++) + for (s32 i = 0, j = 0; i < len; i++) { if (src[i] == '(') { diff --git a/Source/Core/Core/HW/DSPHLE/UCodes/Zelda.cpp b/Source/Core/Core/HW/DSPHLE/UCodes/Zelda.cpp index c540dc2461..f8812e2a1b 100644 --- a/Source/Core/Core/HW/DSPHLE/UCodes/Zelda.cpp +++ b/Source/Core/Core/HW/DSPHLE/UCodes/Zelda.cpp @@ -1034,10 +1034,10 @@ void ZeldaAudioRenderer::PrepareFrame() // Prepare patterns 2/3 - they are not constant unlike 0/1. s16* pattern2 = m_const_patterns.data() + 2 * 0x40; - s32 yn2 = pattern2[0x40 - 2], yn1 = pattern2[0x40 - 1], v; + s32 yn2 = pattern2[0x40 - 2], yn1 = pattern2[0x40 - 1]; for (int i = 0; i < 0x40; i += 2) { - v = yn2 * yn1 - (pattern2[i] << 16); + s32 v = yn2 * yn1 - (pattern2[i] << 16); yn2 = yn1; yn1 = pattern2[i]; pattern2[i] = v >> 16; diff --git a/Source/Core/Core/HW/EXI/BBA/BuiltIn.cpp b/Source/Core/Core/HW/EXI/BBA/BuiltIn.cpp index 86d3f89420..b655c68fc1 100644 --- a/Source/Core/Core/HW/EXI/BBA/BuiltIn.cpp +++ b/Source/Core/Core/HW/EXI/BBA/BuiltIn.cpp @@ -341,7 +341,6 @@ CEXIETHERNET::BuiltInBBAInterface::TryGetDataFromSocket(StackRef* ref) void CEXIETHERNET::BuiltInBBAInterface::HandleTCPFrame(const Common::TCPPacket& packet) { const auto& [hwdata, ip_header, tcp_header, ip_options, tcp_options, data] = packet; - sf::IpAddress target; StackRef* ref = m_network_ref.GetTCPSlot(tcp_header.source_port, tcp_header.destination_port, std::bit_cast(ip_header.destination_addr)); const u16 flags = ntohs(tcp_header.properties) & 0xfff; @@ -395,7 +394,7 @@ void CEXIETHERNET::BuiltInBBAInterface::HandleTCPFrame(const Common::TCPPacket& ref->ready = false; ref->ip = std::bit_cast(ip_header.destination_addr); - target = sf::IpAddress(ntohl(destination_ip)); + sf::IpAddress target = sf::IpAddress(ntohl(destination_ip)); ref->tcp_socket.Connect(target, ntohs(tcp_header.destination_port), m_current_ip); } else diff --git a/Source/Core/Core/HW/EXI/BBA/TAP_Win32.cpp b/Source/Core/Core/HW/EXI/BBA/TAP_Win32.cpp index bbfdfa19de..f91537ccf8 100644 --- a/Source/Core/Core/HW/EXI/BBA/TAP_Win32.cpp +++ b/Source/Core/Core/HW/EXI/BBA/TAP_Win32.cpp @@ -15,11 +15,10 @@ namespace Win32TAPHelper bool IsTAPDevice(const TCHAR* guid) { HKEY netcard_key; - LONG status; DWORD len; int i = 0; - status = RegOpenKeyEx(HKEY_LOCAL_MACHINE, ADAPTER_KEY, 0, KEY_READ, &netcard_key); + LONG status = RegOpenKeyEx(HKEY_LOCAL_MACHINE, ADAPTER_KEY, 0, KEY_READ, &netcard_key); if (status != ERROR_SUCCESS) return false; @@ -90,13 +89,12 @@ bool IsTAPDevice(const TCHAR* guid) bool GetGUIDs(std::vector>& guids) { - LONG status; HKEY control_net_key; DWORD len; DWORD cSubKeys = 0; - status = RegOpenKeyEx(HKEY_LOCAL_MACHINE, NETWORK_CONNECTIONS_KEY, 0, KEY_READ | KEY_QUERY_VALUE, - &control_net_key); + LONG status = RegOpenKeyEx(HKEY_LOCAL_MACHINE, NETWORK_CONNECTIONS_KEY, 0, + KEY_READ | KEY_QUERY_VALUE, &control_net_key); if (status != ERROR_SUCCESS) return false; diff --git a/Source/Core/Core/HW/EXI/EXI_DeviceAGP.cpp b/Source/Core/Core/HW/EXI/EXI_DeviceAGP.cpp index f035003cf0..c508e7b92c 100644 --- a/Source/Core/Core/HW/EXI/EXI_DeviceAGP.cpp +++ b/Source/Core/Core/HW/EXI/EXI_DeviceAGP.cpp @@ -37,9 +37,8 @@ CEXIAgp::~CEXIAgp() std::string path; std::string filename; std::string ext; - std::string gbapath; SplitPath(Config::Get(Config::GetInfoForAGPCartPath(m_slot)), &path, &filename, &ext); - gbapath = path + filename; + std::string gbapath = path + filename; SaveFileFromEEPROM(gbapath + ".sav"); } diff --git a/Source/Core/Core/HW/GCMemcard/GCMemcard.cpp b/Source/Core/Core/HW/GCMemcard/GCMemcard.cpp index d603e1075e..0935d3bd2d 100644 --- a/Source/Core/Core/HW/GCMemcard/GCMemcard.cpp +++ b/Source/Core/Core/HW/GCMemcard/GCMemcard.cpp @@ -1068,7 +1068,6 @@ bool GCMemcard::Format(const CardFlashId& flash_id, u16 size_mbits, bool shift_j s32 GCMemcard::FZEROGX_MakeSaveGameValid(const Header& cardheader, const DEntry& direntry, std::vector& FileBuffer) { - u32 i, j; u16 chksum = 0xFFFF; // check for F-Zero GX system file @@ -1089,12 +1088,12 @@ s32 GCMemcard::FZEROGX_MakeSaveGameValid(const Header& cardheader, const DEntry& *(u16*)&FileBuffer[1].m_block[0x0200] = Common::swap16(u16(Common::swap32(serial2) & 0xFFFF)); // calc 16-bit checksum - for (i = 0x02; i < 0x8000; i++) + for (u32 i = 0x02; i < 0x8000; i++) { const int block = i / 0x2000; const int offset = i % 0x2000; chksum ^= (FileBuffer[block].m_block[offset] & 0xFF); - for (j = 8; j > 0; j--) + for (u32 j = 8; j > 0; j--) { if (chksum & 1) chksum = (chksum >> 1) ^ 0x8408; @@ -1123,7 +1122,6 @@ s32 GCMemcard::FZEROGX_MakeSaveGameValid(const Header& cardheader, const DEntry& s32 GCMemcard::PSO_MakeSaveGameValid(const Header& cardheader, const DEntry& direntry, std::vector& FileBuffer) { - u32 i, j; u32 chksum; u32 crc32LUT[256]; u32 pso3offset = 0x00; @@ -1152,10 +1150,10 @@ s32 GCMemcard::PSO_MakeSaveGameValid(const Header& cardheader, const DEntry& dir *(u32*)&FileBuffer[1].m_block[0x015C] = serial2; // generate crc32 LUT - for (i = 0; i < 256; i++) + for (u32 i = 0; i < 256; i++) { chksum = i; - for (j = 8; j > 0; j--) + for (u32 j = 8; j > 0; j--) { if (chksum & 1) chksum = (chksum >> 1) ^ 0xEDB88320; @@ -1170,7 +1168,7 @@ s32 GCMemcard::PSO_MakeSaveGameValid(const Header& cardheader, const DEntry& dir chksum = 0xDEBB20E3; // calc 32-bit checksum - for (i = 0x004C; i < 0x0164 + pso3offset; i++) + for (u32 i = 0x004C; i < 0x0164 + pso3offset; i++) { chksum = ((chksum >> 8) & 0xFFFFFF) ^ crc32LUT[(chksum ^ FileBuffer[1].m_block[i]) & 0xFF]; } diff --git a/Source/Core/Core/HW/WiimoteReal/IOWin.cpp b/Source/Core/Core/HW/WiimoteReal/IOWin.cpp index f931bb10a3..a4050d018f 100644 --- a/Source/Core/Core/HW/WiimoteReal/IOWin.cpp +++ b/Source/Core/Core/HW/WiimoteReal/IOWin.cpp @@ -345,10 +345,9 @@ bool GetParentDevice(const DEVINST& child_device_instance, HDEVINFO* parent_devi { ULONG status; ULONG problem_number; - CONFIGRET result; // Check if that device instance has device node present - result = CM_Get_DevNode_Status(&status, &problem_number, child_device_instance, 0); + CONFIGRET result = CM_Get_DevNode_Status(&status, &problem_number, child_device_instance, 0); if (result != CR_SUCCESS) { return false; diff --git a/Source/Core/Core/IOS/Network/IP/Top.cpp b/Source/Core/Core/IOS/Network/IP/Top.cpp index 2c078779b9..9405031887 100644 --- a/Source/Core/Core/IOS/Network/IP/Top.cpp +++ b/Source/Core/Core/IOS/Network/IP/Top.cpp @@ -867,8 +867,8 @@ IPCReply NetIPTopDevice::HandleGetInterfaceOptRequest(const IOCtlVRequest& reque { PIP_ADAPTER_ADDRESSES AdapterAddresses = nullptr; ULONG OutBufferLength = 0; - ULONG RetVal = 0, i; - for (i = 0; i < 5; ++i) + ULONG RetVal = 0; + for (int i = 0; i < 5; ++i) { RetVal = GetAdaptersAddresses(AF_INET, 0, nullptr, AdapterAddresses, &OutBufferLength); diff --git a/Source/Core/Core/IOS/USB/Emulated/Infinity.cpp b/Source/Core/Core/IOS/USB/Emulated/Infinity.cpp index 34a2f40698..de187c368a 100644 --- a/Source/Core/Core/IOS/USB/Emulated/Infinity.cpp +++ b/Source/Core/Core/IOS/USB/Emulated/Infinity.cpp @@ -597,7 +597,6 @@ InfinityBase::LoadFigure(const std::array sha1_calc = {SHA1_CONSTANT.begin(), SHA1_CONSTANT.end() - 1}; for (int i = 0; i < 7; i++) @@ -625,7 +624,7 @@ InfinityBase::LoadFigure(const std::array> (28 - 4 * i)); } static void wbe64hex(u8* p, u64 v) { - u32 i; - for (i = 0; i < 16; i++) + for (u32 i = 0; i < 16; i++) p[i] = Nibble2hex(v >> (60 - 4 * i)); } static u32 re32hex(u8* p) { - u32 i; u32 res = 0; - for (i = 0; i < 8; i++) + for (u32 i = 0; i < 8; i++) res = (res << 4) | Hex2char(p[i]); return res; @@ -389,10 +386,9 @@ static u32 re32hex(u8* p) static u64 re64hex(u8* p) { - u32 i; u64 res = 0; - for (i = 0; i < 16; i++) + for (u32 i = 0; i < 16; i++) res = (res << 4) | Hex2char(p[i]); return res; @@ -404,10 +400,9 @@ static void ReadRegister() auto& ppc_state = system.GetPPCState(); static u8 reply[64]; - u32 id; memset(reply, 0, sizeof reply); - id = Hex2char(s_cmd_bfr[1]); + u32 id = Hex2char(s_cmd_bfr[1]); if (s_cmd_bfr[2] != '\0') { id <<= 4; @@ -588,11 +583,10 @@ static void ReadRegisters() static u8 bfr[GDB_BFR_MAX - 4]; u8* bufptr = bfr; - u32 i; memset(bfr, 0, sizeof bfr); - for (i = 0; i < 32; i++) + for (u32 i = 0; i < 32; i++) { wbe32hex(bufptr + i * 8, ppc_state.gpr[i]); } @@ -606,10 +600,9 @@ static void WriteRegisters() auto& system = Core::System::GetInstance(); auto& ppc_state = system.GetPPCState(); - u32 i; u8* bufptr = s_cmd_bfr; - for (i = 0; i < 32; i++) + for (u32 i = 0; i < 32; i++) { ppc_state.gpr[i] = re32hex(bufptr + i * 8); } @@ -623,11 +616,9 @@ static void WriteRegister() auto& system = Core::System::GetInstance(); auto& ppc_state = system.GetPPCState(); - u32 id; - u8* bufptr = s_cmd_bfr + 3; - id = Hex2char(s_cmd_bfr[1]); + u32 id = Hex2char(s_cmd_bfr[1]); if (s_cmd_bfr[2] != '=') { ++bufptr; @@ -808,16 +799,14 @@ static void WriteRegister() static void ReadMemory(const Core::CPUThreadGuard& guard) { static u8 reply[GDB_BFR_MAX - 4]; - u32 addr, len; - u32 i; - i = 1; - addr = 0; + u32 i = 1; + u32 addr = 0; while (s_cmd_bfr[i] != ',') addr = (addr << 4) | Hex2char(s_cmd_bfr[i++]); i++; - len = 0; + u32 len = 0; while (i < s_cmd_len) len = (len << 4) | Hex2char(s_cmd_bfr[i++]); INFO_LOG_FMT(GDB_STUB, "gdb: read memory: {:08x} bytes from {:08x}", len, addr); @@ -838,16 +827,13 @@ static void ReadMemory(const Core::CPUThreadGuard& guard) static void WriteMemory(const Core::CPUThreadGuard& guard) { - u32 addr, len; - u32 i; - - i = 1; - addr = 0; + u32 i = 1; + u32 addr = 0; while (s_cmd_bfr[i] != ',') addr = (addr << 4) | Hex2char(s_cmd_bfr[i++]); i++; - len = 0; + u32 len = 0; while (s_cmd_bfr[i] != ':') len = (len << 4) | Hex2char(s_cmd_bfr[i++]); INFO_LOG_FMT(GDB_STUB, "gdb: write memory: {:08x} bytes to {:08x}", len, addr); @@ -901,14 +887,13 @@ static bool AddBreakpoint(BreakpointType type, u32 addr, u32 len) static void HandleAddBreakpoint() { - u32 type; - u32 i, addr = 0, len = 0; + u32 addr = 0, len = 0; - type = Hex2char(s_cmd_bfr[1]); + u32 type = Hex2char(s_cmd_bfr[1]); if (type > NUM_BREAKPOINT_TYPES) return SendReply("E01"); - i = 3; + u32 i = 3; while (s_cmd_bfr[i] != ',') addr = addr << 4 | Hex2char(s_cmd_bfr[i++]); i++; @@ -923,16 +908,14 @@ static void HandleAddBreakpoint() static void HandleRemoveBreakpoint() { - u32 type, addr, len, i; - - type = Hex2char(s_cmd_bfr[1]); + u32 type = Hex2char(s_cmd_bfr[1]); if (type > NUM_BREAKPOINT_TYPES) return SendReply("E01"); - addr = 0; - len = 0; + u32 addr = 0; + u32 len = 0; - i = 3; + u32 i = 3; while (s_cmd_bfr[i] != ',') addr = (addr << 4) | Hex2char(s_cmd_bfr[i++]); i++; diff --git a/Source/Core/DolphinQt/Debugger/MemoryWidget.cpp b/Source/Core/DolphinQt/Debugger/MemoryWidget.cpp index f5faea68be..fd81ccbee3 100644 --- a/Source/Core/DolphinQt/Debugger/MemoryWidget.cpp +++ b/Source/Core/DolphinQt/Debugger/MemoryWidget.cpp @@ -576,13 +576,12 @@ void MemoryWidget::ValidateAndPreviewInputValue() if (!bytes.empty()) { - QString hex_string; std::string s; for (const u8 c : bytes) s.append(fmt::format("{:02x}", c)); - hex_string = QString::fromStdString(s); + QString hex_string = QString::fromStdString(s); int output_length = hex_string.length(); if (output_length > 16) diff --git a/Source/Core/DolphinQt/RenderWidget.cpp b/Source/Core/DolphinQt/RenderWidget.cpp index d88a17e3d3..4f0c399ed2 100644 --- a/Source/Core/DolphinQt/RenderWidget.cpp +++ b/Source/Core/DolphinQt/RenderWidget.cpp @@ -530,11 +530,10 @@ void RenderWidget::PassEventToPresenter(const QEvent* event) const u32 key = static_cast(key_event->key() & 0x1FF); const char* chars = nullptr; - QByteArray utf8; if (is_down) { - utf8 = key_event->text().toUtf8(); + QByteArray utf8 = key_event->text().toUtf8(); if (utf8.size()) chars = utf8.constData(); diff --git a/Source/Core/DolphinQt/SkylanderPortal/SkylanderPortalWindow.cpp b/Source/Core/DolphinQt/SkylanderPortal/SkylanderPortalWindow.cpp index f8b29a5674..b4fd56fb39 100644 --- a/Source/Core/DolphinQt/SkylanderPortal/SkylanderPortalWindow.cpp +++ b/Source/Core/DolphinQt/SkylanderPortal/SkylanderPortalWindow.cpp @@ -516,11 +516,10 @@ void SkylanderPortalWindow::LoadSelected() if (file_path.isEmpty()) { - QMessageBox::StandardButton create_file_response; - create_file_response = - QMessageBox::question(this, tr("Create Skylander File"), - tr("Skylander not found in this collection. Create new file?"), - QMessageBox::Yes | QMessageBox::No); + QMessageBox::StandardButton create_file_response = QMessageBox::question( + this, tr("Create Skylander File"), + tr("Skylander not found in this collection. Create new file?"), + QMessageBox::Yes | QMessageBox::No); if (create_file_response == QMessageBox::Yes) { diff --git a/Source/Core/VideoBackends/D3D/D3DBoundingBox.cpp b/Source/Core/VideoBackends/D3D/D3DBoundingBox.cpp index 8cab19ac95..5ecdbf1620 100644 --- a/Source/Core/VideoBackends/D3D/D3DBoundingBox.cpp +++ b/Source/Core/VideoBackends/D3D/D3DBoundingBox.cpp @@ -34,8 +34,7 @@ bool D3DBoundingBox::Initialize() data.pSysMem = initial_values; data.SysMemPitch = NUM_BBOX_VALUES * sizeof(BBoxType); data.SysMemSlicePitch = 0; - HRESULT hr; - hr = D3D::device->CreateBuffer(&desc, &data, &m_buffer); + HRESULT hr = D3D::device->CreateBuffer(&desc, &data, &m_buffer); ASSERT_MSG(VIDEO, SUCCEEDED(hr), "Failed to create BoundingBox Buffer: {}", DX11HRWrap(hr)); if (FAILED(hr)) return false; diff --git a/Source/Core/VideoBackends/Vulkan/VKSwapChain.cpp b/Source/Core/VideoBackends/Vulkan/VKSwapChain.cpp index 58e2e439e8..5f2a4a661f 100644 --- a/Source/Core/VideoBackends/Vulkan/VKSwapChain.cpp +++ b/Source/Core/VideoBackends/Vulkan/VKSwapChain.cpp @@ -226,10 +226,9 @@ bool SwapChain::SelectSurfaceFormat() bool SwapChain::SelectPresentMode() { - VkResult res; u32 mode_count; - res = vkGetPhysicalDeviceSurfacePresentModesKHR(g_vulkan_context->GetPhysicalDevice(), m_surface, - &mode_count, nullptr); + VkResult res = vkGetPhysicalDeviceSurfacePresentModesKHR(g_vulkan_context->GetPhysicalDevice(), m_surface, + &mode_count, nullptr); if (res != VK_SUCCESS || mode_count == 0) { LOG_VULKAN_ERROR(res, "vkGetPhysicalDeviceSurfaceFormatsKHR failed: "); diff --git a/Source/Core/VideoBackends/Vulkan/VKTexture.cpp b/Source/Core/VideoBackends/Vulkan/VKTexture.cpp index 6756305d1e..789b7da005 100644 --- a/Source/Core/VideoBackends/Vulkan/VKTexture.cpp +++ b/Source/Core/VideoBackends/Vulkan/VKTexture.cpp @@ -381,7 +381,6 @@ void VKTexture::Load(u32 level, u32 width, u32 height, u32 row_length, const u8* const u32 num_rows = Common::AlignUp(height, block_size) / block_size; const u32 source_pitch = CalculateStrideForFormat(m_config.format, row_length); const u32 upload_size = source_pitch * num_rows; - std::unique_ptr temp_buffer; VkBuffer upload_buffer; VkDeviceSize upload_buffer_offset; @@ -409,8 +408,8 @@ void VKTexture::Load(u32 level, u32 width, u32 height, u32 row_length, const u8* else { // Create a temporary staging buffer that is destroyed after the image is copied. - temp_buffer = StagingBuffer::Create(STAGING_BUFFER_TYPE_UPLOAD, upload_size, - VK_BUFFER_USAGE_TRANSFER_SRC_BIT); + std::unique_ptr temp_buffer = StagingBuffer::Create( + STAGING_BUFFER_TYPE_UPLOAD, upload_size, VK_BUFFER_USAGE_TRANSFER_SRC_BIT); if (!temp_buffer || !temp_buffer->Map()) { PanicAlertFmt("Failed to allocate staging texture for large texture upload."); diff --git a/Source/Core/VideoCommon/TextureDecoder_Common.cpp b/Source/Core/VideoCommon/TextureDecoder_Common.cpp index 299a36e4d4..2f71fa0794 100644 --- a/Source/Core/VideoCommon/TextureDecoder_Common.cpp +++ b/Source/Core/VideoCommon/TextureDecoder_Common.cpp @@ -316,11 +316,10 @@ static inline u32 DecodePixel_IA8(u16 val) static inline u32 DecodePixel_RGB565(u16 val) { - int r, g, b, a; - r = Convert5To8((val >> 11) & 0x1f); - g = Convert6To8((val >> 5) & 0x3f); - b = Convert5To8((val)&0x1f); - a = 0xFF; + int r = Convert5To8((val >> 11) & 0x1f); + int g = Convert6To8((val >> 5) & 0x3f); + int b = Convert5To8((val) & 0x1f); + int a = 0xFF; return r | (g << 8) | (b << 16) | (a << 24); } diff --git a/Source/Core/VideoCommon/TextureDecoder_x64.cpp b/Source/Core/VideoCommon/TextureDecoder_x64.cpp index 85a6e5e731..905ee32a55 100644 --- a/Source/Core/VideoCommon/TextureDecoder_x64.cpp +++ b/Source/Core/VideoCommon/TextureDecoder_x64.cpp @@ -34,11 +34,10 @@ static inline u32 DecodePixel_IA8(u16 val) static inline u32 DecodePixel_RGB565(u16 val) { - int r, g, b, a; - r = Convert5To8((val >> 11) & 0x1f); - g = Convert6To8((val >> 5) & 0x3f); - b = Convert5To8((val)&0x1f); - a = 0xFF; + int r = Convert5To8((val >> 11) & 0x1f); + int g = Convert6To8((val >> 5) & 0x3f); + int b = Convert5To8((val) & 0x1f); + int a = 0xFF; return r | (g << 8) | (b << 16) | (a << 24); } @@ -410,14 +409,13 @@ static void TexDecoder_DecodeImpl_I8_SSSE3(u32* dst, const u8* src, int width, i const __m128i mask3210 = _mm_set_epi8(3, 3, 3, 3, 2, 2, 2, 2, 1, 1, 1, 1, 0, 0, 0, 0); const __m128i mask7654 = _mm_set_epi8(7, 7, 7, 7, 6, 6, 6, 6, 5, 5, 5, 5, 4, 4, 4, 4); - __m128i *quaddst, r, rgba0, rgba1; // Load 64 bits from `src` into an __m128i with upper 64 bits zeroed: (0000 0000 hgfe dcba) - r = _mm_loadl_epi64((const __m128i*)(src + 8 * xStep)); + __m128i r = _mm_loadl_epi64((const __m128i*)(src + 8 * xStep)); // Shuffle select bytes to expand from (0000 0000 hgfe dcba) to: - rgba0 = _mm_shuffle_epi8(r, mask3210); // (dddd cccc bbbb aaaa) - rgba1 = _mm_shuffle_epi8(r, mask7654); // (hhhh gggg ffff eeee) + __m128i rgba0 = _mm_shuffle_epi8(r, mask3210); // (dddd cccc bbbb aaaa) + __m128i rgba1 = _mm_shuffle_epi8(r, mask7654); // (hhhh gggg ffff eeee) - quaddst = (__m128i*)(dst + (y + iy) * width + x); + __m128i* quaddst = (__m128i*)(dst + (y + iy) * width + x); _mm_storeu_si128(quaddst, rgba0); _mm_storeu_si128(quaddst + 1, rgba1); } diff --git a/Source/Core/VideoCommon/VertexLoader_Color.cpp b/Source/Core/VideoCommon/VertexLoader_Color.cpp index 87cd19063a..556b3d9ab0 100644 --- a/Source/Core/VideoCommon/VertexLoader_Color.cpp +++ b/Source/Core/VideoCommon/VertexLoader_Color.cpp @@ -33,8 +33,8 @@ void SetCol(VertexLoader* loader, u32 val) // BARG -> AABBGGRR void SetCol4444(VertexLoader* loader, u16 val_) { - u32 col, val = val_; - col = val & 0x00F0; // col = 000000R0; + u32 val = val_; + u32 col = val & 0x00F0; // col = 000000R0; col |= (val & 0x000F) << 12; // col |= 0000G000; col |= (val & 0xF000) << 8; // col |= 00B00000; col |= (val & 0x0F00) << 20; // col |= A0000000; @@ -58,8 +58,8 @@ void SetCol6666(VertexLoader* loader, u32 val) // RRRRRGGG GGGBBBBB void SetCol565(VertexLoader* loader, u16 val_) { - u32 col, val = val_; - col = (val >> 8) & 0x0000F8; + u32 val = val_; + u32 col = (val >> 8) & 0x0000F8; col |= (val << 5) & 0x00FC00; col |= (val << 19) & 0xF80000; col |= (col >> 5) & 0x070007; diff --git a/Source/UnitTests/Common/BitSetTest.cpp b/Source/UnitTests/Common/BitSetTest.cpp index 397f9fecbe..dd4f6b4c9b 100644 --- a/Source/UnitTests/Common/BitSetTest.cpp +++ b/Source/UnitTests/Common/BitSetTest.cpp @@ -70,12 +70,12 @@ TEST(BitSet, Count) TEST(BitSet, BitOps) { - BitSet32 a(3), b(5), c; + BitSet32 a(3), b(5); EXPECT_EQ(BitSet32(7), a | b); EXPECT_EQ(BitSet32(6), a ^ b); EXPECT_EQ(BitSet32(1), a & b); EXPECT_EQ(BitSet32(0xfffffffc), ~a); - c = a; + BitSet32 c = a; c |= b; EXPECT_EQ(BitSet32(7), c); c = a; diff --git a/Source/UnitTests/Core/IOS/FS/FileSystemTest.cpp b/Source/UnitTests/Core/IOS/FS/FileSystemTest.cpp index b1e6997e34..865f1e7c25 100644 --- a/Source/UnitTests/Core/IOS/FS/FileSystemTest.cpp +++ b/Source/UnitTests/Core/IOS/FS/FileSystemTest.cpp @@ -76,9 +76,7 @@ TEST(FileSystem, BasicPathValidity) TEST(FileSystem, PathSplitting) { - SplitPathResult result; - - result = {"/shared1", "00000042.app"}; + SplitPathResult result = {"/shared1", "00000042.app"}; EXPECT_EQ(SplitPathAndBasename("/shared1/00000042.app"), result); result = {"/shared2/sys", "SYSCONF"};