Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Merge pull request #11572 from Pokechu22/uninitialized-variables-feb-…
…2023

Fix uninitialized variable warnings (C26495)
  • Loading branch information
lioncash committed Feb 16, 2023
2 parents 089eab9 + 74a14c7 commit 19bf13d
Show file tree
Hide file tree
Showing 31 changed files with 197 additions and 198 deletions.
2 changes: 2 additions & 0 deletions Source/Core/Common/Arm64Emitter.h
Expand Up @@ -484,12 +484,14 @@ class ArithOption
m_width = WidthSpecifier::Width64Bit;
if (shift == 64)
m_shift = 0;
m_extend = ExtendSpecifier::UXTX;
}
else
{
m_width = WidthSpecifier::Width32Bit;
if (shift == 32)
m_shift = 0;
m_extend = ExtendSpecifier::UXTW;
}
}
ARM64Reg GetReg() const { return m_destReg; }
Expand Down
2 changes: 1 addition & 1 deletion Source/Core/Common/Debug/CodeTrace.h
Expand Up @@ -31,7 +31,7 @@ struct InstructionAttributes

struct TraceOutput
{
u32 address;
u32 address = 0;
std::optional<u32> memory_target = std::nullopt;
std::string instruction;
};
Expand Down
4 changes: 2 additions & 2 deletions Source/Core/Common/FatFsUtil.cpp
Expand Up @@ -160,8 +160,8 @@ class SDCardFatFsCallbacks : public Common::FatFsCallbacks
return GetSystemTimeFAT();
}

File::IOFile* m_image;
bool m_deterministic;
File::IOFile* m_image = nullptr;
bool m_deterministic = false;
};
} // namespace

Expand Down
2 changes: 1 addition & 1 deletion Source/Core/Core/HW/AudioInterface.cpp
Expand Up @@ -124,7 +124,7 @@ struct AudioInterfaceState::Data
u32 ais_sample_rate_divisor = Mixer::FIXED_SAMPLE_RATE_DIVIDEND / 48000;
u32 aid_sample_rate_divisor = Mixer::FIXED_SAMPLE_RATE_DIVIDEND / 32000;

CoreTiming::EventType* event_type_ai;
CoreTiming::EventType* event_type_ai = nullptr;
};

AudioInterfaceState::AudioInterfaceState() : m_data(std::make_unique<Data>())
Expand Down
8 changes: 4 additions & 4 deletions Source/Core/Core/HW/DSP.cpp
Expand Up @@ -137,16 +137,16 @@ struct DSPState::Data
// Contains bitfields for some stuff we don't care about (and nothing ever reads):
// CAS latency/burst length/addressing mode/write mode
// We care about the LSB tho. It indicates that the ARAM controller has finished initializing
u16 aram_mode;
u16 aram_refresh;
u16 aram_mode = 0;
u16 aram_refresh = 0;
int dsp_slice = 0;

std::unique_ptr<DSPEmulator> dsp_emulator;

bool is_lle = false;

CoreTiming::EventType* event_type_generate_dsp_interrupt;
CoreTiming::EventType* event_type_complete_aram;
CoreTiming::EventType* event_type_generate_dsp_interrupt = nullptr;
CoreTiming::EventType* event_type_complete_aram = nullptr;
};

DSPState::DSPState() : m_data(std::make_unique<Data>())
Expand Down
44 changes: 22 additions & 22 deletions Source/Core/Core/HW/DVD/DVDInterface.cpp
Expand Up @@ -138,48 +138,48 @@ struct DVDInterfaceState::Data
// Hardware registers
UDISR DISR;
UDICVR DICVR;
u32 DICMDBUF[3];
u32 DIMAR;
u32 DILENGTH;
std::array<u32, 3> DICMDBUF{};
u32 DIMAR = 0;
u32 DILENGTH = 0;
UDICR DICR;
u32 DIIMMBUF;
u32 DIIMMBUF = 0;
UDICFG DICFG;

StreamADPCM::ADPCMDecoder adpcm_decoder;

