Skip to content

Commit dad7a32

Browse files
authored
Merge pull request #11534 from Pokechu22/warning-fixes-feb-2023
Resolve various compiler warnings
2 parents a88e5ef + 3024ca2 commit dad7a32

34 files changed

+418
-348
lines changed

Source/Core/Common/Debug/CodeTrace.cpp

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,21 @@ u32 GetMemoryTargetSize(std::string_view instr)
4848

4949
return 4;
5050
}
51+
52+
bool CompareMemoryTargetToTracked(const std::string& instr, const u32 mem_target,
53+
const std::set<u32>& mem_tracked)
54+
{
55+
// This function is hit often and should be optimized.
56+
auto it_lower = std::lower_bound(mem_tracked.begin(), mem_tracked.end(), mem_target);
57+
58+
if (it_lower == mem_tracked.end())
59+
return false;
60+
else if (*it_lower == mem_target)
61+
return true;
62+
63+
// If the base value doesn't hit, still need to check if longer values overlap.
64+
return *it_lower < mem_target + GetMemoryTargetSize(instr);
65+
}
5166
} // namespace
5267

5368
void CodeTrace::SetRegTracked(const std::string& reg)
@@ -124,21 +139,6 @@ TraceOutput CodeTrace::SaveCurrentInstruction() const
124139
return output;
125140
}
126141

127-
bool CompareMemoryTargetToTracked(const std::string& instr, const u32 mem_target,
128-
const std::set<u32>& mem_tracked)
129-
{
130-
// This function is hit often and should be optimized.
131-
auto it_lower = std::lower_bound(mem_tracked.begin(), mem_tracked.end(), mem_target);
132-
133-
if (it_lower == mem_tracked.end())
134-
return false;
135-
else if (*it_lower == mem_target)
136-
return true;
137-
138-
// If the base value doesn't hit, still need to check if longer values overlap.
139-
return *it_lower < mem_target + GetMemoryTargetSize(instr);
140-
}
141-
142142
AutoStepResults CodeTrace::AutoStepping(bool continue_previous, AutoStop stop_on)
143143
{
144144
AutoStepResults results;

Source/Core/Common/FatFsUtil.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -195,6 +195,7 @@ extern "C" DWORD get_fattime(void)
195195
return static_cast<DWORD>(s_callbacks->GetCurrentTimeFAT());
196196
}
197197

