Skip to content
Permalink
Browse files
Merge pull request #10085 from Pokechu22/C26495
Fix all uninitialized variable warnings (C26495)
  • Loading branch information
leoetlino committed Oct 13, 2021
2 parents a0a91ec + 78bfd25 commit 023eb0b
Show file tree
Hide file tree
Showing 114 changed files with 789 additions and 790 deletions.
@@ -99,7 +99,7 @@ class Mixer final
bool m_is_stretching = false;
AudioCommon::AudioStretcher m_stretcher;
AudioCommon::SurroundDecoder m_surround_decoder;
std::array<short, MAX_SAMPLES * 2> m_scratch_buffer;
std::array<short, MAX_SAMPLES * 2> m_scratch_buffer{};

WaveFileWriter m_wave_writer_dtk;
WaveFileWriter m_wave_writer_dsp;
@@ -53,7 +53,7 @@ class OpenALStream final : public SoundStream
{
#ifdef _WIN32
public:
OpenALStream() : m_source(0) {}
OpenALStream() = default;
~OpenALStream() override;
bool Init() override;
void SetVolume(int volume) override;
@@ -68,9 +68,9 @@ class OpenALStream final : public SoundStream
Common::Flag m_run_thread;

std::vector<short> m_realtime_buffer;
std::array<ALuint, OAL_BUFFERS> m_buffers;
ALuint m_source;
ALfloat m_volume;
std::array<ALuint, OAL_BUFFERS> m_buffers{};
ALuint m_source = 0;
ALfloat m_volume = 1;

#endif // _WIN32
};
@@ -23,7 +23,7 @@ using UnderlyingType = typename std::enable_if_t<std::is_enum<T>{}, std::underly

struct Location
{
System system;
System system{};
std::string section;
std::string key;

@@ -85,11 +85,11 @@ enum

namespace File
{
// FileSystem tree node/
// FileSystem tree node
struct FSTEntry
{
bool isDirectory;
u64 size; // File length, or for directories, recursive count of children
bool isDirectory = false;
u64 size = 0; // File length, or for directories, recursive count of children
std::string physicalName; // Name on disk
std::string virtualName; // Name in FST names table
std::vector<FSTEntry> children;
@@ -78,7 +78,7 @@ class FixedSizeQueue
bool empty() const noexcept { return size() == 0; }

private:
std::array<T, N> storage;
std::array<T, N> storage{};
int head = 0;
int tail = 0;
// Sacrifice 4 bytes for a simpler implementation. may optimize away in the future.
@@ -3,6 +3,7 @@

#pragma once

#include <array>
#include <cstddef>
#include <cstdio>
#include <string>
@@ -57,6 +58,18 @@ class IOFile
return m_good;
}

template <typename T, std::size_t N>
bool ReadArray(std::array<T, N>* elements, size_t* num_read = nullptr)
{
return ReadArray(elements->data(), elements->size(), num_read);
}

template <typename T, std::size_t N>
bool WriteArray(const std::array<T, N>& elements)
{
return WriteArray(elements.data(), elements.size());
}

bool ReadBytes(void* data, size_t length)
{
return ReadArray(reinterpret_cast<char*>(data), length);
@@ -153,13 +153,13 @@ class LinearDiskCache
std::min(Common::scm_rev_git_str.size(), sizeof(ver)));
}

u32 id;
u32 id = 0;
const u16 key_t_size = sizeof(K);
const u16 value_t_size = sizeof(V);
char ver[40] = {};

} m_header;

File::IOFile m_file;
u32 m_num_entries;
u32 m_num_entries = 0;
};
@@ -14,5 +14,5 @@ class ConsoleListener : public Common::Log::LogListener
void Log(Common::Log::LOG_LEVELS level, const char* text) override;

private:
bool m_use_color;
bool m_use_color = false;
};
@@ -98,7 +98,7 @@ class SPSCQueue
delete next_ptr;
}

T current;
T current{};
std::atomic<ElementPtr*> next;
};

