summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorliamwhite <liamwhite@users.noreply.github.com>2024-02-24 22:24:01 +0100
committerGitHub <noreply@github.com>2024-02-24 22:24:01 +0100
commita93d249ac161e190b8c7046917bd9a3b6e79a0e0 (patch)
treee7589e51b5bf334aef78658b2e7efddcce3578dd
parentMerge pull request #13153 from german77/defaultset (diff)
parentservice: set: Fix GetSettingsItemValue (diff)
downloadyuzu-a93d249ac161e190b8c7046917bd9a3b6e79a0e0.tar
yuzu-a93d249ac161e190b8c7046917bd9a3b6e79a0e0.tar.gz
yuzu-a93d249ac161e190b8c7046917bd9a3b6e79a0e0.tar.bz2
yuzu-a93d249ac161e190b8c7046917bd9a3b6e79a0e0.tar.lz
yuzu-a93d249ac161e190b8c7046917bd9a3b6e79a0e0.tar.xz
yuzu-a93d249ac161e190b8c7046917bd9a3b6e79a0e0.tar.zst
yuzu-a93d249ac161e190b8c7046917bd9a3b6e79a0e0.zip
Diffstat (limited to '')
-rw-r--r--src/core/hle/service/glue/time/worker.cpp7
-rw-r--r--src/core/hle/service/set/system_settings_server.cpp13
-rw-r--r--src/core/hle/service/set/system_settings_server.h21
3 files changed, 19 insertions, 22 deletions
diff --git a/src/core/hle/service/glue/time/worker.cpp b/src/core/hle/service/glue/time/worker.cpp
index b28569b68..b6bbd7965 100644
--- a/src/core/hle/service/glue/time/worker.cpp
+++ b/src/core/hle/service/glue/time/worker.cpp
@@ -26,12 +26,9 @@ Service::PSC::Time::SystemClockContext g_report_ephemeral_clock_context{};
template <typename T>
T GetSettingsItemValue(std::shared_ptr<Service::Set::ISystemSettingsServer>& set_sys,
const char* category, const char* name) {
- std::vector<u8> interval_buf;
- auto res = set_sys->GetSettingsItemValueImpl(interval_buf, category, name);
- ASSERT(res == ResultSuccess);
-
T v{};
- std::memcpy(&v, interval_buf.data(), sizeof(T));
+ auto res = set_sys->GetSettingsItemValueImpl(v, category, name);
+ ASSERT(res == ResultSuccess);
return v;
}
diff --git a/src/core/hle/service/set/system_settings_server.cpp b/src/core/hle/service/set/system_settings_server.cpp
index 6a7ea83fd..900d5408f 100644
--- a/src/core/hle/service/set/system_settings_server.cpp
+++ b/src/core/hle/service/set/system_settings_server.cpp
@@ -308,7 +308,7 @@ ISystemSettingsServer::ISystemSettingsServer(Core::System& system_)
SetupSettings();
m_system_settings.region_code =
- static_cast<SystemRegionCode>(Settings::values.region_index.GetValue());
+ static_cast<SystemRegionCode>(::Settings::values.region_index.GetValue());
// TODO: Remove this when starter applet is fully functional
EulaVersion eula_version{
@@ -715,7 +715,7 @@ Result ISystemSettingsServer::GetSettingsItemValueSize(
}
Result ISystemSettingsServer::GetSettingsItemValue(
- OutBuffer<BufferAttr_HipcMapAlias> out_data,
+ Out<u64> out_size, OutBuffer<BufferAttr_HipcMapAlias> out_data,
InLargeData<SettingItemName, BufferAttr_HipcPointer> setting_category_buffer,
InLargeData<SettingItemName, BufferAttr_HipcPointer> setting_name_buffer) {
const std::string setting_category{Common::StringFromBuffer(*setting_category_buffer)};
@@ -723,7 +723,7 @@ Result ISystemSettingsServer::GetSettingsItemValue(
LOG_INFO(Service_SET, "called, category={}, name={}", setting_category, setting_name);
- R_RETURN(GetSettingsItemValueImpl(out_data, setting_category, setting_name));
+ R_RETURN(GetSettingsItemValueImpl(out_data, *out_size, setting_category, setting_name));
}
Result ISystemSettingsServer::GetTvSettings(Out<TvSettings> out_tv_settings) {
@@ -1363,13 +1363,16 @@ void ISystemSettingsServer::SetSaveNeeded() {
m_save_needed = true;
}
-Result ISystemSettingsServer::GetSettingsItemValueImpl(std::vector<u8>& out_value,
+Result ISystemSettingsServer::GetSettingsItemValueImpl(std::span<u8> out_value, u64& out_size,
const std::string& category,
const std::string& name) {
auto settings{GetSettings()};
R_UNLESS(settings.contains(category) && settings[category].contains(name), ResultUnknown);
- out_value = settings[category][name];
+ ASSERT_MSG(out_value.size() >= settings[category][name].size(),
+ "Stored type is bigger than requested type");
+ out_size = std::min<u64>(settings[category][name].size(), out_value.size());
+ std::memcpy(out_value.data(), settings[category][name].data(), out_size);
R_SUCCEED();
}
diff --git a/src/core/hle/service/set/system_settings_server.h b/src/core/hle/service/set/system_settings_server.h
index 46e06c8ea..9a1154ad6 100644
--- a/src/core/hle/service/set/system_settings_server.h
+++ b/src/core/hle/service/set/system_settings_server.h
@@ -34,20 +34,17 @@ public:
explicit ISystemSettingsServer(Core::System& system_);
~ISystemSettingsServer() override;
- Result GetSettingsItemValueImpl(std::vector<u8>& out_value, const std::string& category,
- const std::string& name);
+ Result GetSettingsItemValueImpl(std::span<u8> out_value, u64& out_size,
+ const std::string& category, const std::string& name);
template <typename T>
- Result GetSettingsItemValueImpl(T& value, const std::string& category,
+ Result GetSettingsItemValueImpl(T& out_value, const std::string& category,
const std::string& name) {
- std::vector<u8> data;
- const auto result = GetSettingsItemValueImpl(data, category, name);
- if (result.IsError()) {
- return result;
- }
- ASSERT(data.size() >= sizeof(T));
- std::memcpy(&value, data.data(), sizeof(T));
- return result;
+ u64 data_size{};
+ std::vector<u8> data(sizeof(T));
+ R_TRY(GetSettingsItemValueImpl(data, data_size, category, name));
+ std::memcpy(&out_value, data.data(), data_size);
+ R_SUCCEED();
}
public:
@@ -84,7 +81,7 @@ public:
InLargeData<SettingItemName, BufferAttr_HipcPointer> setting_category_buffer,
InLargeData<SettingItemName, BufferAttr_HipcPointer> setting_name_buf);
Result GetSettingsItemValue(
- OutBuffer<BufferAttr_HipcMapAlias> out_data,
+ Out<u64> out_size, OutBuffer<BufferAttr_HipcMapAlias> out_data,
InLargeData<SettingItemName, BufferAttr_HipcPointer> setting_category_buffer,
InLargeData<SettingItemName, BufferAttr_HipcPointer> setting_name_buffer);
Result GetTvSettings(Out<TvSettings> out_tv_settings);