198+
#if FF_USE_LFN == 3 // match ff.h; currently unused by Dolphin
198199
extern "C" void* ff_memalloc(UINT msize)
199200
{
200201
return std::malloc(msize);
@@ -204,7 +205,9 @@ extern "C" void ff_memfree(void* mblock)
204205
{
205206
return std::free(mblock);
206207
}
208+
#endif
207209

210+
#if FF_FS_REENTRANT
208211
extern "C" int ff_cre_syncobj(BYTE vol, FF_SYNC_t* sobj)
209212
{
210213
*sobj = new std::recursive_mutex();
@@ -229,6 +232,7 @@ extern "C" int ff_del_syncobj(FF_SYNC_t sobj)
229232
delete reinterpret_cast<std::recursive_mutex*>(sobj);
230233
return 1;
231234
}
235+
#endif
232236

233237
static const char* FatFsErrorToString(FRESULT error_code)
234238
{

Source/Core/Core/Boot/Boot.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -502,8 +502,8 @@ bool CBoot::BootUp(Core::System& system, std::unique_ptr<BootParameters> boot)
502502

503503
struct BootTitle
504504
{
505-
BootTitle(Core::System& system, const std::vector<DiscIO::Riivolution::Patch>& patches)
506-
: system(system), config(SConfig::GetInstance()), riivolution_patches(patches)
505+
BootTitle(Core::System& system_, const std::vector<DiscIO::Riivolution::Patch>& patches)
506+
: system(system_), config(SConfig::GetInstance()), riivolution_patches(patches)
507507
{
508508
}
509509
bool operator()(BootParameters::Disc& disc) const

Source/Core/Core/FifoPlayer/FifoPlayer.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,14 @@ void FifoPlaybackAnalyzer::AnalyzeFrames(FifoDataFile* file,
101101
part_start = offset;
102102
// Copy cpmem now, because end_of_primitives isn't triggered until the first opcode after
103103
// primitive data, and the first opcode might update cpmem
104+
#ifdef __GNUC__
105+
#pragma GCC diagnostic push
106+
#pragma GCC diagnostic ignored "-Wclass-memaccess"
107+
#endif
104108
std::memcpy(&cpmem, &analyzer.m_cpmem, sizeof(CPState));
109+
#ifdef __GNUC__
110+
#pragma GCC diagnostic pop
111+
#endif
105112
}
106113
if (analyzer.m_end_of_primitives)
107114
{

Source/Core/Core/HW/AudioInterface.cpp

Lines changed: 33 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -292,21 +292,21 @@ void RegisterMMIO(MMIO::Mapping* mmio, u32 base)
292292
const AICR tmp_ai_ctrl(val);
293293

294294
auto& core_timing = system.GetCoreTiming();
295-
auto& state = system.GetAudioInterfaceState().GetData();
296-
if (state.control.AIINTMSK != tmp_ai_ctrl.AIINTMSK)
295+
auto& state_ = system.GetAudioInterfaceState().GetData();
296+
if (state_.control.AIINTMSK != tmp_ai_ctrl.AIINTMSK)
297297
{
298298
DEBUG_LOG_FMT(AUDIO_INTERFACE, "Change AIINTMSK to {}", tmp_ai_ctrl.AIINTMSK);
299-
state.control.AIINTMSK = tmp_ai_ctrl.AIINTMSK;
299+
state_.control.AIINTMSK = tmp_ai_ctrl.AIINTMSK;
300300
}
301301

302-
if (state.control.AIINTVLD != tmp_ai_ctrl.AIINTVLD)
302+
if (state_.control.AIINTVLD != tmp_ai_ctrl.AIINTVLD)
303303
{
304304
DEBUG_LOG_FMT(AUDIO_INTERFACE, "Change AIINTVLD to {}", tmp_ai_ctrl.AIINTVLD);
305-
state.control.AIINTVLD = tmp_ai_ctrl.AIINTVLD;
305+
state_.control.AIINTVLD = tmp_ai_ctrl.AIINTVLD;
306306
}
307307

308308
// Set frequency of streaming audio
309-
if (tmp_ai_ctrl.AISFR != state.control.AISFR)
309+
if (tmp_ai_ctrl.AISFR != state_.control.AISFR)
310310
{
311311
// AISFR rates below are intentionally inverted wrt yagcd
312312
DEBUG_LOG_FMT(AUDIO_INTERFACE, "Change AISFR to {}",
@@ -315,79 +315,79 @@ void RegisterMMIO(MMIO::Mapping* mmio, u32 base)
315315
}
316316

317317
// Set frequency of DMA
318-
if (tmp_ai_ctrl.AIDFR != state.control.AIDFR)
318+
if (tmp_ai_ctrl.AIDFR != state_.control.AIDFR)
319319
{
320320
DEBUG_LOG_FMT(AUDIO_INTERFACE, "Change AIDFR to {}",
321321
tmp_ai_ctrl.AIDFR ? "32khz" : "48khz");
322322
SetAIDSampleRate(tmp_ai_ctrl.AIDFR ? SampleRate::AI32KHz : SampleRate::AI48KHz);
323323
}
324324

325325
// Streaming counter
326-
if (tmp_ai_ctrl.PSTAT != state.control.PSTAT)
326+
if (tmp_ai_ctrl.PSTAT != state_.control.PSTAT)
327327
{
328328
DEBUG_LOG_FMT(AUDIO_INTERFACE, "{} streaming audio",
329329
tmp_ai_ctrl.PSTAT ? "start" : "stop");
330-
state.control.PSTAT = tmp_ai_ctrl.PSTAT;
331-
state.last_cpu_time = core_timing.GetTicks();
330+
state_.control.PSTAT = tmp_ai_ctrl.PSTAT;
331+
state_.last_cpu_time = core_timing.GetTicks();
332332

333-
core_timing.RemoveEvent(state.event_type_ai);
334-
core_timing.ScheduleEvent(GetAIPeriod(), state.event_type_ai);
333+
core_timing.RemoveEvent(state_.event_type_ai);
334+
core_timing.ScheduleEvent(GetAIPeriod(), state_.event_type_ai);
335335
}
336336

337337
// AI Interrupt
338338
if (tmp_ai_ctrl.AIINT)
339339
{
340340
DEBUG_LOG_FMT(AUDIO_INTERFACE, "Clear AIS Interrupt");
341-
state.control.AIINT = 0;
341+
state_.control.AIINT = 0;
342342
}
343343

344344
// Sample Count Reset
345345
if (tmp_ai_ctrl.SCRESET)
346346
{
347347
DEBUG_LOG_FMT(AUDIO_INTERFACE, "Reset AIS sample counter");
348-
state.sample_counter = 0;
348+
state_.sample_counter = 0;
349349

350-
state.last_cpu_time = core_timing.GetTicks();
350+
state_.last_cpu_time = core_timing.GetTicks();
351351
}
352352

353353
UpdateInterrupts();
354354
}));
355355

356356
mmio->Register(base | AI_VOLUME_REGISTER, MMIO::DirectRead<u32>(&state.volume.hex),
357357
MMIO::ComplexWrite<u32>([](Core::System& system, u32, u32 val) {
358-
auto& state = system.GetAudioInterfaceState().GetData();
359-
state.volume.hex = val;
358+
auto& state_ = system.GetAudioInterfaceState().GetData();
359+
state_.volume.hex = val;
360360
SoundStream* sound_stream = system.GetSoundStream();
361-
sound_stream->GetMixer()->SetStreamingVolume(state.volume.left,
362-
state.volume.right);
361+
sound_stream->GetMixer()->SetStreamingVolume(state_.volume.left,
362+
state_.volume.right);
363363
}));
364364

365365
mmio->Register(base | AI_SAMPLE_COUNTER, MMIO::ComplexRead<u32>([](Core::System& system, u32) {
366-
auto& state = system.GetAudioInterfaceState().GetData();
366+
auto& state_ = system.GetAudioInterfaceState().GetData();
367367
const u64 cycles_streamed =
368-
IsPlaying() ? (system.GetCoreTiming().GetTicks() - state.last_cpu_time) :
369-
state.last_cpu_time;
370-
return state.sample_counter +
371-
static_cast<u32>(cycles_streamed / state.cpu_cycles_per_sample);
368+
IsPlaying() ? (system.GetCoreTiming().GetTicks() - state_.last_cpu_time) :
369+
state_.last_cpu_time;
370+
return state_.sample_counter +
371+
static_cast<u32>(cycles_streamed / state_.cpu_cycles_per_sample);
372372
}),
373373
MMIO::ComplexWrite<u32>([](Core::System& system, u32, u32 val) {
374374
auto& core_timing = system.GetCoreTiming();
375-
auto& state = system.GetAudioInterfaceState().GetData();
376-
state.sample_counter = val;
377-
state.last_cpu_time = core_timing.GetTicks();
378-
core_timing.RemoveEvent(state.event_type_ai);
379-
core_timing.ScheduleEvent(GetAIPeriod(), state.event_type_ai);
375+
auto& state_ = system.GetAudioInterfaceState().GetData();
376+
state_.sample_counter = val;
377+
state_.last_cpu_time = core_timing.GetTicks();
378+
core_timing.RemoveEvent(state_.event_type_ai);
379+
core_timing.ScheduleEvent(GetAIPeriod(), state_.event_type_ai);
380380
}));
381381

382382
mmio->Register(base | AI_INTERRUPT_TIMING, MMIO::DirectRead<u32>(&state.interrupt_timing),
383383
MMIO::ComplexWrite<u32>([](Core::System& system, u32, u32 val) {
384384
auto& core_timing = system.GetCoreTiming();
385-
auto& state = system.GetAudioInterfaceState().GetData();
385+
auto& state_ = system.GetAudioInterfaceState().GetData();
386386
DEBUG_LOG_FMT(AUDIO_INTERFACE, "AI_INTERRUPT_TIMING={:08x} at PC: {:08x}", val,
387387
system.GetPPCState().pc);
388-
state.interrupt_timing = val;
389-
core_timing.RemoveEvent(state.event_type_ai);
390-
core_timing.ScheduleEvent(GetAIPeriod(), state.event_type_ai);
388+
state_.interrupt_timing = val;
389+
core_timing.RemoveEvent(state_.event_type_ai);
390+
core_timing.ScheduleEvent(GetAIPeriod(), state_.event_type_ai);
391391
}));
392392
}
393393

0 commit comments

Comments
 (0)