Merge pull request #12857 from liamwhite/const

service: use const references for input raw data
This commit is contained in:
Fernando S 2024-02-02 15:10:46 +01:00 committed by GitHub
commit 6baf965777
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
31 changed files with 100 additions and 91 deletions

View file

@ -200,7 +200,7 @@ Result StaticService::GetStandardUserSystemClockAutomaticCorrectionUpdatedTime(
}
Result StaticService::CalculateMonotonicSystemClockBaseTimePoint(
Out<s64> out_time, Service::PSC::Time::SystemClockContext& context) {
Out<s64> out_time, const Service::PSC::Time::SystemClockContext& context) {
SCOPE_EXIT({ LOG_DEBUG(Service_Time, "called. context={} out_time={}", context, *out_time); });
R_RETURN(m_wrapped_service->CalculateMonotonicSystemClockBaseTimePoint(out_time, context));
@ -216,8 +216,8 @@ Result StaticService::GetClockSnapshot(OutClockSnapshot out_snapshot,
Result StaticService::GetClockSnapshotFromSystemClockContext(
Service::PSC::Time::TimeType type, OutClockSnapshot out_snapshot,
Service::PSC::Time::SystemClockContext& user_context,
Service::PSC::Time::SystemClockContext& network_context) {
const Service::PSC::Time::SystemClockContext& user_context,
const Service::PSC::Time::SystemClockContext& network_context) {
SCOPE_EXIT({
LOG_DEBUG(Service_Time,
"called. type={} out_snapshot={} user_context={} network_context={}", type,

View file

@ -58,12 +58,12 @@ public:
Result GetStandardUserSystemClockAutomaticCorrectionUpdatedTime(
Out<Service::PSC::Time::SteadyClockTimePoint> out_time_point);
Result CalculateMonotonicSystemClockBaseTimePoint(
Out<s64> out_time, Service::PSC::Time::SystemClockContext& context);
Out<s64> out_time, const Service::PSC::Time::SystemClockContext& context);
Result GetClockSnapshot(OutClockSnapshot out_snapshot, Service::PSC::Time::TimeType type);
Result GetClockSnapshotFromSystemClockContext(
Service::PSC::Time::TimeType type, OutClockSnapshot out_snapshot,
Service::PSC::Time::SystemClockContext& user_context,
Service::PSC::Time::SystemClockContext& network_context);
const Service::PSC::Time::SystemClockContext& user_context,
const Service::PSC::Time::SystemClockContext& network_context);
Result CalculateStandardUserSystemClockDifferenceByUser(Out<s64> out_difference,
InClockSnapshot a, InClockSnapshot b);
Result CalculateSpanBetween(Out<s64> out_time, InClockSnapshot a, InClockSnapshot b);

View file

@ -62,7 +62,8 @@ Result TimeZoneService::GetDeviceLocationName(
R_RETURN(m_wrapped_service->GetDeviceLocationName(out_location_name));
}
Result TimeZoneService::SetDeviceLocationName(Service::PSC::Time::LocationName& location_name) {
Result TimeZoneService::SetDeviceLocationName(
const Service::PSC::Time::LocationName& location_name) {
LOG_DEBUG(Service_Time, "called. location_name={}", location_name);
R_UNLESS(m_can_write_timezone_device_location, Service::PSC::Time::ResultPermissionDenied);
@ -110,7 +111,8 @@ Result TimeZoneService::LoadLocationNameList(
R_RETURN(GetTimeZoneLocationList(*out_count, out_names, out_names.size(), index));
}
Result TimeZoneService::LoadTimeZoneRule(OutRule out_rule, Service::PSC::Time::LocationName& name) {
Result TimeZoneService::LoadTimeZoneRule(OutRule out_rule,
const Service::PSC::Time::LocationName& name) {
LOG_DEBUG(Service_Time, "called. name={}", name);
std::scoped_lock l{m_mutex};
@ -139,7 +141,8 @@ Result TimeZoneService::GetDeviceLocationNameAndUpdatedTime(
}
Result TimeZoneService::SetDeviceLocationNameWithTimeZoneRule(
Service::PSC::Time::LocationName& location_name, InBuffer<BufferAttr_HipcAutoSelect> binary) {
const Service::PSC::Time::LocationName& location_name,
InBuffer<BufferAttr_HipcAutoSelect> binary) {
LOG_DEBUG(Service_Time, "called. location_name={}", location_name);
R_UNLESS(m_can_write_timezone_device_location, Service::PSC::Time::ResultPermissionDenied);

View file

@ -46,18 +46,20 @@ public:
~TimeZoneService() override;
Result GetDeviceLocationName(Out<Service::PSC::Time::LocationName> out_location_name);
Result SetDeviceLocationName(Service::PSC::Time::LocationName& location_name);
Result SetDeviceLocationName(const Service::PSC::Time::LocationName& location_name);
Result GetTotalLocationNameCount(Out<u32> out_count);
Result LoadLocationNameList(
Out<u32> out_count,
OutArray<Service::PSC::Time::LocationName, BufferAttr_HipcMapAlias> out_names, u32 index);
Result LoadTimeZoneRule(OutRule out_rule, Service::PSC::Time::LocationName& location_name);
Result LoadTimeZoneRule(OutRule out_rule,
const Service::PSC::Time::LocationName& location_name);
Result GetTimeZoneRuleVersion(Out<Service::PSC::Time::RuleVersion> out_rule_version);
Result GetDeviceLocationNameAndUpdatedTime(
Out<Service::PSC::Time::LocationName> location_name,
Out<Service::PSC::Time::SteadyClockTimePoint> out_time_point);
Result SetDeviceLocationNameWithTimeZoneRule(Service::PSC::Time::LocationName& location_name,
InBuffer<BufferAttr_HipcAutoSelect> binary);
Result SetDeviceLocationNameWithTimeZoneRule(
const Service::PSC::Time::LocationName& location_name,
InBuffer<BufferAttr_HipcAutoSelect> binary);
Result ParseTimeZoneBinary(OutRule out_rule, InBuffer<BufferAttr_HipcAutoSelect> binary);
Result GetDeviceLocationNameOperationEventReadableHandle(
OutCopyHandle<Kernel::KReadableEvent> out_event);

View file

@ -98,7 +98,7 @@ void GetTimeZoneBinaryVersionPath(std::string& out_path) {
out_path = "/version.txt";
}
void GetTimeZoneZonePath(std::string& out_path, Service::PSC::Time::LocationName& name) {
void GetTimeZoneZonePath(std::string& out_path, const Service::PSC::Time::LocationName& name) {
if (g_time_zone_binary_mount_result != ResultSuccess) {
return;
}
@ -106,7 +106,7 @@ void GetTimeZoneZonePath(std::string& out_path, Service::PSC::Time::LocationName
out_path = fmt::format("/zoneinfo/{}", name.data());
}
bool IsTimeZoneBinaryValid(Service::PSC::Time::LocationName& name) {
bool IsTimeZoneBinaryValid(const Service::PSC::Time::LocationName& name) {
std::string path{};
GetTimeZoneZonePath(path, name);
@ -155,7 +155,7 @@ Result GetTimeZoneVersion(Service::PSC::Time::RuleVersion& out_rule_version) {
}
Result GetTimeZoneRule(std::span<const u8>& out_rule, size_t& out_rule_size,
Service::PSC::Time::LocationName& name) {
const Service::PSC::Time::LocationName& name) {
std::string path{};
GetTimeZoneZonePath(path, name);

View file

@ -19,12 +19,12 @@ void ResetTimeZoneBinary();
Result MountTimeZoneBinary(Core::System& system);
void GetTimeZoneBinaryListPath(std::string& out_path);
void GetTimeZoneBinaryVersionPath(std::string& out_path);
void GetTimeZoneZonePath(std::string& out_path, Service::PSC::Time::LocationName& name);
bool IsTimeZoneBinaryValid(Service::PSC::Time::LocationName& name);
void GetTimeZoneZonePath(std::string& out_path, const Service::PSC::Time::LocationName& name);
bool IsTimeZoneBinaryValid(const Service::PSC::Time::LocationName& name);
u32 GetTimeZoneCount();
Result GetTimeZoneVersion(Service::PSC::Time::RuleVersion& out_rule_version);
Result GetTimeZoneRule(std::span<const u8>& out_rule, size_t& out_rule_size,
Service::PSC::Time::LocationName& name);
const Service::PSC::Time::LocationName& name);
Result GetTimeZoneLocationList(u32& out_count,
std::span<Service::PSC::Time::LocationName> out_names,
size_t max_names, u32 index);