From dcb91ca4a4a97d279d01ebe010e07298acca1ba9 Mon Sep 17 00:00:00 2001 From: Lioncash Date: Mon, 26 Apr 2021 09:11:33 -0400 Subject: service: Eliminate cases of member shadowing Resolves a few localized instances of member variable shadowing. Brings us a little closer to turning shadowing warnings into errors. --- src/core/hle/service/am/applets/error.cpp | 6 +++--- .../hle/service/am/applets/general_backend.cpp | 2 +- src/core/hle/service/bcat/backend/boxcat.cpp | 4 ++-- src/core/hle/service/bcat/module.cpp | 22 ++++++++++++------- src/core/hle/service/filesystem/fsp_srv.cpp | 21 +++++++++--------- src/core/hle/service/nvflinger/nvflinger.cpp | 14 ++++++------ .../time/standard_user_system_clock_core.cpp | 4 ++-- .../service/time/standard_user_system_clock_core.h | 2 +- src/core/hle/service/time/system_clock_core.cpp | 10 ++++----- src/core/hle/service/time/system_clock_core.h | 2 +- src/core/hle/service/time/time_manager.cpp | 22 +++++++++---------- src/core/hle/service/time/time_sharedmemory.cpp | 3 +-- src/core/hle/service/time/time_sharedmemory.h | 4 ++-- src/core/hle/service/vi/display/vi_display.cpp | 25 +++++++++++----------- src/core/hle/service/vi/display/vi_display.h | 16 +++++++------- 15 files changed, 81 insertions(+), 76 deletions(-) (limited to 'src') diff --git a/src/core/hle/service/am/applets/error.cpp b/src/core/hle/service/am/applets/error.cpp index 23e30aa45..0dd6ec68e 100644 --- a/src/core/hle/service/am/applets/error.cpp +++ b/src/core/hle/service/am/applets/error.cpp @@ -158,11 +158,11 @@ void Error::Execute() { break; case ErrorAppletMode::ShowSystemError: case ErrorAppletMode::ShowApplicationError: { - const auto system = mode == ErrorAppletMode::ShowSystemError; + const auto is_system = mode == ErrorAppletMode::ShowSystemError; const auto& main_text = - system ? args->system_error.main_text : args->application_error.main_text; + is_system ? args->system_error.main_text : args->application_error.main_text; const auto& detail_text = - system ? args->system_error.detail_text : args->application_error.detail_text; + is_system ? args->system_error.detail_text : args->application_error.detail_text; const auto main_text_string = Common::StringFromFixedZeroTerminatedBuffer(main_text.data(), main_text.size()); diff --git a/src/core/hle/service/am/applets/general_backend.cpp b/src/core/hle/service/am/applets/general_backend.cpp index b26abad36..b7483261e 100644 --- a/src/core/hle/service/am/applets/general_backend.cpp +++ b/src/core/hle/service/am/applets/general_backend.cpp @@ -96,7 +96,7 @@ void Auth::Execute() { switch (type) { case AuthAppletType::ShowParentalAuthentication: { - const auto callback = [this](bool successful) { AuthFinished(successful); }; + const auto callback = [this](bool is_successful) { AuthFinished(is_successful); }; if (arg0 == 1 && arg1 == 0 && arg2 == 1) { // ShowAuthenticatorForConfiguration diff --git a/src/core/hle/service/bcat/backend/boxcat.cpp b/src/core/hle/service/bcat/backend/boxcat.cpp index 78c047bd2..cee1774d1 100644 --- a/src/core/hle/service/bcat/backend/boxcat.cpp +++ b/src/core/hle/service/bcat/backend/boxcat.cpp @@ -415,9 +415,9 @@ std::optional> Boxcat::GetLaunchParameter(TitleIDVersion title) if (Settings::values.bcat_boxcat_local) { LOG_INFO(Service_BCAT, "Boxcat using local data by override, skipping download."); } else { - Boxcat::Client client{path, title.title_id, title.build_id}; + Client launch_client{path, title.title_id, title.build_id}; - const auto res = client.DownloadLaunchParam(); + const auto res = launch_client.DownloadLaunchParam(); if (res != DownloadResult::Success) { LOG_ERROR(Service_BCAT, "Boxcat synchronization failed with error '{}'!", res); diff --git a/src/core/hle/service/bcat/module.cpp b/src/core/hle/service/bcat/module.cpp index c7dd04a6e..285085f2a 100644 --- a/src/core/hle/service/bcat/module.cpp +++ b/src/core/hle/service/bcat/module.cpp @@ -174,9 +174,9 @@ private: }; std::shared_ptr CreateProgressService(SyncType type) { - auto& backend{progress.at(static_cast(type))}; - return std::make_shared(system, backend.GetEvent(), - backend.GetImpl()); + auto& progress_backend{GetProgressBackend(type)}; + return std::make_shared(system, progress_backend.GetEvent(), + progress_backend.GetImpl()); } void RequestSyncDeliveryCache(Kernel::HLERequestContext& ctx) { @@ -184,7 +184,7 @@ private: backend.Synchronize({system.CurrentProcess()->GetTitleID(), GetCurrentBuildID(system.GetCurrentProcessBuildID())}, - progress.at(static_cast(SyncType::Normal))); + GetProgressBackend(SyncType::Normal)); IPC::ResponseBuilder rb{ctx, 2, 0, 1}; rb.Push(RESULT_SUCCESS); @@ -201,8 +201,7 @@ private: backend.SynchronizeDirectory({system.CurrentProcess()->GetTitleID(), GetCurrentBuildID(system.GetCurrentProcessBuildID())}, - name, - progress.at(static_cast(SyncType::Directory))); + name, GetProgressBackend(SyncType::Directory)); IPC::ResponseBuilder rb{ctx, 2, 0, 1}; rb.Push(RESULT_SUCCESS); @@ -265,9 +264,16 @@ private: rb.Push(RESULT_SUCCESS); } - Backend& backend; + ProgressServiceBackend& GetProgressBackend(SyncType type) { + return progress.at(static_cast(type)); + } - std::array(SyncType::Count)> progress; + const ProgressServiceBackend& GetProgressBackend(SyncType type) const { + return progress.at(static_cast(type)); + } + + Backend& backend; + std::array(SyncType::Count)> progress; }; void Module::Interface::CreateBcatService(Kernel::HLERequestContext& ctx) { diff --git a/src/core/hle/service/filesystem/fsp_srv.cpp b/src/core/hle/service/filesystem/fsp_srv.cpp index a0215c4d7..7dc487e48 100644 --- a/src/core/hle/service/filesystem/fsp_srv.cpp +++ b/src/core/hle/service/filesystem/fsp_srv.cpp @@ -337,13 +337,14 @@ public: const auto file_buffer = ctx.ReadBuffer(); const std::string name = Common::StringFromBuffer(file_buffer); - const u64 mode = rp.Pop(); - const u32 size = rp.Pop(); + const u64 file_mode = rp.Pop(); + const u32 file_size = rp.Pop(); - LOG_DEBUG(Service_FS, "called. file={}, mode=0x{:X}, size=0x{:08X}", name, mode, size); + LOG_DEBUG(Service_FS, "called. file={}, mode=0x{:X}, size=0x{:08X}", name, file_mode, + file_size); IPC::ResponseBuilder rb{ctx, 2}; - rb.Push(backend.CreateFile(name, size)); + rb.Push(backend.CreateFile(name, file_size)); } void DeleteFile(Kernel::HLERequestContext& ctx) { @@ -935,8 +936,8 @@ void FSP_SRV::ReadSaveDataFileSystemExtraDataWithMaskBySaveDataAttribute( void FSP_SRV::OpenDataStorageByCurrentProcess(Kernel::HLERequestContext& ctx) { LOG_DEBUG(Service_FS, "called"); - auto romfs = fsc.OpenRomFSCurrentProcess(); - if (romfs.Failed()) { + auto current_romfs = fsc.OpenRomFSCurrentProcess(); + if (current_romfs.Failed()) { // TODO (bunnei): Find the right error code to use here LOG_CRITICAL(Service_FS, "no file system interface available!"); IPC::ResponseBuilder rb{ctx, 2}; @@ -944,7 +945,7 @@ void FSP_SRV::OpenDataStorageByCurrentProcess(Kernel::HLERequestContext& ctx) { return; } - auto storage = std::make_shared(system, std::move(romfs.Unwrap())); + auto storage = std::make_shared(system, std::move(current_romfs.Unwrap())); IPC::ResponseBuilder rb{ctx, 2, 0, 1}; rb.Push(RESULT_SUCCESS); @@ -1010,10 +1011,10 @@ void FSP_SRV::OpenDataStorageWithProgramIndex(Kernel::HLERequestContext& ctx) { LOG_DEBUG(Service_FS, "called, program_index={}", program_index); - auto romfs = fsc.OpenPatchedRomFSWithProgramIndex( + auto patched_romfs = fsc.OpenPatchedRomFSWithProgramIndex( system.CurrentProcess()->GetTitleID(), program_index, FileSys::ContentRecordType::Program); - if (romfs.Failed()) { + if (patched_romfs.Failed()) { // TODO: Find the right error code to use here LOG_ERROR(Service_FS, "could not open storage with program_index={}", program_index); @@ -1022,7 +1023,7 @@ void FSP_SRV::OpenDataStorageWithProgramIndex(Kernel::HLERequestContext& ctx) { return; } - auto storage = std::make_shared(system, std::move(romfs.Unwrap())); + auto storage = std::make_shared(system, std::move(patched_romfs.Unwrap())); IPC::ResponseBuilder rb{ctx, 2, 0, 1}; rb.Push(RESULT_SUCCESS); diff --git a/src/core/hle/service/nvflinger/nvflinger.cpp b/src/core/hle/service/nvflinger/nvflinger.cpp index 539b02bc4..c43593e7f 100644 --- a/src/core/hle/service/nvflinger/nvflinger.cpp +++ b/src/core/hle/service/nvflinger/nvflinger.cpp @@ -72,7 +72,7 @@ NVFlinger::NVFlinger(Core::System& system) : system(system) { // Schedule the screen composition events composition_event = Core::Timing::CreateEvent( "ScreenComposition", [this](std::uintptr_t, std::chrono::nanoseconds ns_late) { - const auto guard = Lock(); + const auto lock_guard = Lock(); Compose(); const auto ticks = std::chrono::nanoseconds{GetNextTicks()}; @@ -112,7 +112,7 @@ void NVFlinger::SetNVDrvInstance(std::shared_ptr instance) { } std::optional NVFlinger::OpenDisplay(std::string_view name) { - const auto guard = Lock(); + const auto lock_guard = Lock(); LOG_DEBUG(Service, "Opening \"{}\" display", name); @@ -131,7 +131,7 @@ std::optional NVFlinger::OpenDisplay(std::string_view name) { } std::optional NVFlinger::CreateLayer(u64 display_id) { - const auto guard = Lock(); + const auto lock_guard = Lock(); auto* const display = FindDisplay(display_id); if (display == nullptr) { @@ -147,7 +147,7 @@ std::optional NVFlinger::CreateLayer(u64 display_id) { } void NVFlinger::CloseLayer(u64 layer_id) { - const auto guard = Lock(); + const auto lock_guard = Lock(); for (auto& display : displays) { display.CloseLayer(layer_id); @@ -155,7 +155,7 @@ void NVFlinger::CloseLayer(u64 layer_id) { } std::optional NVFlinger::FindBufferQueueId(u64 display_id, u64 layer_id) const { - const auto guard = Lock(); + const auto lock_guard = Lock(); const auto* const layer = FindLayer(display_id, layer_id); if (layer == nullptr) { @@ -166,7 +166,7 @@ std::optional NVFlinger::FindBufferQueueId(u64 display_id, u64 layer_id) co } std::shared_ptr NVFlinger::FindVsyncEvent(u64 display_id) const { - const auto guard = Lock(); + const auto lock_guard = Lock(); auto* const display = FindDisplay(display_id); if (display == nullptr) { @@ -177,7 +177,7 @@ std::shared_ptr NVFlinger::FindVsyncEvent(u64 display_id } BufferQueue* NVFlinger::FindBufferQueue(u32 id) { - const auto guard = Lock(); + const auto lock_guard = Lock(); const auto itr = std::find_if(buffer_queues.begin(), buffer_queues.end(), [id](const auto& queue) { return queue->GetId() == id; }); diff --git a/src/core/hle/service/time/standard_user_system_clock_core.cpp b/src/core/hle/service/time/standard_user_system_clock_core.cpp index b9faa474e..3172acc5a 100644 --- a/src/core/hle/service/time/standard_user_system_clock_core.cpp +++ b/src/core/hle/service/time/standard_user_system_clock_core.cpp @@ -45,12 +45,12 @@ ResultCode StandardUserSystemClockCore::GetClockContext(Core::System& system, return local_system_clock_core.GetClockContext(system, context); } -ResultCode StandardUserSystemClockCore::Flush(const SystemClockContext& context) { +ResultCode StandardUserSystemClockCore::Flush(const SystemClockContext&) { UNREACHABLE(); return ERROR_NOT_IMPLEMENTED; } -ResultCode StandardUserSystemClockCore::SetClockContext(const SystemClockContext& context) { +ResultCode StandardUserSystemClockCore::SetClockContext(const SystemClockContext&) { UNREACHABLE(); return ERROR_NOT_IMPLEMENTED; } diff --git a/src/core/hle/service/time/standard_user_system_clock_core.h b/src/core/hle/service/time/standard_user_system_clock_core.h index aac44d72f..5bc8bf5c2 100644 --- a/src/core/hle/service/time/standard_user_system_clock_core.h +++ b/src/core/hle/service/time/standard_user_system_clock_core.h @@ -39,7 +39,7 @@ public: } protected: - ResultCode Flush(const SystemClockContext& context) override; + ResultCode Flush(const SystemClockContext&) override; ResultCode SetClockContext(const SystemClockContext&) override; diff --git a/src/core/hle/service/time/system_clock_core.cpp b/src/core/hle/service/time/system_clock_core.cpp index d31d4e2ca..46fc8c6c3 100644 --- a/src/core/hle/service/time/system_clock_core.cpp +++ b/src/core/hle/service/time/system_clock_core.cpp @@ -45,18 +45,18 @@ ResultCode SystemClockCore::SetCurrentTime(Core::System& system, s64 posix_time) return Flush(clock_context); } -ResultCode SystemClockCore::Flush(const SystemClockContext& context) { +ResultCode SystemClockCore::Flush(const SystemClockContext& clock_context) { if (!system_clock_context_update_callback) { return RESULT_SUCCESS; } - return system_clock_context_update_callback->Update(context); + return system_clock_context_update_callback->Update(clock_context); } -ResultCode SystemClockCore::SetSystemClockContext(const SystemClockContext& context) { - if (const ResultCode result{SetClockContext(context)}; result != RESULT_SUCCESS) { +ResultCode SystemClockCore::SetSystemClockContext(const SystemClockContext& clock_context) { + if (const ResultCode result{SetClockContext(clock_context)}; result != RESULT_SUCCESS) { return result; } - return Flush(context); + return Flush(clock_context); } bool SystemClockCore::IsClockSetup(Core::System& system) const { diff --git a/src/core/hle/service/time/system_clock_core.h b/src/core/hle/service/time/system_clock_core.h index 608dd3b2e..82a8b79ff 100644 --- a/src/core/hle/service/time/system_clock_core.h +++ b/src/core/hle/service/time/system_clock_core.h @@ -43,7 +43,7 @@ public: return RESULT_SUCCESS; } - virtual ResultCode Flush(const SystemClockContext& context); + virtual ResultCode Flush(const SystemClockContext& clock_context); void SetUpdateCallbackInstance(std::shared_ptr callback) { system_clock_context_update_callback = std::move(callback); diff --git a/src/core/hle/service/time/time_manager.cpp b/src/core/hle/service/time/time_manager.cpp index f89c5aaad..fe01a3739 100644 --- a/src/core/hle/service/time/time_manager.cpp +++ b/src/core/hle/service/time/time_manager.cpp @@ -129,7 +129,7 @@ struct TimeManager::Impl final { return 0; } - void SetupStandardSteadyClock(Core::System& system, Common::UUID clock_source_id, + void SetupStandardSteadyClock(Core::System& system_, Common::UUID clock_source_id, Clock::TimeSpanType setup_value, Clock::TimeSpanType internal_offset, bool is_rtc_reset_detected) { standard_steady_clock_core.SetClockSourceId(clock_source_id); @@ -137,21 +137,21 @@ struct TimeManager::Impl final { standard_steady_clock_core.SetInternalOffset(internal_offset); standard_steady_clock_core.MarkAsInitialized(); - const auto current_time_point{standard_steady_clock_core.GetCurrentRawTimePoint(system)}; - shared_memory.SetupStandardSteadyClock(system, clock_source_id, current_time_point); + const auto current_time_point{standard_steady_clock_core.GetCurrentRawTimePoint(system_)}; + shared_memory.SetupStandardSteadyClock(clock_source_id, current_time_point); } - void SetupStandardLocalSystemClock(Core::System& system, + void SetupStandardLocalSystemClock(Core::System& system_, Clock::SystemClockContext clock_context, s64 posix_time) { standard_local_system_clock_core.SetUpdateCallbackInstance( local_system_clock_context_writer); const auto current_time_point{ - standard_local_system_clock_core.GetSteadyClockCore().GetCurrentTimePoint(system)}; + standard_local_system_clock_core.GetSteadyClockCore().GetCurrentTimePoint(system_)}; if (current_time_point.clock_source_id == clock_context.steady_time_point.clock_source_id) { standard_local_system_clock_core.SetSystemClockContext(clock_context); } else { - if (standard_local_system_clock_core.SetCurrentTime(system, posix_time) != + if (standard_local_system_clock_core.SetCurrentTime(system_, posix_time) != RESULT_SUCCESS) { UNREACHABLE(); return; @@ -177,10 +177,10 @@ struct TimeManager::Impl final { standard_network_system_clock_core.MarkAsInitialized(); } - void SetupStandardUserSystemClock(Core::System& system, bool is_automatic_correction_enabled, + void SetupStandardUserSystemClock(Core::System& system_, bool is_automatic_correction_enabled, Clock::SteadyClockTimePoint steady_clock_time_point) { if (standard_user_system_clock_core.SetAutomaticCorrectionEnabled( - system, is_automatic_correction_enabled) != RESULT_SUCCESS) { + system_, is_automatic_correction_enabled) != RESULT_SUCCESS) { UNREACHABLE(); return; } @@ -196,10 +196,10 @@ struct TimeManager::Impl final { ephemeral_network_system_clock_core.MarkAsInitialized(); } - void UpdateLocalSystemClockTime(Core::System& system, s64 posix_time) { - const auto timespan{Service::Time::Clock::TimeSpanType::FromSeconds(posix_time)}; + void UpdateLocalSystemClockTime(Core::System& system_, s64 posix_time) { + const auto timespan{Clock::TimeSpanType::FromSeconds(posix_time)}; if (GetStandardLocalSystemClockCore() - .SetCurrentTime(system, timespan.ToSeconds()) + .SetCurrentTime(system_, timespan.ToSeconds()) .IsError()) { UNREACHABLE(); return; diff --git a/src/core/hle/service/time/time_sharedmemory.cpp b/src/core/hle/service/time/time_sharedmemory.cpp index 4d8de81be..018ce94ed 100644 --- a/src/core/hle/service/time/time_sharedmemory.cpp +++ b/src/core/hle/service/time/time_sharedmemory.cpp @@ -26,8 +26,7 @@ std::shared_ptr SharedMemory::GetSharedMemoryHolder() con return shared_memory_holder; } -void SharedMemory::SetupStandardSteadyClock(Core::System& system, - const Common::UUID& clock_source_id, +void SharedMemory::SetupStandardSteadyClock(const Common::UUID& clock_source_id, Clock::TimeSpanType current_time_point) { const Clock::TimeSpanType ticks_time_span{Clock::TimeSpanType::FromTicks( system.CoreTiming().GetClockTicks(), Core::Hardware::CNTFREQ)}; diff --git a/src/core/hle/service/time/time_sharedmemory.h b/src/core/hle/service/time/time_sharedmemory.h index 299680517..3bc749114 100644 --- a/src/core/hle/service/time/time_sharedmemory.h +++ b/src/core/hle/service/time/time_sharedmemory.h @@ -56,8 +56,8 @@ public: }; static_assert(sizeof(Format) == 0xd8, "Format is an invalid size"); - void SetupStandardSteadyClock(Core::System& system, const Common::UUID& clock_source_id, - Clock::TimeSpanType currentTimePoint); + void SetupStandardSteadyClock(const Common::UUID& clock_source_id, + Clock::TimeSpanType current_time_point); void UpdateLocalSystemClockContext(const Clock::SystemClockContext& context); void UpdateNetworkSystemClockContext(const Clock::SystemClockContext& context); void SetAutomaticCorrectionEnabled(bool is_enabled); diff --git a/src/core/hle/service/vi/display/vi_display.cpp b/src/core/hle/service/vi/display/vi_display.cpp index 7f42aa4a0..ac9e87338 100644 --- a/src/core/hle/service/vi/display/vi_display.cpp +++ b/src/core/hle/service/vi/display/vi_display.cpp @@ -41,24 +41,22 @@ void Display::SignalVSyncEvent() { vsync_event->GetWritableEvent()->Signal(); } -void Display::CreateLayer(u64 id, NVFlinger::BufferQueue& buffer_queue) { +void Display::CreateLayer(u64 layer_id, NVFlinger::BufferQueue& buffer_queue) { // TODO(Subv): Support more than 1 layer. ASSERT_MSG(layers.empty(), "Only one layer is supported per display at the moment"); - layers.emplace_back(std::make_shared(id, buffer_queue)); + layers.emplace_back(std::make_shared(layer_id, buffer_queue)); } -void Display::CloseLayer(u64 id) { - layers.erase( - std::remove_if(layers.begin(), layers.end(), - [id](const std::shared_ptr& layer) { return layer->GetID() == id; }), - layers.end()); +void Display::CloseLayer(u64 layer_id) { + std::erase_if(layers, [layer_id](const auto& layer) { return layer->GetID() == layer_id; }); } -Layer* Display::FindLayer(u64 id) { +Layer* Display::FindLayer(u64 layer_id) { const auto itr = - std::find_if(layers.begin(), layers.end(), - [id](const std::shared_ptr& layer) { return layer->GetID() == id; }); + std::find_if(layers.begin(), layers.end(), [layer_id](const std::shared_ptr& layer) { + return layer->GetID() == layer_id; + }); if (itr == layers.end()) { return nullptr; @@ -67,10 +65,11 @@ Layer* Display::FindLayer(u64 id) { return itr->get(); } -const Layer* Display::FindLayer(u64 id) const { +const Layer* Display::FindLayer(u64 layer_id) const { const auto itr = - std::find_if(layers.begin(), layers.end(), - [id](const std::shared_ptr& layer) { return layer->GetID() == id; }); + std::find_if(layers.begin(), layers.end(), [layer_id](const std::shared_ptr& layer) { + return layer->GetID() == layer_id; + }); if (itr == layers.end()) { return nullptr; diff --git a/src/core/hle/service/vi/display/vi_display.h b/src/core/hle/service/vi/display/vi_display.h index 931c898f6..8340059de 100644 --- a/src/core/hle/service/vi/display/vi_display.h +++ b/src/core/hle/service/vi/display/vi_display.h @@ -68,34 +68,34 @@ public: /// Creates and adds a layer to this display with the given ID. /// - /// @param id The ID to assign to the created layer. + /// @param layer_id The ID to assign to the created layer. /// @param buffer_queue The buffer queue for the layer instance to use. /// - void CreateLayer(u64 id, NVFlinger::BufferQueue& buffer_queue); + void CreateLayer(u64 layer_id, NVFlinger::BufferQueue& buffer_queue); /// Closes and removes a layer from this display with the given ID. /// - /// @param id The ID assigned to the layer to close. + /// @param layer_id The ID assigned to the layer to close. /// - void CloseLayer(u64 id); + void CloseLayer(u64 layer_id); /// Attempts to find a layer with the given ID. /// - /// @param id The layer ID. + /// @param layer_id The layer ID. /// /// @returns If found, the Layer instance with the given ID. /// If not found, then nullptr is returned. /// - Layer* FindLayer(u64 id); + Layer* FindLayer(u64 layer_id); /// Attempts to find a layer with the given ID. /// - /// @param id The layer ID. + /// @param layer_id The layer ID. /// /// @returns If found, the Layer instance with the given ID. /// If not found, then nullptr is returned. /// - const Layer* FindLayer(u64 id) const; + const Layer* FindLayer(u64 layer_id) const; private: u64 id; -- cgit v1.2.3