Move variables to inner scope

This commit is contained in:
Dr. Dystopia 2024-08-20 12:21:46 +02:00
parent 4ff5ff2772
commit 4ae6842ccc
116 changed files with 200 additions and 351 deletions

View File

@ -161,9 +161,7 @@ bool SupportsVolumeChanges(std::string_view backend)
void UpdateSoundStream(Core::System& system)
{
SoundStream* sound_stream = system.GetSoundStream();
if (sound_stream)
if (SoundStream* sound_stream = system.GetSoundStream())
{
int volume = Config::Get(Config::MAIN_AUDIO_MUTED) ? 0 : Config::Get(Config::MAIN_AUDIO_VOLUME);
sound_stream->SetVolume(volume);

View File

@ -620,9 +620,7 @@ TokenType Lexer::LexStringLit(std::string_view& invalid_reason, Interval& invali
const size_t string_start = m_scan_pos.index - 1;
TokenType token_type = TokenType::StringLit;
std::optional<std::string_view> failure_reason = RunDfa(string_dfa);
if (failure_reason)
if (std::optional<std::string_view> failure_reason = RunDfa(string_dfa))
{
token_type = TokenType::Invalid;
invalid_reason = *failure_reason;

View File

@ -18,8 +18,6 @@ static const int s_lut3to8[] = {0x00, 0x24, 0x48, 0x6D, 0x91, 0xB6, 0xDA, 0xFF};
static u32 Decode5A3(u16 val)
{
const u32 bg_color = 0x00000000;
int r, g, b, a;
if (val & 0x8000)
@ -31,6 +29,7 @@ static u32 Decode5A3(u16 val)
}
else
{
const u32 bg_color = 0x00000000;
a = s_lut3to8[(val >> 12) & 0x7];
r = (s_lut4to8[(val >> 8) & 0xf] * a + (bg_color & 0xFF) * (255 - a)) / 255;
g = (s_lut4to8[(val >> 4) & 0xf] * a + ((bg_color >> 8) & 0xFF) * (255 - a)) / 255;

View File

@ -71,14 +71,13 @@ void bn_mul(u8* d, const u8* a, const u8* b, const u8* N, const size_t n)
void bn_exp(u8* d, const u8* a, const u8* N, const size_t n, const u8* e, const size_t en)
{
u8 t[512];
bn_zero(d, n);
d[n - 1] = 1;
for (size_t i = 0; i < en; i++)
{
for (u8 mask = 0x80; mask != 0; mask >>= 1)
{
u8 t[512];
bn_mul(t, d, d, N, n);
if ((e[i] & mask) != 0)
bn_mul(d, t, a, N, n);

View File

@ -397,8 +397,7 @@ HGLRC GLContextWGL::CreateCoreContext(HDC dc, HGLRC share_context)
0};
// Attempt creating this context.
HGLRC core_context = wglCreateContextAttribsARB(dc, share_context, attribs.data());
if (core_context)
if (HGLRC core_context = wglCreateContextAttribsARB(dc, share_context, attribs.data()))
{
INFO_LOG_FMT(VIDEO, "WGL: Created a GL {}.{} core context", version.first, version.second);
return core_context;

View File

@ -97,14 +97,13 @@ GLuint CompileProgram(const std::string& vertexShader, const std::string& fragme
void EnablePrimitiveRestart(const GLContext* context)
{
constexpr GLuint PRIMITIVE_RESTART_INDEX = 65535;
if (context->IsGLES())
{
glEnable(GL_PRIMITIVE_RESTART_FIXED_INDEX);
}
else
{
constexpr GLuint PRIMITIVE_RESTART_INDEX = 65535;
if (GLExtensions::Version() >= 310)
{
glEnable(GL_PRIMITIVE_RESTART);

View File

@ -796,7 +796,6 @@ void GekkoDisassembler::mspr(u32 in, int smode)
{
int d = (int)PPCGETD(in);
int spr = (int)((PPCGETB(in) << 5) + PPCGETA(in));
int fmt = 0;
if (in & 1)
{
@ -804,6 +803,7 @@ void GekkoDisassembler::mspr(u32 in, int smode)
}
else
{
int fmt = 0;
const char* x;
switch (spr)
{

View File

@ -15,8 +15,6 @@ namespace Common
// Reads all of the current file. destination must be big enough to fit the whole file.
inline bool ReadFileFromZip(unzFile file, u8* destination, u64 len)
{
const u64 MAX_BUFFER_SIZE = 65535;
if (unzOpenCurrentFile(file) != UNZ_OK)
return false;
@ -25,6 +23,7 @@ inline bool ReadFileFromZip(unzFile file, u8* destination, u64 len)
u64 bytes_to_go = len;
while (bytes_to_go > 0)
{
const u64 MAX_BUFFER_SIZE = 65535;
// NOTE: multiples of 4G can't cause read_len == 0 && bytes_to_go > 0, as MAX_BUFFER_SIZE is
// small.
const u32 read_len = static_cast<u32>(std::min(bytes_to_go, MAX_BUFFER_SIZE));

View File

@ -92,9 +92,7 @@ private:
ElementPtr() : next(nullptr) {}
~ElementPtr()
{
ElementPtr* next_ptr = next.load();
if (next_ptr)
if (ElementPtr* next_ptr = next.load())
delete next_ptr;
}

View File

@ -175,8 +175,7 @@ u8* XEmitter::AlignCodeTo(size_t alignment)
{
ASSERT_MSG(DYNA_REC, alignment != 0 && (alignment & (alignment - 1)) == 0,
"Alignment must be power of two");
u64 c = reinterpret_cast<u64>(code) & (alignment - 1);
if (c)
if (u64 c = reinterpret_cast<u64>(code) & (alignment - 1))
ReserveCodeSpace(static_cast<int>(alignment - c));
return code;
}

View File

@ -20,7 +20,6 @@ void SetSIMDMode(RoundMode rounding_mode, bool non_ieee_mode)
// OR-mask for disabling FPU exceptions (bits 7-12 in the MXCSR register)
const u32 EXCEPTION_MASK = 0x1F80;
// Flush-To-Zero (non-IEEE mode: denormal outputs are set to +/- 0)
const u32 FTZ = 0x8000;
// lookup table for FPSCR.RN-to-MXCSR.RC translation
static const u32 simd_rounding_table[] = {
(0 << 13) | EXCEPTION_MASK, // nearest
@ -32,6 +31,7 @@ void SetSIMDMode(RoundMode rounding_mode, bool non_ieee_mode)
if (non_ieee_mode)
{
const u32 FTZ = 0x8000;
csr |= FTZ;
}
_mm_setcsr(csr);

View File

@ -466,8 +466,7 @@ void DecryptARCode(std::vector<std::string> vCodes, std::vector<AREntry>* ops)
Common::ToUpper(&s);
}
const u32 ret = alphatobin(uCodes.data(), vCodes, (int)vCodes.size());
if (ret)
if (const u32 ret = alphatobin(uCodes.data(), vCodes, (int)vCodes.size()))
{
// Return value is index + 1, 0 being the success flag value.
PanicAlertFmtT(

View File

@ -237,8 +237,7 @@ std::unique_ptr<BootParameters> BootParameters::GenerateFromFile(std::vector<std
{".gcm", ".iso", ".tgc", ".wbfs", ".ciso", ".gcz", ".wia", ".rvz", ".nfs", ".dol", ".elf"}};
if (disc_image_extensions.contains(extension))
{
std::unique_ptr<DiscIO::VolumeDisc> disc = DiscIO::CreateDisc(path);
if (disc)
if (std::unique_ptr<DiscIO::VolumeDisc> disc = DiscIO::CreateDisc(path))
{
return std::make_unique<BootParameters>(Disc{std::move(path), std::move(disc), paths},
std::move(boot_session_data_));
@ -267,15 +266,13 @@ std::unique_ptr<BootParameters> BootParameters::GenerateFromFile(std::vector<std
if (extension == ".wad")
{
std::unique_ptr<DiscIO::VolumeWAD> wad = DiscIO::CreateWAD(std::move(path));
if (wad)
if (std::unique_ptr<DiscIO::VolumeWAD> wad = DiscIO::CreateWAD(std::move(path)))
return std::make_unique<BootParameters>(std::move(*wad), std::move(boot_session_data_));
}
if (extension == ".json")
{
auto descriptor = DiscIO::ParseGameModDescriptorFile(path);
if (descriptor)
if (auto descriptor = DiscIO::ParseGameModDescriptorFile(path))
{
auto boot_params = GenerateFromFile(descriptor->base_file, std::move(boot_session_data_));
if (!boot_params)

View File

@ -115,9 +115,8 @@ const char* ElfReader::GetSectionName(int section) const
return nullptr;
int nameOffset = sections[section].sh_name;
char* ptr = (char*)GetSectionDataPtr(header->e_shstrndx);
if (ptr)
if (char* ptr = (char*)GetSectionDataPtr(header->e_shstrndx))
return ptr + nameOffset;
else
return nullptr;

View File

@ -71,8 +71,7 @@ static std::vector<u8> ToByteVector(const T& val)
std::vector<u8> Cheats::GetValueAsByteVector(const Cheats::SearchValue& value)
{
DataType type = GetDataType(value);
switch (type)
switch (DataType type = GetDataType(value))
{
case Cheats::DataType::U8:
return {std::get<u8>(value.m_value)};

View File

@ -207,8 +207,7 @@ private:
// Somewhat hacky support for IPL.SADR. The setting only stores the
// first 4 bytes even thought the SYSCONF entry is much bigger.
u32 value = info->GetDefaultValue();
SysConf::Entry* entry = sysconf.GetEntry(key);
if (entry)
if (SysConf::Entry* entry = sysconf.GetEntry(key))
{
std::memcpy(&value, entry->bytes.data(),
std::min(entry->bytes.size(), sizeof(u32)));

View File

@ -465,8 +465,7 @@ std::string SConfig::GetGameTDBImageRegionCode(bool wii, DiscIO::Region region)
return "KO";
case DiscIO::Region::PAL:
{
const auto user_lang = GetCurrentLanguage(wii);
switch (user_lang)
switch (const auto user_lang = GetCurrentLanguage(wii))
{
case DiscIO::Language::German:
return "DE";

View File

@ -981,8 +981,7 @@ void UpdateWantDeterminism(Core::System& system, bool initial)
const Core::CPUThreadGuard guard(system);
s_wants_determinism = new_want_determinism;
const auto ios = system.GetIOS();
if (ios)
if (const auto ios = system.GetIOS())
ios->UpdateWantDeterminism(new_want_determinism);
system.GetFifo().UpdateWantDeterminism(new_want_determinism);

View File

@ -176,9 +176,7 @@ void DSPEmitter::EmitInstruction(UDSPInstruction inst)
// Call extended
if (op_template->extended)
{
const auto jit_function = GetExtOp(inst);
if (jit_function)
if (const auto jit_function = GetExtOp(inst))
{
(this->*jit_function)(inst);
ext_is_jit = true;
@ -195,8 +193,7 @@ void DSPEmitter::EmitInstruction(UDSPInstruction inst)
}
// Main instruction
const auto jit_function = GetOp(inst);
if (jit_function)
if (const auto jit_function = GetOp(inst))
{
(this->*jit_function)(inst);
}

View File

@ -44,8 +44,7 @@ void LabelMap::RegisterDefaults()
bool LabelMap::RegisterLabel(std::string label, u16 lval, LabelType type)
{
const std::optional<u16> old_value = GetLabelValue(label);
if (old_value)
if (const std::optional<u16> old_value = GetLabelValue(label))
{
if (old_value != lval)
{

View File

@ -389,8 +389,7 @@ std::string GetStringVA(HLEPrintArgs* args, std::string_view string)
break;
}
const char format_specifier = string[i];
switch (format_specifier)
switch (const char format_specifier = string[i])
{
case 's':
{

View File

@ -130,9 +130,7 @@ void AXUCode::HandleCommandList()
bool end = false;
while (!end)
{
u16 cmd = m_cmdlist[curr_idx++];
switch (cmd)
switch (u16 cmd = m_cmdlist[curr_idx++])
{
// Some of these commands are unknown, or unused in this AX HLE.
// We still need to skip their arguments using "curr_idx += N".
@ -416,7 +414,6 @@ void AXUCode::ProcessPBList(u32 pb_addr)
{
// Samples per millisecond. In theory DSP sampling rate can be changed from
// 32KHz to 48KHz, but AX always process at 32KHz.
constexpr u32 spms = 32;
AXPB pb;
@ -434,6 +431,7 @@ void AXUCode::ProcessPBList(u32 pb_addr)
for (int curr_ms = 0; curr_ms < 5; ++curr_ms)
{
constexpr u32 spms = 32;
ApplyUpdatesForMs(curr_ms, pb, pb.updates.num_updates, updates);
ProcessVoice(static_cast<HLEAccelerator*>(m_accelerator.get()), pb, buffers, spms,

View File

@ -423,7 +423,6 @@ void AXWiiUCode::ProcessPBList(u32 pb_addr)
{
// Samples per millisecond. In theory DSP sampling rate can be changed from
// 32KHz to 48KHz, but AX always process at 32KHz.
constexpr u32 spms = 32;
AXPBWii pb;
@ -447,6 +446,7 @@ void AXWiiUCode::ProcessPBList(u32 pb_addr)
{
for (int curr_ms = 0; curr_ms < 3; ++curr_ms)
{
constexpr u32 spms = 32;
ApplyUpdatesForMs(curr_ms, pb, num_updates, updates);
ProcessVoice(static_cast<HLEAccelerator*>(m_accelerator.get()), pb, buffers, spms,
ConvertMixerControl(HILO_TO_32(pb.mixer_control)),

View File

@ -428,9 +428,8 @@ void DVDInterface::EjectDiscCallback(Core::System& system, u64 userdata, s64 cyc
void DVDInterface::InsertDiscCallback(Core::System& system, u64 userdata, s64 cyclesLate)
{
auto& di = system.GetDVDInterface();
std::unique_ptr<DiscIO::VolumeDisc> new_disc = DiscIO::CreateDisc(di.m_disc_path_to_insert);
if (new_disc)
if (std::unique_ptr<DiscIO::VolumeDisc> new_disc = DiscIO::CreateDisc(di.m_disc_path_to_insert))
di.SetDisc(std::move(new_disc), {});
else
PanicAlertFmtT("The disc that was about to be inserted couldn't be found.");

View File

@ -249,12 +249,12 @@ std::optional<std::vector<u8>>
CEXIETHERNET::BuiltInBBAInterface::TryGetDataFromSocket(StackRef* ref)
{
std::size_t datasize = 0; // Set by socket.receive using a non-const reference
unsigned short remote_port;
switch (ref->type)
{
case IPPROTO_UDP:
{
unsigned short remote_port;
std::array<u8, MAX_UDP_LENGTH> buffer;
ref->udp_socket.receive(buffer.data(), MAX_UDP_LENGTH, datasize, ref->target, remote_port);
if (datasize > 0)
@ -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<u32>(ip_header.destination_addr));
const u16 flags = ntohs(tcp_header.properties) & 0xfff;
@ -369,6 +368,7 @@ void CEXIETHERNET::BuiltInBBAInterface::HandleTCPFrame(const Common::TCPPacket&
}
else if (flags & TCP_FLAG_SIN)
{
sf::IpAddress target;
// new connection
if (ref != nullptr)
return;

View File

@ -30,9 +30,7 @@ bool IsTAPDevice(const TCHAR* guid)
TCHAR unit_string[256];
HKEY unit_key;
TCHAR component_id_string[] = _T("ComponentId");
TCHAR component_id[256];
TCHAR net_cfg_instance_id_string[] = _T("NetCfgInstanceId");
TCHAR net_cfg_instance_id[256];
DWORD data_type;
len = _countof(enum_name);
@ -54,21 +52,21 @@ bool IsTAPDevice(const TCHAR* guid)
}
else
{
TCHAR component_id[256];
len = sizeof(component_id);
status = RegQueryValueEx(unit_key, component_id_string, nullptr, &data_type,
(LPBYTE)component_id, &len);
if (!(status != ERROR_SUCCESS || data_type != REG_SZ))
{
TCHAR net_cfg_instance_id[256];
len = sizeof(net_cfg_instance_id);
status = RegQueryValueEx(unit_key, net_cfg_instance_id_string, nullptr, &data_type,
(LPBYTE)net_cfg_instance_id, &len);
if (status == ERROR_SUCCESS && data_type == REG_SZ)
{
TCHAR* const component_id_sub = _tcsstr(component_id, TAP_COMPONENT_ID);
if (component_id_sub)
if (TCHAR* const component_id_sub = _tcsstr(component_id, TAP_COMPONENT_ID))
{
if (!_tcscmp(component_id_sub, TAP_COMPONENT_ID) && !_tcscmp(net_cfg_instance_id, guid))
{
@ -112,7 +110,6 @@ bool GetGUIDs(std::vector<std::basic_string<TCHAR>>& guids)
TCHAR enum_name[256];
TCHAR connection_string[256];
HKEY connection_key;
TCHAR name_data[256];
DWORD name_type;
const TCHAR name_string[] = _T("Name");
@ -130,6 +127,7 @@ bool GetGUIDs(std::vector<std::basic_string<TCHAR>>& guids)
if (status == ERROR_SUCCESS)
{
TCHAR name_data[256];
len = sizeof(name_data);
status = RegQueryValueEx(connection_key, name_string, nullptr, &name_type, (LPBYTE)name_data,
&len);

View File

@ -236,8 +236,7 @@ void ProcessorInterfaceManager::IOSNotifyResetButtonCallback(Core::System& syste
if (!ios)
return;
auto stm = ios->GetDeviceByName("/dev/stm/eventhook");
if (stm)
if (auto stm = ios->GetDeviceByName("/dev/stm/eventhook"))
std::static_pointer_cast<IOS::HLE::STMEventHookDevice>(stm)->ResetButton();
}
@ -248,8 +247,7 @@ void ProcessorInterfaceManager::IOSNotifyPowerButtonCallback(Core::System& syste
if (!ios)
return;
auto stm = ios->GetDeviceByName("/dev/stm/eventhook");
if (stm)
if (auto stm = ios->GetDeviceByName("/dev/stm/eventhook"))
std::static_pointer_cast<IOS::HLE::STMEventHookDevice>(stm)->PowerButton();
}

View File

@ -49,10 +49,9 @@ int CSIDevice_GCController::RunBuffer(u8* buffer, int request_length)
return -1;
// Read the command
const auto command = static_cast<EBufferCommands>(buffer[0]);
// Handle it
switch (command)
switch (const auto command = static_cast<EBufferCommands>(buffer[0]))
{
case EBufferCommands::CMD_STATUS:
case EBufferCommands::CMD_RESET:

View File

@ -27,10 +27,9 @@ int CSIDevice_Keyboard::RunBuffer(u8* buffer, int request_length)
ISIDevice::RunBuffer(buffer, request_length);
// Read the command
const auto command = static_cast<EBufferCommands>(buffer[0]);
// Handle it
switch (command)
switch (const auto command = static_cast<EBufferCommands>(buffer[0]))
{
case EBufferCommands::CMD_STATUS:
case EBufferCommands::CMD_RESET:

View File

@ -26,10 +26,8 @@ int I2CBus::BusRead(u8 slave_addr, u8 addr, int count, u8* data_out)
{
for (auto& slave : m_slaves)
{
auto const bytes_read = slave->BusRead(slave_addr, addr, count, data_out);
// A slave responded, we are done.
if (bytes_read)
if (auto const bytes_read = slave->BusRead(slave_addr, addr, count, data_out))
return bytes_read;
}
@ -40,10 +38,8 @@ int I2CBus::BusWrite(u8 slave_addr, u8 addr, int count, const u8* data_in)
{
for (auto& slave : m_slaves)
{
auto const bytes_written = slave->BusWrite(slave_addr, addr, count, data_in);
// A slave responded, we are done.
if (bytes_written)
if (auto const bytes_written = slave->BusWrite(slave_addr, addr, count, data_in))
return bytes_written;
}

View File

@ -267,14 +267,13 @@ int IOWritePerWriteFile(HANDLE& dev_handle, OVERLAPPED& hid_overlap_write,
LPCVOID write_buffer = buf + 1;
DWORD bytes_to_write = (DWORD)(len - 1);
u8 resized_buffer[MAX_PAYLOAD];
// Resize the buffer, if the underlying HID Class driver needs the buffer to be the size of
// HidCaps.OuputReportSize
// In case of Wiimote HidCaps.OuputReportSize is 22 Byte.
// This is currently needed by the Toshiba Bluetooth Stack.
if ((write_method == WWM_WRITE_FILE_LARGEST_REPORT_SIZE) && (MAX_PAYLOAD > len))
{
u8 resized_buffer[MAX_PAYLOAD];
std::copy(buf, buf + len, resized_buffer);
std::fill(resized_buffer + len, resized_buffer + MAX_PAYLOAD, 0);
write_buffer = resized_buffer + 1;
@ -286,9 +285,7 @@ int IOWritePerWriteFile(HANDLE& dev_handle, OVERLAPPED& hid_overlap_write,
WriteFile(dev_handle, write_buffer, bytes_to_write, &bytes_written, &hid_overlap_write);
if (!result)
{
const DWORD error = GetLastError();
switch (error)
switch (const DWORD error = GetLastError())
{
case ERROR_INVALID_USER_BUFFER:
INFO_LOG_FMT(WIIMOTE, "IOWrite[WWM_WRITE_FILE]: Falling back to SetOutputReport");
@ -466,12 +463,12 @@ bool IsWiimote(const std::basic_string<TCHAR>& device_path, WinWriteMethod& meth
Common::ScopeGuard handle_guard{[&dev_handle] { CloseHandle(dev_handle); }};
u8 buf[MAX_PAYLOAD];
u8 const req_status_report[] = {WR_SET_REPORT | BT_OUTPUT, u8(OutputReportID::RequestStatus), 0};
int invalid_report_count = 0;
int rc = WriteToHandle(dev_handle, method, req_status_report, sizeof(req_status_report));
while (rc > 0)
{
u8 buf[MAX_PAYLOAD];
rc = ReadFromHandle(dev_handle, buf);
if (rc <= 0)
break;
@ -712,9 +709,7 @@ size_t GetReportSize(u8 rid)
{
using namespace WiimoteCommon;
const auto report_id = static_cast<InputReportID>(rid);
switch (report_id)
switch (const auto report_id = static_cast<InputReportID>(rid))
{
case InputReportID::Status:
return sizeof(InputReportStatus);

View File

@ -35,9 +35,8 @@ std::optional<IPCReply> AesDevice::IOCtlV(const IOCtlVRequest& request)
auto& system = GetSystem();
auto& memory = system.GetMemory();
HLE::ReturnCode return_code = IPC_EINVAL;
AesIoctlv command = static_cast<AesIoctlv>(request.request);
switch (command)
switch (AesIoctlv command = static_cast<AesIoctlv>(request.request))
{
case AesIoctlv::Copy:
{

View File

@ -82,9 +82,8 @@ HLE::ReturnCode ShaDevice::ProcessShaCommand(ShaIoctlv command, const IOCtlVRequ
std::optional<IPCReply> ShaDevice::IOCtlV(const IOCtlVRequest& request)
{
HLE::ReturnCode return_code = IPC_EINVAL;
ShaIoctlv command = static_cast<ShaIoctlv>(request.request);
switch (command)
switch (ShaIoctlv command = static_cast<ShaIoctlv>(request.request))
{
case ShaIoctlv::InitState:
case ShaIoctlv::ContributeState:

View File

@ -108,8 +108,7 @@ void DIDevice::ProcessQueuedIOCtl()
auto& system = GetSystem();
IOCtlRequest request{system, m_executing_command->m_request_address};
auto finished = StartIOCtl(request);
if (finished)
if (auto finished = StartIOCtl(request))
{
system.GetCoreTiming().ScheduleEvent(IPC_OVERHEAD_TICKS, s_finish_executing_di_command,
static_cast<u64>(finished.value()));
@ -628,8 +627,7 @@ void DIDevice::InterruptFromDVDInterface(DVD::DIInterruptType interrupt_type)
break;
}
auto di = GetDevice();
if (di)
if (auto di = GetDevice())
{
di->FinishDICommand(result);
}
@ -644,8 +642,7 @@ void DIDevice::FinishDICommandCallback(Core::System& system, u64 userdata, s64 t
{
const DIResult result = static_cast<DIResult>(userdata);
auto di = GetDevice();
if (di)
if (auto di = GetDevice())
di->FinishDICommand(result);
else
PanicAlertFmt("IOS::HLE::DIDevice: Received interrupt from DI when device wasn't registered!");

View File

@ -28,8 +28,7 @@ OpenRequest::OpenRequest(Core::System& system, const u32 address_) : Request(sys
auto& memory = system.GetMemory();
path = memory.GetString(memory.Read_U32(address + 0xc));
flags = static_cast<OpenMode>(memory.Read_U32(address + 0x10));
const EmulationKernel* ios = system.GetIOS();
if (ios)
if (const EmulationKernel* ios = system.GetIOS())
{
uid = ios->GetUidForPPC();
gid = ios->GetGidForPPC();

View File

@ -686,8 +686,7 @@ u32 UIDSys::GetNextUID() const
u32 UIDSys::GetOrInsertUIDForTitle(const u64 title_id)
{
const u32 current_uid = GetUIDFromTitle(title_id);
if (current_uid)
if (const u32 current_uid = GetUIDFromTitle(title_id))
{
INFO_LOG_FMT(IOS_ES, "Title {:016x} already exists in uid.sys", title_id);
return current_uid;

View File

@ -397,8 +397,6 @@ void HostFileSystem::DoState(PointerWrap& p)
movie.IsMovieActive() && Core::WiiRootIsTemporary();
p.Do(original_save_state_made_during_movie_recording);
u32 temp_val = 0;
if (!p.IsReadMode())
{
DoStateWriteOrMeasure(p, "/tmp");
@ -415,6 +413,7 @@ void HostFileSystem::DoState(PointerWrap& p)
}
else // case where we're in read mode.
{
u32 temp_val = 0;
DoStateRead(p, "/tmp");
if (!movie.IsMovieActive() || !original_save_state_made_during_movie_recording ||
!Core::WiiRootIsTemporary() ||

View File

@ -236,7 +236,6 @@ void RAMOverrideForIOSMemoryValues(Memory::MemoryManager& memory, MemorySetupTyp
const u32 mem1_physical_size = memory.GetRamSizeReal();
const u32 mem1_simulated_size = memory.GetRamSizeReal();
const u32 mem1_end = Memory::MEM1_BASE_ADDR + mem1_simulated_size;
const u32 mem1_arena_begin = 0;
const u32 mem1_arena_end = mem1_end;
const u32 mem2_physical_size = memory.GetExRamSizeReal();
const u32 mem2_simulated_size = memory.GetExRamSizeReal();
@ -250,6 +249,7 @@ void RAMOverrideForIOSMemoryValues(Memory::MemoryManager& memory, MemorySetupTyp
if (setup_type == MemorySetupType::Full)
{
const u32 mem1_arena_begin = 0;
// Overwriting these after the game's apploader sets them would be bad
memory.Write_U32(mem1_physical_size, ADDR_MEM1_SIZE);
memory.Write_U32(mem1_simulated_size, ADDR_MEM1_SIM_SIZE);
@ -957,8 +957,7 @@ void Init(Core::System& system)
s_event_enqueue =
core_timing.RegisterEvent("IPCEvent", [](Core::System& system_, u64 userdata, s64) {
auto* ios = system_.GetIOS();
if (ios)
if (auto* ios = system_.GetIOS())
ios->HandleIPCEvent(userdata);
});

View File

@ -69,8 +69,8 @@ NetIPTopDevice::NetIPTopDevice(EmulationKernel& ios, const std::string& device_n
: EmulationDevice(ios, device_name)
{
m_work_queue.Reset("Network Worker", [this](AsyncTask task) {
const IPCReply reply = task.handler();
{
const IPCReply reply = task.handler();
std::lock_guard lg(m_async_reply_lock);
m_async_replies.emplace(AsyncReply{task.request, reply.return_value});
}
@ -1087,9 +1087,9 @@ IPCReply NetIPTopDevice::HandleGetAddressInfoRequest(const IOCtlVRequest& reques
u32 sockoffset = addr + 0x460;
if (ret == 0)
{
constexpr size_t WII_ADDR_INFO_SIZE = 0x20;
for (addrinfo* result_iter = result; result_iter != nullptr; result_iter = result_iter->ai_next)
{
constexpr size_t WII_ADDR_INFO_SIZE = 0x20;
memory.Write_U32(result_iter->ai_flags, addr);
memory.Write_U32(result_iter->ai_family, addr + 0x04);
memory.Write_U32(result_iter->ai_socktype, addr + 0x08);

View File

@ -28,8 +28,7 @@ void NWC24Config::ReadConfig()
{
if (file->Read(&m_data, 1))
{
const s32 config_error = CheckNwc24Config();
if (config_error)
if (const s32 config_error = CheckNwc24Config())
ERROR_LOG_FMT(IOS_WC24, "There is an error in the config for for WC24: {}", config_error);
return;

View File

@ -162,8 +162,8 @@ NetKDRequestDevice::NetKDRequestDevice(EmulationKernel& ios, const std::string&
m_scheduler_buffer[1] = Common::swap32(-1);
m_work_queue.Reset("WiiConnect24 Worker", [this](AsyncTask task) {
const IPCReply reply = task.handler();
{
const IPCReply reply = task.handler();
std::lock_guard lg(m_async_reply_lock);
m_async_replies.emplace(AsyncReply{task.request, reply.return_value});
}
@ -178,8 +178,7 @@ NetKDRequestDevice::NetKDRequestDevice(EmulationKernel& ios, const std::string&
NetKDRequestDevice::~NetKDRequestDevice()
{
auto socket_manager = GetEmulationKernel().GetSocketManager();
if (socket_manager)
if (auto socket_manager = GetEmulationKernel().GetSocketManager())
socket_manager->Clean();
{

View File

@ -243,8 +243,7 @@ std::optional<IPCReply> NetSSLDevice::IOCtlV(const IOCtlVRequest& request)
int verifyOption = memory.Read_U32(BufferOut);
std::string hostname = memory.GetString(BufferOut2, BufferOutSize2);
int freeSSL = GetSSLFreeID();
if (freeSSL)
if (int freeSSL = GetSSLFreeID())
{
int sslID = freeSSL - 1;
WII_SSL* ssl = &_SSL[sslID];

View File

@ -1235,8 +1235,7 @@ void BluetoothEmuDevice::CommandDisconnect(u32 input_address)
SendEventCommandStatus(HCI_CMD_DISCONNECT);
SendEventDisconnect(disconnect.con_handle, disconnect.reason);
WiimoteDevice* wiimote = AccessWiimote(disconnect.con_handle);
if (wiimote)
if (WiimoteDevice* wiimote = AccessWiimote(disconnect.con_handle))
wiimote->EventDisconnect(disconnect.reason);
}

View File

@ -681,16 +681,16 @@ bool InfinityBase::CreateFigure(const std::string& file_path, u32 figure_num)
// Create a 320 byte file with standard NFC read/write permissions
std::array<u8, INFINITY_NUM_BLOCKS * INFINITY_BLOCK_SIZE> file_data{};
u32 first_block = 0x17878E;
u32 other_blocks = 0x778788;
for (s8 i = 2; i >= 0; i--)
{
u32 first_block = 0x17878E;
file_data[0x38 - i] = u8((first_block >> i * 8) & 0xFF);
}
for (u32 index = 1; index < 0x05; index++)
{
for (s8 i = 2; i >= 0; i--)
{
u32 other_blocks = 0x778788;
file_data[((index * 0x40) + 0x38) - i] = u8((other_blocks >> i * 8) & 0xFF);
}
}

View File

@ -15,8 +15,6 @@ namespace IOS::HLE::USB::SkylanderCrypto
{
u16 ComputeCRC16(std::span<const u8> data)
{
const u16 polynomial = 0x1021;
u16 crc = 0xFFFF;
for (size_t i = 0; i < data.size(); ++i)
@ -27,6 +25,7 @@ u16 ComputeCRC16(std::span<const u8> data)
{
if (Common::ExtractBit(crc, 15))
{
const u16 polynomial = 0x1021;
crc = (crc << 1) ^ polynomial;
}
else
@ -41,7 +40,6 @@ u16 ComputeCRC16(std::span<const u8> data)
// CRC-64 algorithm that is limited to 48 bits every iteration
u64 ComputeCRC48(std::span<const u8> data)
{
const u64 polynomial = 0x42f0e1eba9ea3693;
const u64 initial_register_value = 2ULL * 2ULL * 3ULL * 1103ULL * 12868356821ULL;
u64 crc = initial_register_value;
@ -52,6 +50,7 @@ u64 ComputeCRC48(std::span<const u8> data)
{
if (Common::ExtractBit(crc, 47))
{
const u64 polynomial = 0x42f0e1eba9ea3693;
crc = (crc << 1) ^ polynomial;
}
else

View File

@ -204,10 +204,9 @@ void USB_HIDv4::TriggerDeviceChangeReply()
return;
}
auto& system = GetSystem();
auto& memory = system.GetMemory();
{
auto& system = GetSystem();
auto& memory = system.GetMemory();
std::lock_guard lk(m_devices_mutex);
const u32 dest = m_devicechange_hook_request->buffer_out;
u32 offset = 0;

View File

@ -183,9 +183,9 @@ IPCReply USB_HIDv5::GetDeviceInfo(USBV5Device& device, const IOCtlRequest& reque
for (auto& endpoint : endpoints)
{
constexpr u8 ENDPOINT_INTERRUPT = 0b11;
constexpr u8 ENDPOINT_IN = 0x80;
if (endpoint.bmAttributes == ENDPOINT_INTERRUPT)
{
constexpr u8 ENDPOINT_IN = 0x80;
const bool is_in_endpoint = (endpoint.bEndpointAddress & ENDPOINT_IN) != 0;
AdditionalDeviceData* data = &m_additional_device_data[&device - m_usbv5_devices.data()];

View File

@ -246,12 +246,12 @@ void USB_KBD::Update()
{
const bool key_pressed_now = IsKeyPressed(static_cast<int>(i));
const bool key_pressed_before = m_old_key_buffer[i];
u8 key_code = 0;
if (key_pressed_now ^ key_pressed_before)
{
if (key_pressed_now)
{
u8 key_code = 0;
switch (m_keyboard_layout)
{
case KBD_LAYOUT_QWERTY:

View File

@ -1585,9 +1585,9 @@ void NetPlayClient::ThreadFunc()
{
INFO_LOG_FMT(NETPLAY, "NetPlayClient starting.");
Common::QoSSession qos_session;
if (Config::Get(Config::NETPLAY_ENABLE_QOS))
{
Common::QoSSession qos_session;
qos_session = Common::QoSSession(m_server);
if (qos_session.Successful())

View File

@ -182,8 +182,7 @@ void PCAPSSLCaptureLogger::LogIPv4(LogType log_type, const u8* data, u16 length,
};
Common::EthernetHeader ethernet_header(0x800);
auto mac = Common::StringToMacAddress(Config::Get(Config::MAIN_WIRELESS_MAC));
if (mac)
if (auto mac = Common::StringToMacAddress(Config::Get(Config::MAIN_WIRELESS_MAC)))
{
auto& mac_address =
(log_type == LogType::Write) ? ethernet_header.source : ethernet_header.destination;

View File

@ -912,8 +912,7 @@ bool Jit64::DoJit(u32 em_address, JitBlock* b, u32 nextPC)
if (!js.pairedQuantizeAddresses.contains(js.blockStart))
{
// If there are GQRs used but not set, we'll treat those as constant and optimize them
BitSet8 gqr_static = ComputeStaticGQRs(code_block);
if (gqr_static)
if (BitSet8 gqr_static = ComputeStaticGQRs(code_block))
{
SwitchToFarCode();
const u8* target = GetCodePtr();

View File

@ -394,11 +394,9 @@ void Jit64::fmaddXX(UGeckoInstruction inst)
RCOpArg Rb;
RCOpArg Rc;
RCX64Reg Rd;
RCX64Reg xmm2_guard;
RCX64Reg result_xmm_guard;
RCX64Reg Rc_duplicated_guard;
if (software_fma)
{
RCX64Reg xmm2_guard;
xmm2_guard = fpr.Scratch(XMM2);
Ra = packed ? fpr.Bind(a, RCMode::Read) : fpr.Use(a, RCMode::Read);
Rb = packed ? fpr.Bind(b, RCMode::Read) : fpr.Use(b, RCMode::Read);
@ -406,6 +404,7 @@ void Jit64::fmaddXX(UGeckoInstruction inst)
Rd = fpr.Bind(d, single ? RCMode::Write : RCMode::ReadWrite);
if (preserve_d && packed)
{
RCX64Reg result_xmm_guard;
result_xmm_guard = fpr.Scratch();
RegCache::Realize(Ra, Rb, Rc, Rd, xmm2_guard, result_xmm_guard);
result_xmm = Gen::X64Reg(result_xmm_guard);
@ -429,6 +428,7 @@ void Jit64::fmaddXX(UGeckoInstruction inst)
if (madds_accurate_nans)
{
RCX64Reg Rc_duplicated_guard;
Rc_duplicated_guard = fpr.Scratch();
RegCache::Realize(Rc_duplicated_guard);
Rc_duplicated = Rc_duplicated_guard;

View File

@ -436,10 +436,9 @@ void Jit64::dcbz(UGeckoInstruction inst)
INSTRUCTION_START
JITDISABLE(bJITLoadStoreOff);
int a = inst.RA;
int b = inst.RB;
{
int a = inst.RA;
int b = inst.RB;
RCOpArg Ra = a ? gpr.Use(a, RCMode::Read) : RCOpArg::Imm32(0);
RCOpArg Rb = gpr.Use(b, RCMode::Read);
RegCache::Realize(Ra, Rb);
@ -632,10 +631,11 @@ void Jit64::lmw(UGeckoInstruction inst)
INSTRUCTION_START
JITDISABLE(bJITLoadStoreOff);
int a = inst.RA, d = inst.RD;
int d = inst.RD;
// TODO: This doesn't handle rollback on DSI correctly
{
int a = inst.RA;
RCOpArg Ra = a ? gpr.Use(a, RCMode::Read) : RCOpArg::Imm32(0);
RegCache::Realize(Ra);
MOV_sum(32, RSCRATCH2, Ra, Imm32((u32)(s32)inst.SIMM_16));

View File

@ -675,10 +675,10 @@ void Jit64::mcrfs(UGeckoInstruction inst)
// Only clear exception bits (but not FEX/VX).
mask &= FPSCR_FX | FPSCR_ANY_X;
RCX64Reg scratch_guard;
X64Reg scratch;
if (mask != 0)
{
RCX64Reg scratch_guard;
scratch_guard = gpr.Scratch();
RegCache::Realize(scratch_guard);
scratch = scratch_guard;

View File

@ -391,8 +391,7 @@ void JitBaseBlockCache::LinkBlockExits(JitBlock& block)
{
if (!e.linkStatus)
{
JitBlock* destinationBlock = GetBlockFromStartAddress(e.exitAddress, block.feature_flags);
if (destinationBlock)
if (JitBlock* destinationBlock = GetBlockFromStartAddress(e.exitAddress, block.feature_flags))
{
WriteLinkBlock(e, destinationBlock);
e.linkStatus = true;

View File

@ -334,8 +334,7 @@ bool PPCSymbolDB::LoadMap(const Core::CPUThreadGuard& guard, const std::string&
{
alignment = 0;
sscanf(line, "%08x %08x %08x %08x %511s", &address, &size, &vaddress, &offset, name);
char* s = strstr(line, "(entry of ");
if (s)
if (char* s = strstr(line, "(entry of "))
{
sscanf(s + 10, "%511s", container);
char* s2 = (strchr(container, ')'));
@ -363,8 +362,7 @@ bool PPCSymbolDB::LoadMap(const Core::CPUThreadGuard& guard, const std::string&
{
alignment = 0;
sscanf(line, "%08x %08x %08x %511s", &address, &size, &vaddress, name);
char* s = strstr(line, "(entry of ");
if (s)
if (char* s = strstr(line, "(entry of "))
{
sscanf(s + 10, "%511s", container);
char* s2 = (strchr(container, ')'));
@ -496,7 +494,6 @@ bool PPCSymbolDB::SaveSymbolMap(const std::string& filename) const
// - It's a custom code map format
bool PPCSymbolDB::SaveCodeMap(const Core::CPUThreadGuard& guard, const std::string& filename) const
{
constexpr int SYMBOL_NAME_LIMIT = 30;
File::IOFile f(filename, "w");
if (!f)
return false;
@ -526,6 +523,7 @@ bool PPCSymbolDB::SaveCodeMap(const Core::CPUThreadGuard& guard, const std::stri
// Write the code
for (u32 address = symbol.address; address < next_address; address += 4)
{
constexpr int SYMBOL_NAME_LIMIT = 30;
const std::string disasm = ppc_debug_interface.Disassemble(&guard, address);
f.WriteString(fmt::format("{0:08x} {1:<{2}.{3}} {4}\n", address, symbol.name,
SYMBOL_NAME_LIMIT, SYMBOL_NAME_LIMIT, disasm));

View File

@ -27,11 +27,12 @@ bool CSVSignatureDB::Load(const std::string& file_path)
{
std::istringstream iss(line);
u32 checksum, size;
std::string tab, symbol, object_location, object_name;
std::string tab;
iss >> std::hex >> checksum >> std::hex >> size;
if (iss && std::getline(iss, tab, '\t'))
{
std::string symbol, object_location, object_name;
if (std::getline(iss, symbol, '\t') && std::getline(iss, object_location, '\t'))
std::getline(iss, object_name);
HashSignatureDB::DBFunc func;

View File

@ -170,8 +170,7 @@ u32 HashSignatureDB::ComputeCodeChecksum(const Core::CPUThreadGuard& guard, u32
u32 op = opcode & 0xFC000000;
u32 op2 = 0;
u32 op3 = 0;
u32 auxop = op >> 26;
switch (auxop)
switch (u32 auxop = op >> 26)
{
case 4: // PS instructions
op2 = opcode & 0x0000003F;

View File

@ -420,9 +420,9 @@ static void CompressAndDumpState(Core::System& system, CompressAndDumpState_args
const std::string last_state_filename = File::GetUserPath(D_STATESAVES_IDX) + "lastState.sav";
const std::string last_state_dtmname = last_state_filename + ".dtm";
const std::string dtmname = filename + ".dtm";
{
const std::string dtmname = filename + ".dtm";
std::lock_guard lk(s_save_thread_mutex);
// Backup existing state (overwriting an existing backup, if any).

View File

@ -121,8 +121,7 @@ static bool ImportWAD(IOS::HLE::Kernel& ios, const DiscIO::VolumeWAD& wad,
return false;
}
const auto old_handle = fs->OpenFile(IOS::SYSMENU_UID, IOS::SYSMENU_GID, path, rw_mode);
if (old_handle)
if (const auto old_handle = fs->OpenFile(IOS::SYSMENU_UID, IOS::SYSMENU_GID, path, rw_mode))
continue;
const auto new_handle = fs->CreateAndOpenFile(IOS::SYSMENU_UID, IOS::SYSMENU_GID, path,
@ -977,8 +976,7 @@ static NANDCheckResult CheckNAND(IOS::HLE::Kernel& ios, bool repair)
"/title/00010003", "/title/00010004", "/title/00010005",
"/title/00010006", "/title/00010007", "/shared2/title"})
{
const auto dir_stats = fs->GetExtendedDirectoryStats(user_path);
if (dir_stats)
if (const auto dir_stats = fs->GetExtendedDirectoryStats(user_path))
{
used_clusters_user += dir_stats->used_clusters;
used_inodes_user += dir_stats->used_inodes;

View File

@ -271,13 +271,13 @@ static bool IsValidDirectoryBlob(const std::string& dol_path, std::string* parti
if (File::GetSize(*partition_root + "sys/boot.bin") < 0x20)
return false;
#ifdef _WIN32
constexpr const char* dir_separator = "/\\";
#else
constexpr char dir_separator = '/';
#endif
if (true_root)
{
#ifdef _WIN32
constexpr const char* dir_separator = "/\\";
#else
constexpr char dir_separator = '/';
#endif
*true_root =
dol_path.substr(0, dol_path.find_last_of(dir_separator, partition_root->size() - 2) + 1);
}
@ -462,8 +462,7 @@ DirectoryBlobReader::DirectoryBlobReader(
if (partition == m_wrapped_volume->GetGamePartition())
continue;
auto type = m_wrapped_volume->GetPartitionType(partition);
if (type)
if (auto type = m_wrapped_volume->GetPartitionType(partition))
{
partitions.emplace_back(DirectoryBlobPartition(m_wrapped_volume.get(), partition, m_is_wii,
nullptr, nullptr, this),
@ -657,11 +656,11 @@ void DirectoryBlobReader::SetPartitions(std::vector<PartitionWithType>&& partiti
}
constexpr u64 STANDARD_UPDATE_PARTITION_ADDRESS = 0x50000;
constexpr u64 STANDARD_GAME_PARTITION_ADDRESS = 0xF800000;
u64 partition_address = STANDARD_UPDATE_PARTITION_ADDRESS;
u64 offset_in_table = PARTITION_SUBTABLE1_OFFSET;
for (size_t i = 0; i < partitions.size(); ++i)
{
constexpr u64 STANDARD_GAME_PARTITION_ADDRESS = 0xF800000;
if (i == subtable_1_size)
offset_in_table = PARTITION_SUBTABLE2_OFFSET;
@ -921,11 +920,9 @@ DirectoryBlobPartition::DirectoryBlobPartition(
SetApploader(ExtractNodeToVector(&sys_nodes, &apploader, blob), "apploader");
FSTBuilderNode dol_node{"main.dol", 0, {}};
const auto dol_offset = GetBootDOLOffset(*volume, partition);
if (dol_offset)
if (const auto dol_offset = GetBootDOLOffset(*volume, partition))
{
const auto dol_size = GetBootDOLSize(*volume, partition, *dol_offset);
if (dol_size)
if (const auto dol_size = GetBootDOLSize(*volume, partition, *dol_offset))
{
std::vector<BuilderContentSource> dol_contents;
dol_contents.emplace_back(

View File

@ -168,11 +168,9 @@ u64 GetBiggestReferencedOffset(const Volume& volume, const std::vector<Partition
biggest_offset = std::max(biggest_offset, offset);
}
const std::optional<u64> dol_offset = GetBootDOLOffset(volume, partition);
if (dol_offset)
if (const std::optional<u64> dol_offset = GetBootDOLOffset(volume, partition))
{
const std::optional<u64> dol_size = GetBootDOLSize(volume, partition, *dol_offset);
if (dol_size)
if (const std::optional<u64> dol_size = GetBootDOLSize(volume, partition, *dol_offset))
{
const u64 offset = volume.PartitionOffsetToRawOffset(*dol_offset + *dol_size, partition);
biggest_offset = std::max(biggest_offset, offset);
@ -187,8 +185,7 @@ u64 GetBiggestReferencedOffset(const Volume& volume, const std::vector<Partition
biggest_offset = std::max(biggest_offset, offset);
}
const FileSystem* fs = volume.GetFileSystem(partition);
if (fs)
if (const FileSystem* fs = volume.GetFileSystem(partition))
{
const u64 offset_in_partition = GetBiggestReferencedOffset(volume, fs->GetRoot());
const u64 offset = volume.PartitionOffsetToRawOffset(offset_in_partition, partition);

View File

@ -325,12 +325,11 @@ std::unique_ptr<FileInfo> FileSystemGCWii::FindFileInfo(std::string_view path,
if (child.NameCaseInsensitiveEquals(name))
{
// A match is found. The rest of the path is passed on to finish the search.
std::unique_ptr<FileInfo> result = FindFileInfo(rest_of_path, child);
// If the search wasn't successful, the loop continues, just in case there's a second
// file info that matches searching_for (which probably won't happen in practice)
if (result)
if (std::unique_ptr<FileInfo> result = FindFileInfo(rest_of_path, child))
return result;
// The search wasn't successful, the loop continues, just in case there's a second
// file info that matches searching_for (which probably won't happen in practice)
}
}

View File

@ -90,11 +90,10 @@ bool NANDImporter::ReadNANDBin(const std::string& path_to_bin,
bool NANDImporter::FindSuperblock()
{
constexpr size_t NAND_SUPERBLOCK_START = 0x1fc00000;
// There are 16 superblocks, choose the highest/newest version
for (int i = 0; i < 16; i++)
{
constexpr size_t NAND_SUPERBLOCK_START = 0x1fc00000;
auto superblock = std::make_unique<NANDSuperblock>();
std::memcpy(superblock.get(), &m_nand[NAND_SUPERBLOCK_START + i * sizeof(NANDSuperblock)],
sizeof(NANDSuperblock));

View File

@ -87,8 +87,7 @@ std::optional<Disc> ParseString(std::string_view xml, std::string xml_path)
return std::nullopt;
const std::string default_root = wiidisc.attribute("root").as_string();
const auto id = wiidisc.child("id");
if (id)
if (const auto id = wiidisc.child("id"))
{
for (const auto& attribute : id.attributes())
{
@ -113,8 +112,7 @@ std::optional<Disc> ParseString(std::string_view xml, std::string xml_path)
}
}
const auto options = wiidisc.child("options");
if (options)
if (const auto options = wiidisc.child("options"))
{
for (const auto& section_node : options.children("section"))
{

View File

@ -50,8 +50,7 @@ FileDataLoaderHostFS::FileDataLoaderHostFS(std::string sd_root, const std::strin
// m_patch_root with it.
if (!patch_root.empty())
{
auto r = MakeAbsoluteFromRelative(patch_root);
if (r)
if (auto r = MakeAbsoluteFromRelative(patch_root))
m_patch_root = std::move(*r);
}
}
@ -405,8 +404,7 @@ static DiscIO::FSTBuilderNode* FindFilenameNodeInFST(std::string_view filename,
{
if (node.IsFolder())
{
DiscIO::FSTBuilderNode* result = FindFilenameNodeInFST(filename, node.GetFolderContent());
if (result)
if (DiscIO::FSTBuilderNode* result = FindFilenameNodeInFST(filename, node.GetFolderContent()))
return result;
}
else if (Common::CaseInsensitiveEquals(node.m_filename, filename))
@ -438,8 +436,7 @@ static void ApplyFilePatchToFST(const Patch& patch, const File& file,
else
{
// Otherwise we want to patch the first file in the FST that matches that filename.
DiscIO::FSTBuilderNode* node = FindFilenameNodeInFST(file.m_disc, *fst);
if (node)
if (DiscIO::FSTBuilderNode* node = FindFilenameNodeInFST(file.m_disc, *fst))
ApplyPatchToFile(patch, file, node);
}
}
@ -666,8 +663,7 @@ std::optional<SavegameRedirect> ExtractSavegameRedirect(std::span<const Patch> r
if (!patch.m_savegame_patches.empty())
{
const auto& save_patch = patch.m_savegame_patches[0];
auto resolved = patch.m_file_data_loader->ResolveSavegameRedirectPath(save_patch.m_external);
if (resolved)
if (auto resolved = patch.m_file_data_loader->ResolveSavegameRedirectPath(save_patch.m_external))
return SavegameRedirect{std::move(*resolved), save_patch.m_clone};
return std::nullopt;
}

View File

@ -136,12 +136,10 @@ std::unique_ptr<VolumeWAD> CreateWAD(const std::string& path)
std::unique_ptr<Volume> CreateVolume(std::unique_ptr<BlobReader> reader)
{
std::unique_ptr<VolumeDisc> disc = TryCreateDisc(reader);
if (disc)
if (std::unique_ptr<VolumeDisc> disc = TryCreateDisc(reader))
return disc;
std::unique_ptr<VolumeWAD> wad = TryCreateWAD(reader);
if (wad)
if (std::unique_ptr<VolumeWAD> wad = TryCreateWAD(reader))
return wad;
return nullptr;

View File

@ -103,21 +103,18 @@ void VolumeDisc::AddGamePartitionToSyncHash(Common::SHA1::Context* context) cons
partition);
// Boot DOL (may be missing if this is a Datel disc)
const std::optional<u64> dol_offset = GetBootDOLOffset(*this, partition);
if (dol_offset)
if (const std::optional<u64> dol_offset = GetBootDOLOffset(*this, partition))
{
ReadAndAddToSyncHash(context, *dol_offset,
GetBootDOLSize(*this, partition, *dol_offset).value_or(0), partition);
}
// File system
const std::optional<u64> fst_offset = GetFSTOffset(*this, partition);
if (fst_offset)
if (const std::optional<u64> fst_offset = GetFSTOffset(*this, partition))
ReadAndAddToSyncHash(context, *fst_offset, GetFSTSize(*this, partition).value_or(0), partition);
// opening.bnr (name and banner)
const FileSystem* file_system = GetFileSystem(partition);
if (file_system)
if (const FileSystem* file_system = GetFileSystem(partition))
{
std::unique_ptr<FileInfo> file_info = file_system->FindFileInfo("opening.bnr");
if (file_info && !file_info->IsDirectory())

View File

@ -448,8 +448,7 @@ std::vector<Partition> VolumeVerifier::CheckPartitions()
std::vector<u32> types;
for (const Partition& partition : partitions)
{
const std::optional<u32> type = m_volume.GetPartitionType(partition);
if (type)
if (const std::optional<u32> type = m_volume.GetPartitionType(partition))
types.emplace_back(*type);
}
@ -656,8 +655,7 @@ bool VolumeVerifier::CheckPartition(const Partition& partition)
if (!has_correct_ios && tmd.IsValid())
{
std::unique_ptr<FileInfo> file_info = filesystem->FindFileInfo("_sys");
if (file_info)
if (std::unique_ptr<FileInfo> file_info = filesystem->FindFileInfo("_sys"))
{
const std::string ios_ver_str = std::to_string(ios_ver);
const std::string correct_ios =

View File

@ -449,11 +449,11 @@ bool VolumeWii::CheckBlockIntegrity(u64 block_index, const u8* encrypted_data,
}
HashBlock hashes;
u8 cluster_data_buffer[BLOCK_DATA_SIZE];
const u8* cluster_data;
if (m_has_encryption)
{
u8 cluster_data_buffer[BLOCK_DATA_SIZE];
Common::AES::Context* aes_context = partition_details.key->get();
if (!aes_context)
return false;

View File

@ -198,7 +198,7 @@ void CheatSearchFactoryWidget::OnNewSearchClicked()
bool aligned = m_data_type_aligned->isChecked();
auto data_type = m_data_type_dropdown->currentData().value<Cheats::DataType>();
auto session = Cheats::MakeSession(std::move(memory_ranges), address_space, aligned, data_type);
if (session)
if (auto session =
Cheats::MakeSession(std::move(memory_ranges), address_space, aligned, data_type))
emit NewSessionCreated(*session);
}

View File

@ -90,8 +90,7 @@ void CheatSearchWidget::CreateWidgets()
QLabel* session_info_label = new QLabel();
{
QString ranges;
size_t range_count = m_session->GetMemoryRangeCount();
switch (range_count)
switch (size_t range_count = m_session->GetMemoryRangeCount())
{
case 1:
{
@ -460,9 +459,8 @@ void CheatSearchWidget::OnResetClicked()
void CheatSearchWidget::OnAddressTableItemChanged(QTableWidgetItem* item)
{
const u32 address = item->data(ADDRESS_TABLE_ADDRESS_ROLE).toUInt();
const int column = item->column();
switch (column)
switch (item->column())
{
case ADDRESS_TABLE_COLUMN_INDEX_DESCRIPTION:
{
@ -537,8 +535,7 @@ void CheatSearchWidget::GenerateARCodes()
for (auto* const item : m_address_table->selectedItems())
{
const u32 index = item->data(ADDRESS_TABLE_RESULT_INDEX_ROLE).toUInt();
auto result = Cheats::GenerateActionReplayCode(*m_session, index);
if (result)
if (auto result = Cheats::GenerateActionReplayCode(*m_session, index))
{
emit ActionReplayCodeGenerated(*result);
had_success = true;

View File

@ -185,8 +185,7 @@ void CheatsManager::OnNewSessionCreated(const Cheats::CheatSearchSessionBase& se
void CheatsManager::OnTabCloseRequested(int index)
{
auto* w = m_tab_widget->widget(index);
if (w)
if (auto* w = m_tab_widget->widget(index))
w->deleteLater();
}

View File

@ -179,8 +179,7 @@ void FilesystemWidget::PopulateDirectory(int partition_id, QStandardItem* root,
root->setText(text);
const DiscIO::FileSystem* const file_system = m_volume->GetFileSystem(partition);
if (file_system)
if (const DiscIO::FileSystem* const file_system = m_volume->GetFileSystem(partition))
PopulateDirectory(partition_id, root, file_system->GetRoot());
}

View File

@ -176,8 +176,7 @@ void GamecubeControllersWidget::LoadSettings(Core::State state)
{
const SerialInterface::SIDevices si_device =
Config::Get(Config::GetInfoForSIDevice(static_cast<int>(i)));
const std::optional<int> gc_index = ToGCMenuIndex(si_device);
if (gc_index)
if (const std::optional<int> gc_index = ToGCMenuIndex(si_device))
{
SignalBlocking(m_gc_controller_boxes[i])->setCurrentIndex(*gc_index);
m_gc_controller_boxes[i]->setEnabled(NetPlay::IsNetPlayRunning() ? !running : true);

View File

@ -316,9 +316,9 @@ void EnhancementsWidget::LoadPPShaders(StereoMode stereo_mode)
tr("%1 doesn't support this feature.")
.arg(tr(g_video_backend->GetDisplayName().c_str())));
VideoCommon::PostProcessingConfiguration pp_shader;
if (selected_shader != "" && supports_postprocessing)
{
VideoCommon::PostProcessingConfiguration pp_shader;
pp_shader.LoadShader(selected_shader);
m_configure_pp_effect->setEnabled(pp_shader.HasOptions());
}
@ -497,9 +497,9 @@ void EnhancementsWidget::SaveSettings()
"" :
m_pp_effect->currentText().toStdString());
VideoCommon::PostProcessingConfiguration pp_shader;
if (Config::Get(Config::GFX_ENHANCE_POST_SHADER) != "")
{
VideoCommon::PostProcessingConfiguration pp_shader;
pp_shader.LoadShader(Config::Get(Config::GFX_ENHANCE_POST_SHADER));
m_configure_pp_effect->setEnabled(pp_shader.HasOptions());
}

View File

@ -77,8 +77,7 @@ PropertiesDialog::PropertiesDialog(QWidget* parent, const UICommon::GameFile& ga
if (game.GetPlatform() != DiscIO::Platform::ELFOrDOL)
{
std::shared_ptr<DiscIO::Volume> volume = DiscIO::CreateVolume(game.GetFilePath());
if (volume)
if (std::shared_ptr<DiscIO::Volume> volume = DiscIO::CreateVolume(game.GetFilePath()))
{
VerifyWidget* verify = new VerifyWidget(volume);
tab_widget->addTab(GetWrappedWidget(verify, this, padding_width, padding_height),

View File

@ -70,10 +70,10 @@ private:
painter->setClipRect(option.rect);
painter->setPen(m_parent->palette().text().color());
constexpr u32 x_offset_in_branch_for_vertical_line = 10;
const u32 addr = m_parent->AddressForRow(index.row());
for (const CodeViewBranch& branch : m_parent->m_branches)
{
constexpr u32 x_offset_in_branch_for_vertical_line = 10;
const int y_center = option.rect.top() + option.rect.height() / 2;
const int x_left = option.rect.left() + WIDTH_PER_BRANCH_ARROW * branch.indentation;
const int x_right = x_left + x_offset_in_branch_for_vertical_line;

View File

@ -401,9 +401,8 @@ void CodeWidget::UpdateFunctionCalls(const Common::Symbol* symbol)
for (const auto& call : symbol->calls)
{
const u32 addr = call.function;
const Common::Symbol* const call_symbol = m_ppc_symbol_db.GetSymbolFromAddr(addr);
if (call_symbol)
if (const Common::Symbol* const call_symbol = m_ppc_symbol_db.GetSymbolFromAddr(addr))
{
const QString name =
QString::fromStdString(fmt::format("> {} ({:08x})", call_symbol->name, addr));
@ -426,9 +425,8 @@ void CodeWidget::UpdateFunctionCallers(const Common::Symbol* symbol)
for (const auto& caller : symbol->callers)
{
const u32 addr = caller.call_address;
const Common::Symbol* const caller_symbol = m_ppc_symbol_db.GetSymbolFromAddr(addr);
if (caller_symbol)
if (const Common::Symbol* const caller_symbol = m_ppc_symbol_db.GetSymbolFromAddr(addr))
{
const QString name =
QString::fromStdString(fmt::format("< {} ({:08x})", caller_symbol->name, addr));
@ -516,8 +514,8 @@ void CodeWidget::StepOut()
clock::time_point timeout = clock::now() + std::chrono::seconds(5);
auto& power_pc = m_system.GetPowerPC();
auto& ppc_state = power_pc.GetPPCState();
{
auto& ppc_state = power_pc.GetPPCState();
Core::CPUThreadGuard guard(m_system);
PowerPC::CoreMode old_mode = power_pc.GetMode();

View File

@ -187,11 +187,11 @@ void GameList::MakeListView()
if (!Settings::GetQSettings().contains(QStringLiteral("tableheader/state")))
m_list->sortByColumn(static_cast<int>(GameListModel::Column::Title), Qt::AscendingOrder);
const auto SetResizeMode = [&hor_header](const GameListModel::Column column,
const QHeaderView::ResizeMode mode) {
hor_header->setSectionResizeMode(static_cast<int>(column), mode);
};
{
const auto SetResizeMode = [&hor_header](const GameListModel::Column column,
const QHeaderView::ResizeMode mode) {
hor_header->setSectionResizeMode(static_cast<int>(column), mode);
};
using Column = GameListModel::Column;
using Mode = QHeaderView::ResizeMode;
SetResizeMode(Column::Platform, Mode::Fixed);
@ -1021,8 +1021,6 @@ void GameList::OnSectionResized(int index, int, int)
{
auto* hor_header = m_list->horizontalHeader();
std::vector<int> sections;
const int vis_index = hor_header->visualIndex(index);
const int col_count = hor_header->count() - hor_header->hiddenSectionCount();
@ -1040,6 +1038,7 @@ void GameList::OnSectionResized(int index, int, int)
if (!last)
{
std::vector<int> sections;
for (int i = 0; i < vis_index; i++)
{
const int logical_index = hor_header->logicalIndex(i);

View File

@ -106,13 +106,12 @@ QVariant GameListModel::data(const QModelIndex& index, int role) const
// For natural sorting, pad all numbers to the same length.
if (SORT_ROLE == role)
{
constexpr int MAX_NUMBER_LENGTH = 10;
const QRegularExpression rx(QStringLiteral("\\d+"));
QRegularExpressionMatch match;
int pos = 0;
while ((match = rx.match(name, pos)).hasMatch())
{
constexpr int MAX_NUMBER_LENGTH = 10;
pos = match.capturedStart();
name.replace(pos, match.capturedLength(),
match.captured().rightJustified(MAX_NUMBER_LENGTH));

View File

@ -356,8 +356,7 @@ void GameTracker::LoadGame(const QString& path)
if (!DiscIO::ShouldHideFromGameList(converted_path))
{
bool cache_changed = false;
auto game = m_cache.AddOrGet(converted_path, &cache_changed);
if (game)
if (auto game = m_cache.AddOrGet(converted_path, &cache_changed))
emit GameLoaded(std::move(game));
if (cache_changed && !m_refresh_in_progress)
m_cache.Save();

View File

@ -80,9 +80,6 @@ static bool IsHotkey(int id, bool held = false)
static void HandleFrameStepHotkeys()
{
constexpr int MAX_FRAME_STEP_DELAY = 60;
constexpr int FRAME_STEP_DELAY = 30;
static int frame_step_count = 0;
static int frame_step_delay = 1;
static int frame_step_delay_count = 0;
@ -96,6 +93,7 @@ static void HandleFrameStepHotkeys()
if (IsHotkey(HK_FRAME_ADVANCE_DECREASE_SPEED))
{
constexpr int MAX_FRAME_STEP_DELAY = 60;
frame_step_delay = std::min(frame_step_delay + 1, MAX_FRAME_STEP_DELAY);
return;
}
@ -108,6 +106,7 @@ static void HandleFrameStepHotkeys()
if (IsHotkey(HK_FRAME_ADVANCE, true))
{
constexpr int FRAME_STEP_DELAY = 30;
if (frame_step_delay_count < frame_step_delay && frame_step_hold)
frame_step_delay_count++;

View File

@ -846,8 +846,7 @@ void MainWindow::Play(const std::optional<std::string>& savestate_path)
}
else
{
std::shared_ptr<const UICommon::GameFile> selection = m_game_list->GetSelectedGame();
if (selection)
if (std::shared_ptr<const UICommon::GameFile> selection = m_game_list->GetSelectedGame())
{
StartGame(selection->GetFilePath(), ScanForSecondDisc::Yes,
std::make_unique<BootSessionData>(savestate_path, DeleteSavestateAfterBoot::No));
@ -1961,8 +1960,7 @@ void MainWindow::OnActivateChat()
void MainWindow::OnRequestGolfControl()
{
auto client = Settings::Instance().GetNetPlayClient();
if (client)
if (auto client = Settings::Instance().GetNetPlayClient())
client->RequestGolfControl();
}

View File

@ -48,10 +48,10 @@ NANDRepairDialog::NANDRepairDialog(const WiiUtils::NANDCheckResult& result, QWid
main_layout->addWidget(warning_label);
std::string title_listings;
Core::TitleDatabase title_db;
const DiscIO::Language language = SConfig::GetInstance().GetCurrentLanguage(true);
for (const u64 title_id : result.titles_to_remove)
{
Core::TitleDatabase title_db;
title_listings += fmt::format("{:016x}", title_id);
const std::string database_name = title_db.GetChannelName(title_id, language);

View File

@ -141,9 +141,7 @@ void ChunkedProgressDialog::SetProgress(const int pid, const u64 progress)
void ChunkedProgressDialog::reject()
{
auto server = Settings::Instance().GetNetPlayServer();
if (server)
if (auto server = Settings::Instance().GetNetPlayServer())
server->AbortGameStart();
QDialog::reject();

View File

@ -164,9 +164,7 @@ void GameDigestDialog::SetResult(int pid, const std::string& result)
void GameDigestDialog::reject()
{
auto server = Settings::Instance().GetNetPlayServer();
if (server)
if (auto server = Settings::Instance().GetNetPlayServer())
server->AbortGameDigest();
QDialog::reject();

View File

@ -199,9 +199,7 @@ void NetPlayBrowser::RefreshLoop()
NetPlayIndex client;
auto entries = client.List(filters);
if (entries)
if (auto entries = client.List(filters))
{
emit UpdateListRequested(std::move(*entries));
}

View File

@ -367,8 +367,7 @@ void NetPlayDialog::ConnectWidgets()
const auto hia_function = [this](bool enable) {
if (m_host_input_authority != enable)
{
auto server = Settings::Instance().GetNetPlayServer();
if (server)
if (auto server = Settings::Instance().GetNetPlayServer())
server->SetHostInputAuthority(enable);
}
};
@ -881,9 +880,7 @@ void NetPlayDialog::OnMsgStartGame()
}
QueueOnObject(this, [this] {
auto client = Settings::Instance().GetNetPlayClient();
if (client)
if (auto client = Settings::Instance().GetNetPlayClient())
{
if (auto game = FindGameFile(m_current_game_identifier))
client->StartGame(game->GetFilePath());
@ -1047,8 +1044,7 @@ void NetPlayDialog::OnTtlDetermined(u8 ttl)
bool NetPlayDialog::IsRecording()
{
std::optional<bool> is_recording = RunOnObject(m_record_input_action, &QAction::isChecked);
if (is_recording)
if (std::optional<bool> is_recording = RunOnObject(m_record_input_action, &QAction::isChecked))
return *is_recording;
return false;
}
@ -1274,7 +1270,6 @@ void NetPlayDialog::SetChunkedProgress(const int pid, const u64 progress)
void NetPlayDialog::SetHostWiiSyncData(std::vector<u64> titles, std::string redirect_folder)
{
auto client = Settings::Instance().GetNetPlayClient();
if (client)
if (auto client = Settings::Instance().GetNetPlayClient())
client->SetWiiSyncData(nullptr, std::move(titles), std::move(redirect_folder));
}

View File

@ -530,11 +530,10 @@ void RenderWidget::PassEventToPresenter(const QEvent* event)
const u32 key = static_cast<u32>(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();

View File

@ -161,8 +161,7 @@ void RiivolutionBootWidget::OpenXML()
}
auto root = FindRoot(p);
const auto config = LoadConfigXML(root);
if (config)
if (const auto config = LoadConfigXML(root))
DiscIO::Riivolution::ApplyConfigDefaults(&*parsed, *config);
MakeGUIForParsedFile(p, std::move(root), *parsed);
}

View File

@ -815,8 +815,7 @@ void GameCubePane::SaveSettings()
m_gba_rom_edits[i]->text().toStdString());
}
auto server = Settings::Instance().GetNetPlayServer();
if (server)
if (auto server = Settings::Instance().GetNetPlayServer())
server->SetGBAConfig(server->GetGBAConfig(), true);
}
#endif

View File

@ -154,8 +154,7 @@ Token Lexer::NextToken()
if (it == expr.end())
return Token(TOK_EOF);
char c = *it++;
switch (c)
switch (char c = *it++)
{
case ' ':
case '\t':

View File

@ -305,17 +305,14 @@ Device::Input* DeviceContainer::FindInput(std::string_view name, const Device* d
{
if (def_dev)
{
Device::Input* const inp = def_dev->FindInput(name);
if (inp)
if (Device::Input* const inp = def_dev->FindInput(name))
return inp;
}
std::lock_guard lk(m_devices_mutex);
for (const auto& d : m_devices)
{
Device::Input* const i = d->FindInput(name);
if (i)
if (Device::Input* const i = d->FindInput(name))
return i;
}

View File

@ -304,9 +304,8 @@ std::unique_ptr<ciface::InputBackend> CreateInputBackend(ControllerInterface* co
void InputBackend::OpenAndAddDevice(int index)
{
SDL_GameController* gc = SDL_GameControllerOpen(index);
SDL_Joystick* js = SDL_JoystickOpen(index);
if (js)
if (SDL_Joystick* js = SDL_JoystickOpen(index))
{
if (SDL_JoystickNumButtons(js) > 255 || SDL_JoystickNumAxes(js) > 255 ||
SDL_JoystickNumHats(js) > 255 || SDL_JoystickNumBalls(js) > 255)

View File

@ -279,8 +279,7 @@ static void WriteThreadFunc()
{
s_write_happened.Wait();
const int write_size = s_controller_write_payload_size.load();
if (write_size)
if (const int write_size = s_controller_write_payload_size.load())
{
#if GCADAPTER_USE_LIBUSB_IMPLEMENTATION
const int error =
@ -953,10 +952,10 @@ void Output(int chan, u8 rumble_command)
s_port_states[chan].controller_type != ControllerType::Wireless)
{
s_controller_rumble[chan] = rumble_command;
std::array<u8, CONTROLLER_OUTPUT_RUMBLE_PAYLOAD_SIZE> rumble = {
0x11, s_controller_rumble[0], s_controller_rumble[1], s_controller_rumble[2],
s_controller_rumble[3]};
{
std::array<u8, CONTROLLER_OUTPUT_RUMBLE_PAYLOAD_SIZE> rumble = {
0x11, s_controller_rumble[0], s_controller_rumble[1], s_controller_rumble[2],
s_controller_rumble[3]};
#if GCADAPTER_USE_ANDROID_IMPLEMENTATION
std::lock_guard lk(s_write_mutex);
#endif

View File

@ -127,8 +127,7 @@ void ProfileCycler::CycleProfile(CycleDirection cycle_direction, InputConfig* de
}
const std::string profile = GetProfile(cycle_direction, profile_index, profiles);
auto* controller = device_configuration->GetController(controller_index);
if (controller)
if (auto* controller = device_configuration->GetController(controller_index))
{
UpdateToProfile(profile, controller, device_configuration);
}
@ -166,8 +165,7 @@ void ProfileCycler::CycleProfileForGame(CycleDirection cycle_direction,
const std::string profile = GetProfile(cycle_direction, profile_index, profiles_for_game);
auto* controller = device_configuration->GetController(controller_index);
if (controller)
if (auto* controller = device_configuration->GetController(controller_index))
{
UpdateToProfile(profile, controller, device_configuration);
}

View File

@ -168,8 +168,7 @@ static std::string GetPlatformID()
static std::string GetUpdateServerUrl()
{
auto server_url = std::getenv("DOLPHIN_UPDATE_SERVER_URL");
if (server_url)
if (auto server_url = std::getenv("DOLPHIN_UPDATE_SERVER_URL"))
return server_url;
return "https://dolphin-emu.org";
}

View File

@ -51,8 +51,7 @@ public:
std::getline(buffer, section, '.');
std::getline(buffer, key, '=');
std::getline(buffer, value, '=');
std::optional<Config::System> system = Config::GetSystemFromName(system_str);
if (system)
if (std::optional<Config::System> system = Config::GetSystemFromName(system_str))
{
m_values.emplace_back(
Config::Location{std::move(*system), std::move(section), std::move(key)},

View File

@ -158,8 +158,7 @@ GameFile::GameFile(std::string path) : m_file_path(std::move(path))
if (!IsValid() && GetExtension() == ".json")
{
auto descriptor = DiscIO::ParseGameModDescriptorFile(m_file_path);
if (descriptor)
if (auto descriptor = DiscIO::ParseGameModDescriptorFile(m_file_path))
{
GameFile proxy(descriptor->base_file);
if (proxy.IsValid())
@ -691,8 +690,7 @@ Common::SHA1::Digest GameFile::GetSyncHash() const
}
else if (m_blob_type == DiscIO::BlobType::MOD_DESCRIPTOR)
{
auto descriptor = DiscIO::ParseGameModDescriptorFile(m_file_path);
if (descriptor)
if (auto descriptor = DiscIO::ParseGameModDescriptorFile(m_file_path))
{
GameFile proxy(descriptor->base_file);
if (proxy.IsValid())

Some files were not shown because too many files have changed in this diff Show More