// DTK
bool stream = false;
bool stop_at_track_end = false;
u64 audio_position;
u64 current_start;
u32 current_length;
u64 next_start;
u32 next_length;
u32 pending_samples;
u64 audio_position = 0;
u64 current_start = 0;
u32 current_length = 0;
u64 next_start = 0;
u32 next_length = 0;
u32 pending_samples = 0;
bool enable_dtk = false;
u8 dtk_buffer_length = 0; // TODO: figure out how this affects the regular buffer

// Disc drive state
DriveState drive_state;
DriveError error_code;
u64 disc_end_offset;
DriveState drive_state = DriveState::Ready;
DriveError error_code = DriveError::None;
u64 disc_end_offset = 0;

// Disc drive timing
u64 read_buffer_start_time;
u64 read_buffer_end_time;
u64 read_buffer_start_offset;
u64 read_buffer_end_offset;
u64 read_buffer_start_time = 0;
u64 read_buffer_end_time = 0;
u64 read_buffer_start_offset = 0;
u64 read_buffer_end_offset = 0;

// Disc changing
std::string disc_path_to_insert;
std::vector<std::string> auto_disc_change_paths;
size_t auto_disc_change_index;
size_t auto_disc_change_index = 0;

// Events
CoreTiming::EventType* finish_executing_command;
CoreTiming::EventType* auto_change_disc;
CoreTiming::EventType* eject_disc;
CoreTiming::EventType* insert_disc;
CoreTiming::EventType* finish_executing_command = nullptr;
CoreTiming::EventType* auto_change_disc = nullptr;
CoreTiming::EventType* eject_disc = nullptr;
CoreTiming::EventType* insert_disc = nullptr;
};

DVDInterfaceState::DVDInterfaceState() : m_data(std::make_unique<Data>())
Expand Down
2 changes: 1 addition & 1 deletion Source/Core/Core/HW/DVD/DVDThread.cpp
Expand Up @@ -76,7 +76,7 @@ static void FinishRead(Core::System& system, u64 id, s64 cycles_late);

struct DVDThreadState::Data
{
CoreTiming::EventType* finish_read;
CoreTiming::EventType* finish_read = nullptr;

u64 next_id = 0;

Expand Down
2 changes: 1 addition & 1 deletion Source/Core/Core/HW/DVD/FileMonitor.h
Expand Up @@ -18,6 +18,6 @@ class FileLogger

private:
DiscIO::Partition m_previous_partition;
u64 m_previous_file_offset;
u64 m_previous_file_offset = 0;
};
} // namespace FileMonitor
6 changes: 3 additions & 3 deletions Source/Core/Core/HW/EXI/EXI.cpp
Expand Up @@ -29,10 +29,10 @@ namespace ExpansionInterface
{
struct ExpansionInterfaceState::Data
{
CoreTiming::EventType* event_type_change_device;
CoreTiming::EventType* event_type_update_interrupts;
CoreTiming::EventType* event_type_change_device = nullptr;
CoreTiming::EventType* event_type_update_interrupts = nullptr;

std::array<std::unique_ptr<CEXIChannel>, MAX_EXI_CHANNELS> channels;
std::array<std::unique_ptr<CEXIChannel>, MAX_EXI_CHANNELS> channels{};

bool using_overridden_sram = false;
};
Expand Down
2 changes: 1 addition & 1 deletion Source/Core/Core/HW/GPFifo.h
Expand Up @@ -57,7 +57,7 @@ class GPFifoManager final
void SetGatherPipeCount(size_t size);

// More room for the fastmodes
alignas(GATHER_PIPE_SIZE) u8 m_gather_pipe[GATHER_PIPE_EXTRA_SIZE];
alignas(GATHER_PIPE_SIZE) u8 m_gather_pipe[GATHER_PIPE_EXTRA_SIZE]{};

Core::System& m_system;
};
Expand Down
12 changes: 6 additions & 6 deletions Source/Core/Core/HW/SI/SI.cpp
Expand Up @@ -201,19 +201,19 @@ union USIEXIClockCount