@@ -16,10 +16,10 @@ namespace ActionReplay
{
struct AREntry
{
AREntry() {}
AREntry() = default;
AREntry(u32 _addr, u32 _value) : cmd_addr(_addr), value(_value) {}
u32 cmd_addr;
u32 value;
u32 cmd_addr = 0;
u32 value = 0;
};
constexpr bool operator==(const AREntry& left, const AREntry& right)
{
@@ -64,44 +64,44 @@ struct ConfigCache

// These store if the relevant setting should be reset back later (true) or if it should be left
// alone on restore (false)
bool bSetEmulationSpeed;
bool bSetVolume;
std::array<bool, MAX_BBMOTES> bSetWiimoteSource;
std::array<bool, SerialInterface::MAX_SI_CHANNELS> bSetPads;
std::array<bool, ExpansionInterface::MAX_EXI_CHANNELS> bSetEXIDevice;
bool bSetEmulationSpeed = false;
bool bSetVolume = false;
std::array<bool, MAX_BBMOTES> bSetWiimoteSource{};
std::array<bool, SerialInterface::MAX_SI_CHANNELS> bSetPads{};
std::array<bool, ExpansionInterface::MAX_EXI_CHANNELS> bSetEXIDevice{};

private:
bool valid;
bool bCPUThread;
bool bJITFollowBranch;
bool bSyncGPUOnSkipIdleHack;
bool bFloatExceptions;
bool bDivideByZeroExceptions;
bool bFPRF;
bool bAccurateNaNs;
bool bMMU;
bool bLowDCBZHack;
bool bDisableICache;
bool m_EnableJIT;
bool bSyncGPU;
int iSyncGpuMaxDistance;
int iSyncGpuMinDistance;
float fSyncGpuOverclock;
bool bFastDiscSpeed;
bool bDSPHLE;
bool bHLE_BS2;
int iSelectedLanguage;
PowerPC::CPUCore cpu_core;
int Volume;
float m_EmulationSpeed;
float m_OCFactor;
bool m_OCEnable;
bool m_bt_passthrough_enabled;
bool valid = false;
bool bCPUThread = false;
bool bJITFollowBranch = false;
bool bSyncGPUOnSkipIdleHack = false;
bool bFloatExceptions = false;
bool bDivideByZeroExceptions = false;
bool bFPRF = false;
bool bAccurateNaNs = false;
bool bMMU = false;
bool bLowDCBZHack = false;
bool bDisableICache = false;
bool m_EnableJIT = false;
bool bSyncGPU = false;
int iSyncGpuMaxDistance = 0;
int iSyncGpuMinDistance = 0;
float fSyncGpuOverclock = 0;
bool bFastDiscSpeed = false;
bool bDSPHLE = false;
bool bHLE_BS2 = false;
int iSelectedLanguage = 0;
PowerPC::CPUCore cpu_core = PowerPC::CPUCore::Interpreter;
int Volume = 0;
float m_EmulationSpeed = 0;
float m_OCFactor = 0;
bool m_OCEnable = false;
bool m_bt_passthrough_enabled = false;
std::string sBackend;
std::string m_strGPUDeterminismMode;
std::array<WiimoteSource, MAX_BBMOTES> iWiimoteSource;
std::array<SerialInterface::SIDevices, SerialInterface::MAX_SI_CHANNELS> Pads;
std::array<ExpansionInterface::TEXIDevices, ExpansionInterface::MAX_EXI_CHANNELS> m_EXIDevice;
std::array<WiimoteSource, MAX_BBMOTES> iWiimoteSource{};
std::array<SerialInterface::SIDevices, SerialInterface::MAX_SI_CHANNELS> Pads{};
std::array<ExpansionInterface::TEXIDevices, ExpansionInterface::MAX_EXI_CHANNELS> m_EXIDevice{};
};

void ConfigCache::SaveConfig(const SConfig& config)
@@ -101,87 +101,87 @@ std::vector<u8> Cheats::GetValueAsByteVector(const Cheats::SearchValue& value)
namespace
{
template <typename T>
static PowerPC::TryReadResult<T>
static std::optional<PowerPC::ReadResult<T>>
TryReadValueFromEmulatedMemory(u32 addr, PowerPC::RequestedAddressSpace space);

template <>
PowerPC::TryReadResult<u8> TryReadValueFromEmulatedMemory(u32 addr,
PowerPC::RequestedAddressSpace space)
std::optional<PowerPC::ReadResult<u8>>
TryReadValueFromEmulatedMemory(u32 addr, PowerPC::RequestedAddressSpace space)
{
return PowerPC::HostTryReadU8(addr, space);
}

template <>
PowerPC::TryReadResult<u16> TryReadValueFromEmulatedMemory(u32 addr,
PowerPC::RequestedAddressSpace space)
std::optional<PowerPC::ReadResult<u16>>
TryReadValueFromEmulatedMemory(u32 addr, PowerPC::RequestedAddressSpace space)
{
return PowerPC::HostTryReadU16(addr, space);
}

template <>
PowerPC::TryReadResult<u32> TryReadValueFromEmulatedMemory(u32 addr,
PowerPC::RequestedAddressSpace space)
std::optional<PowerPC::ReadResult<u32>>
TryReadValueFromEmulatedMemory(u32 addr, PowerPC::RequestedAddressSpace space)
{
return PowerPC::HostTryReadU32(addr, space);
}

template <>
PowerPC::TryReadResult<u64> TryReadValueFromEmulatedMemory(u32 addr,
PowerPC::RequestedAddressSpace space)
std::optional<PowerPC::ReadResult<u64>>
TryReadValueFromEmulatedMemory(u32 addr, PowerPC::RequestedAddressSpace space)
{
return PowerPC::HostTryReadU64(addr, space);
}

template <>
PowerPC::TryReadResult<s8> TryReadValueFromEmulatedMemory(u32 addr,
PowerPC::RequestedAddressSpace space)
std::optional<PowerPC::ReadResult<s8>>
TryReadValueFromEmulatedMemory(u32 addr, PowerPC::RequestedAddressSpace space)
{
auto tmp = PowerPC::HostTryReadU8(addr, space);
if (!tmp)
return PowerPC::TryReadResult<s8>();
return PowerPC::TryReadResult<s8>(tmp.translated, Common::BitCast<s8>(tmp.value));
return std::nullopt;
return PowerPC::ReadResult<s8>(tmp->translated, Common::BitCast<s8>(tmp->value));
}

template <>
PowerPC::TryReadResult<s16> TryReadValueFromEmulatedMemory(u32 addr,
PowerPC::RequestedAddressSpace space)
std::optional<PowerPC::ReadResult<s16>>
TryReadValueFromEmulatedMemory(u32 addr, PowerPC::RequestedAddressSpace space)
{
auto tmp = PowerPC::HostTryReadU16(addr, space);
if (!tmp)
return PowerPC::TryReadResult<s16>();
return PowerPC::TryReadResult<s16>(tmp.translated, Common::BitCast<s16>(tmp.value));
return std::nullopt;
return PowerPC::ReadResult<s16>(tmp->translated, Common::BitCast<s16>(tmp->value));
}

template <>
PowerPC::TryReadResult<s32> TryReadValueFromEmulatedMemory(u32 addr,
PowerPC::RequestedAddressSpace space)
std::optional<PowerPC::ReadResult<s32>>
TryReadValueFromEmulatedMemory(u32 addr, PowerPC::RequestedAddressSpace space)
{
auto tmp = PowerPC::HostTryReadU32(addr, space);
if (!tmp)
return PowerPC::TryReadResult<s32>();
return PowerPC::TryReadResult<s32>(tmp.translated, Common::BitCast<s32>(tmp.value));
return std::nullopt;
return PowerPC::ReadResult<s32>(tmp->translated, Common::BitCast<s32>(tmp->value));
}

template <>
PowerPC::TryReadResult<s64> TryReadValueFromEmulatedMemory(u32 addr,
PowerPC::RequestedAddressSpace space)
std::optional<PowerPC::ReadResult<s64>>
TryReadValueFromEmulatedMemory(u32 addr, PowerPC::RequestedAddressSpace space)
{
auto tmp = PowerPC::HostTryReadU64(addr, space);
if (!tmp)
return PowerPC::TryReadResult<s64>();
return PowerPC::TryReadResult<s64>(tmp.translated, Common::BitCast<s64>(tmp.value));
return std::nullopt;
return PowerPC::ReadResult<s64>(tmp->translated, Common::BitCast<s64>(tmp->value));
}

template <>
PowerPC::TryReadResult<float> TryReadValueFromEmulatedMemory(u32 addr,
PowerPC::RequestedAddressSpace space)
std::optional<PowerPC::ReadResult<float>>
TryReadValueFromEmulatedMemory(u32 addr, PowerPC::RequestedAddressSpace space)
{
return PowerPC::HostTryReadF32(addr, space);
}

template <>
PowerPC::TryReadResult<double> TryReadValueFromEmulatedMemory(u32 addr,
PowerPC::RequestedAddressSpace space)
std::optional<PowerPC::ReadResult<double>>
TryReadValueFromEmulatedMemory(u32 addr, PowerPC::RequestedAddressSpace space)
{
return PowerPC::HostTryReadF64(addr, space);
}
@@ -230,11 +230,11 @@ Cheats::NewSearch(const std::vector<Cheats::MemoryRange>& memory_ranges,
if (!current_value)
continue;

if (validator(current_value.value))
if (validator(current_value->value))
{
auto& r = results.emplace_back();
r.m_value = current_value.value;
r.m_value_state = current_value.translated ?
r.m_value = current_value->value;
r.m_value_state = current_value->translated ?
Cheats::SearchResultValueState::ValueFromVirtualMemory :
Cheats::SearchResultValueState::ValueFromPhysicalMemory;
r.m_address = addr;
@@ -284,11 +284,11 @@ Cheats::NextSearch(const std::vector<Cheats::SearchResult<T>>& previous_results,
// if the previous state was invalid we always update the value to avoid getting stuck in an
// invalid state
if (!previous_result.IsValueValid() ||
validator(current_value.value, previous_result.m_value))
validator(current_value->value, previous_result.m_value))
{
auto& r = results.emplace_back();
r.m_value = current_value.value;
r.m_value_state = current_value.translated ?
r.m_value = current_value->value;
r.m_value_state = current_value->translated ?
Cheats::SearchResultValueState::ValueFromVirtualMemory :
Cheats::SearchResultValueState::ValueFromPhysicalMemory;
r.m_address = addr;
@@ -279,10 +279,10 @@ struct DSP_Regs
struct DSPInitOptions
{
// DSP IROM blob, which is where the DSP boots from. Embedded into the DSP.
std::array<u16, DSP_IROM_SIZE> irom_contents;
std::array<u16, DSP_IROM_SIZE> irom_contents{};

// DSP DROM blob, which contains resampling coefficients.
std::array<u16, DSP_COEF_SIZE> coef_contents;
std::array<u16, DSP_COEF_SIZE> coef_contents{};

// Core used to emulate the DSP.
// Default: JIT64.

0 comments on commit 023eb0b

Please sign in to comment.