core: Make variable shadowing a compile-time error

Now that we have most of core free of shadowing, we can enable the
warning as an error to catch anything that may be remaining and also
eliminate this class of logic bug entirely.
This commit is contained in:
Lioncash 2021-05-16 01:46:30 -04:00
parent 06c410ee88
commit 9a07ed53eb
99 changed files with 304 additions and 279 deletions

View file

@ -10,8 +10,8 @@ namespace Service::Time::Clock {
class EphemeralNetworkSystemClockCore final : public SystemClockCore {
public:
explicit EphemeralNetworkSystemClockCore(SteadyClockCore& steady_clock_core)
: SystemClockCore{steady_clock_core} {}
explicit EphemeralNetworkSystemClockCore(SteadyClockCore& steady_clock_core_)
: SystemClockCore{steady_clock_core_} {}
};
} // namespace Service::Time::Clock

View file

@ -12,8 +12,8 @@ namespace Service::Time::Clock {
class LocalSystemClockContextWriter final : public SystemClockContextUpdateCallback {
public:
explicit LocalSystemClockContextWriter(SharedMemory& shared_memory)
: SystemClockContextUpdateCallback{}, shared_memory{shared_memory} {}
explicit LocalSystemClockContextWriter(SharedMemory& shared_memory_)
: SystemClockContextUpdateCallback{}, shared_memory{shared_memory_} {}
protected:
ResultCode Update() override {

View file

@ -12,8 +12,8 @@ namespace Service::Time::Clock {
class NetworkSystemClockContextWriter final : public SystemClockContextUpdateCallback {
public:
explicit NetworkSystemClockContextWriter(SharedMemory& shared_memory)
: SystemClockContextUpdateCallback{}, shared_memory{shared_memory} {}
explicit NetworkSystemClockContextWriter(SharedMemory& shared_memory_)
: SystemClockContextUpdateCallback{}, shared_memory{shared_memory_} {}
protected:
ResultCode Update() override {

View file

@ -10,8 +10,8 @@ namespace Service::Time::Clock {
class StandardLocalSystemClockCore final : public SystemClockCore {
public:
explicit StandardLocalSystemClockCore(SteadyClockCore& steady_clock_core)
: SystemClockCore{steady_clock_core} {}
explicit StandardLocalSystemClockCore(SteadyClockCore& steady_clock_core_)
: SystemClockCore{steady_clock_core_} {}
};
} // namespace Service::Time::Clock

View file

@ -16,21 +16,21 @@ namespace Service::Time::Clock {
class StandardNetworkSystemClockCore final : public SystemClockCore {
public:
explicit StandardNetworkSystemClockCore(SteadyClockCore& steady_clock_core)
: SystemClockCore{steady_clock_core} {}
explicit StandardNetworkSystemClockCore(SteadyClockCore& steady_clock_core_)
: SystemClockCore{steady_clock_core_} {}
void SetStandardNetworkClockSufficientAccuracy(TimeSpanType value) {
standard_network_clock_sufficient_accuracy = value;
}
bool IsStandardNetworkSystemClockAccuracySufficient(Core::System& system) const {
SystemClockContext context{};
if (GetClockContext(system, context) != RESULT_SUCCESS) {
SystemClockContext clock_ctx{};
if (GetClockContext(system, clock_ctx) != RESULT_SUCCESS) {
return {};
}
s64 span{};
if (context.steady_time_point.GetSpanBetween(
if (clock_ctx.steady_time_point.GetSpanBetween(
GetSteadyClockCore().GetCurrentTimePoint(system), span) != RESULT_SUCCESS) {
return {};
}

View file

@ -11,13 +11,13 @@
namespace Service::Time::Clock {
StandardUserSystemClockCore::StandardUserSystemClockCore(
StandardLocalSystemClockCore& local_system_clock_core,
StandardNetworkSystemClockCore& network_system_clock_core, Core::System& system)
: SystemClockCore(local_system_clock_core.GetSteadyClockCore()),
local_system_clock_core{local_system_clock_core},
network_system_clock_core{network_system_clock_core}, auto_correction_enabled{},
StandardLocalSystemClockCore& local_system_clock_core_,
StandardNetworkSystemClockCore& network_system_clock_core_, Core::System& system_)
: SystemClockCore(local_system_clock_core_.GetSteadyClockCore()),
local_system_clock_core{local_system_clock_core_},
network_system_clock_core{network_system_clock_core_},
auto_correction_time{SteadyClockTimePoint::GetRandom()}, auto_correction_event{
system.Kernel()} {
system_.Kernel()} {
Kernel::KAutoObject::Create(std::addressof(auto_correction_event));
auto_correction_event.Initialize("StandardUserSystemClockCore:AutoCorrectionEvent");
}
@ -35,13 +35,13 @@ ResultCode StandardUserSystemClockCore::SetAutomaticCorrectionEnabled(Core::Syst
}
ResultCode StandardUserSystemClockCore::GetClockContext(Core::System& system,
SystemClockContext& context) const {
SystemClockContext& ctx) const {
if (const ResultCode result{ApplyAutomaticCorrection(system, false)};
result != RESULT_SUCCESS) {
return result;
}
return local_system_clock_core.GetClockContext(system, context);
return local_system_clock_core.GetClockContext(system, ctx);
}
ResultCode StandardUserSystemClockCore::Flush(const SystemClockContext&) {
@ -64,13 +64,13 @@ ResultCode StandardUserSystemClockCore::ApplyAutomaticCorrection(Core::System& s
return ERROR_UNINITIALIZED_CLOCK;
}
SystemClockContext context{};
if (const ResultCode result{network_system_clock_core.GetClockContext(system, context)};
SystemClockContext ctx{};
if (const ResultCode result{network_system_clock_core.GetClockContext(system, ctx)};
result != RESULT_SUCCESS) {
return result;
}
local_system_clock_core.SetClockContext(context);
local_system_clock_core.SetClockContext(ctx);
return RESULT_SUCCESS;
}

View file

@ -23,13 +23,13 @@ class StandardNetworkSystemClockCore;
class StandardUserSystemClockCore final : public SystemClockCore {
public:
StandardUserSystemClockCore(StandardLocalSystemClockCore& local_system_clock_core,
StandardNetworkSystemClockCore& network_system_clock_core,
Core::System& system);
StandardUserSystemClockCore(StandardLocalSystemClockCore& local_system_clock_core_,
StandardNetworkSystemClockCore& network_system_clock_core_,
Core::System& system_);
ResultCode SetAutomaticCorrectionEnabled(Core::System& system, bool value);
ResultCode GetClockContext(Core::System& system, SystemClockContext& context) const override;
ResultCode GetClockContext(Core::System& system, SystemClockContext& ctx) const override;
bool IsAutomaticCorrectionEnabled() const {
return auto_correction_enabled;

View file

@ -8,8 +8,8 @@
namespace Service::Time::Clock {
SystemClockCore::SystemClockCore(SteadyClockCore& steady_clock_core)
: steady_clock_core{steady_clock_core} {
SystemClockCore::SystemClockCore(SteadyClockCore& steady_clock_core_)
: steady_clock_core{steady_clock_core_} {
context.steady_time_point.clock_source_id = steady_clock_core.GetClockSourceId();
}

View file

@ -21,7 +21,7 @@ class SystemClockContextUpdateCallback;
class SystemClockCore {
public:
explicit SystemClockCore(SteadyClockCore& steady_clock_core);
explicit SystemClockCore(SteadyClockCore& steady_clock_core_);
virtual ~SystemClockCore();
SteadyClockCore& GetSteadyClockCore() const {

View file

@ -223,7 +223,7 @@ struct TimeManager::Impl final {
TimeZone::TimeZoneContentManager time_zone_content_manager;
};
TimeManager::TimeManager(Core::System& system) : system{system} {}
TimeManager::TimeManager(Core::System& system_) : system{system_} {}
TimeManager::~TimeManager() = default;

View file

@ -30,7 +30,7 @@ class NetworkSystemClockContextWriter;
class TimeManager final {
public:
explicit TimeManager(Core::System& system);
explicit TimeManager(Core::System& system_);
~TimeManager();
void Initialize();

View file

@ -15,7 +15,7 @@ namespace Service::Time {
static constexpr std::size_t SHARED_MEMORY_SIZE{0x1000};
SharedMemory::SharedMemory(Core::System& system) : system(system) {
SharedMemory::SharedMemory(Core::System& system_) : system(system_) {
std::memset(system.Kernel().GetTimeSharedMem().GetPointer(), 0, SHARED_MEMORY_SIZE);
}

View file

@ -14,7 +14,7 @@ namespace Service::Time {
class SharedMemory final {
public:
explicit SharedMemory(Core::System& system);
explicit SharedMemory(Core::System& system_);
~SharedMemory();
// TODO(ogniK): We have to properly simulate memory barriers, how are we going to do this?

View file

@ -68,8 +68,8 @@ static std::vector<std::string> BuildLocationNameCache(Core::System& system) {
return location_name_cache;
}
TimeZoneContentManager::TimeZoneContentManager(Core::System& system)
: system{system}, location_name_cache{BuildLocationNameCache(system)} {}
TimeZoneContentManager::TimeZoneContentManager(Core::System& system_)
: system{system_}, location_name_cache{BuildLocationNameCache(system)} {}
void TimeZoneContentManager::Initialize(TimeManager& time_manager) {
std::string location_name;

View file

@ -21,7 +21,7 @@ namespace Service::Time::TimeZone {
class TimeZoneContentManager final {
public:
explicit TimeZoneContentManager(Core::System& system);
explicit TimeZoneContentManager(Core::System& system_);
void Initialize(TimeManager& time_manager);