struct SerialInterfaceState::Data
{
CoreTiming::EventType* event_type_change_device;
CoreTiming::EventType* event_type_tranfer_pending;
std::array<CoreTiming::EventType*, MAX_SI_CHANNELS> event_types_device;
CoreTiming::EventType* event_type_change_device = nullptr;
CoreTiming::EventType* event_type_tranfer_pending = nullptr;
std::array<CoreTiming::EventType*, MAX_SI_CHANNELS> event_types_device{};

// User-configured device type. possibly overridden by TAS/Netplay
std::array<std::atomic<SIDevices>, MAX_SI_CHANNELS> desired_device_types;
std::array<std::atomic<SIDevices>, MAX_SI_CHANNELS> desired_device_types{};

std::array<SSIChannel, MAX_SI_CHANNELS> channel;
std::array<SSIChannel, MAX_SI_CHANNELS> channel{};
USIPoll poll;
USIComCSR com_csr;
USIStatusReg status_reg;
USIEXIClockCount exi_clock_count;
std::array<u8, 128> si_buffer;
std::array<u8, 128> si_buffer{};
};

SerialInterfaceState::SerialInterfaceState() : m_data(std::make_unique<Data>())
Expand Down
6 changes: 3 additions & 3 deletions Source/Core/Core/HW/Sram.h
Expand Up @@ -122,9 +122,9 @@ struct SramSettingsEx

struct Sram
{
Common::BigEndianValue<u32> rtc;
SramSettings settings;
SramSettingsEx settings_ex;
Common::BigEndianValue<u32> rtc{};
SramSettings settings{};
SramSettingsEx settings_ex{};
// Allow access to this entire structure as a raw blob
// Typical union-with-byte-array method can't be used here on GCC
u8& operator[](size_t offset) { return reinterpret_cast<u8*>(&rtc)[offset]; }
Expand Down
18 changes: 9 additions & 9 deletions Source/Core/Core/HW/VideoInterface.cpp
Expand Up @@ -51,8 +51,8 @@ struct VideoInterfaceState::Data
UVIFBInfoRegister xfb_info_bottom;
UVIFBInfoRegister xfb_3d_info_top; // Start making your stereoscopic demos! :p
UVIFBInfoRegister xfb_3d_info_bottom;
std::array<UVIInterruptRegister, 4> interrupt_register;
std::array<UVILatchRegister, 2> latch_register;
std::array<UVIInterruptRegister, 4> interrupt_register{};
std::array<UVILatchRegister, 2> latch_register{};
PictureConfigurationRegister picture_configuration;
UVIHorizontalScaling horizontal_scaling;
SVIFilterCoefTables filter_coef_tables;
Expand All @@ -68,15 +68,15 @@ struct VideoInterfaceState::Data
u32 target_refresh_rate_numerator = 0;
u32 target_refresh_rate_denominator = 1;

u64 ticks_last_line_start; // number of ticks when the current full scanline started
u32 half_line_count; // number of halflines that have occurred for this full frame
u32 half_line_of_next_si_poll; // halfline when next SI poll results should be available
u64 ticks_last_line_start = 0; // number of ticks when the current full scanline started
u32 half_line_count = 0; // number of halflines that have occurred for this full frame
u32 half_line_of_next_si_poll = 0; // halfline when next SI poll results should be available

// below indexes are 0-based
u32 even_field_first_hl; // index first halfline of the even field
u32 odd_field_first_hl; // index first halfline of the odd field
u32 even_field_last_hl; // index last halfline of the even field
u32 odd_field_last_hl; // index last halfline of the odd field
u32 even_field_first_hl = 0; // index first halfline of the even field
u32 odd_field_first_hl = 0; // index first halfline of the odd field
u32 even_field_last_hl = 0; // index last halfline of the even field
u32 odd_field_last_hl = 0; // index last halfline of the odd field
};

VideoInterfaceState::VideoInterfaceState() : m_data(std::make_unique<Data>())
Expand Down
26 changes: 13 additions & 13 deletions Source/Core/Core/HW/VideoInterface.h
Expand Up @@ -133,7 +133,7 @@ union UVIDisplayControlRegister

union UVIHorizontalTiming0
{
u32 Hex;
u32 Hex = 0;
struct
{
u16 Lo, Hi;
Expand All @@ -151,7 +151,7 @@ union UVIHorizontalTiming0

union UVIHorizontalTiming1
{
u32 Hex;
u32 Hex = 0;
struct
{
u16 Lo, Hi;
Expand All @@ -168,7 +168,7 @@ union UVIHorizontalTiming1
// Exists for both odd and even fields
union UVIVBlankTimingRegister
{
u32 Hex;
u32 Hex = 0;
struct
{
u16 Lo, Hi;
Expand All @@ -185,7 +185,7 @@ union UVIVBlankTimingRegister
// Exists for both odd and even fields
union UVIBurstBlankingRegister
{
u32 Hex;
u32 Hex = 0;
struct
{
u16 Lo, Hi;
Expand All @@ -201,7 +201,7 @@ union UVIBurstBlankingRegister

union UVIFBInfoRegister
{
u32 Hex;
u32 Hex = 0;
struct
{
u16 Lo, Hi;
Expand All @@ -221,7 +221,7 @@ union UVIFBInfoRegister
// VI Interrupt Register
union UVIInterruptRegister
{
u32 Hex;
u32 Hex = 0;
struct
{
u16 Lo, Hi;
Expand All @@ -240,7 +240,7 @@ union UVIInterruptRegister

union UVILatchRegister
{
u32 Hex;
u32 Hex = 0;
struct
{
u16 Lo, Hi;
Expand All @@ -257,7 +257,7 @@ union UVILatchRegister

union PictureConfigurationRegister
{
u16 Hex;
u16 Hex = 0;
struct
{
u16 STD : 8;
Expand All @@ -284,7 +284,7 @@ union UVIHorizontalScaling
// Used for tables 0-2
union UVIFilterCoefTable3
{
u32 Hex;
u32 Hex = 0;
struct
{
u16 Lo, Hi;
Expand All @@ -301,7 +301,7 @@ union UVIFilterCoefTable3
// Used for tables 3-6
union UVIFilterCoefTable4
{
u32 Hex;
u32 Hex = 0;
struct
{
u16 Lo, Hi;
Expand All @@ -324,7 +324,7 @@ struct SVIFilterCoefTables
// Debug video mode only, probably never used in Dolphin...
union UVIBorderBlankRegister
{
u32 Hex;
u32 Hex = 0;
struct
{
u16 Lo, Hi;
Expand All @@ -341,7 +341,7 @@ union UVIBorderBlankRegister
// ntsc-j and component cable bits
union UVIDTVStatus
{
u16 Hex;
u16 Hex = 0;
struct
{
u16 component_plugged : 1;
Expand All @@ -352,7 +352,7 @@ union UVIDTVStatus

union UVIHorizontalStepping
{
u16 Hex;
u16 Hex = 0;
struct
{
u16 srcwidth : 10;
Expand Down
2 changes: 1 addition & 1 deletion Source/Core/Core/IOS/Network/KD/VFF/VFFUtil.cpp
Expand Up @@ -253,7 +253,7 @@ class VffFatFsCallbacks : public Common::FatFsCallbacks

int DiskIOCtl(u8 pdrv, u8 cmd, void* buff) override { return vff_ioctl(m_vff, pdrv, cmd, buff); }

IOS::HLE::FS::FileHandle* m_vff;
IOS::HLE::FS::FileHandle* m_vff = nullptr;
};
} // namespace

Expand Down
Expand Up @@ -40,7 +40,7 @@ struct CachedInterpreter::Instruction

union
{
const CommonCallback common_callback;
const CommonCallback common_callback = nullptr;
const ConditionalCallback conditional_callback;
};

Expand Down

0 comments on commit 19bf13d

Please sign in to comment.