Results: Implement namespaced, type-safe results.
Because I was working on multiple things at once, this commit also:
- Adds wrappers for/linker flags to wrap CXX exceptions to make them
abort. This saves ~0x8000 of memory in every system module.
- Broadly replaces lines of the pattern if (cond) { return ResultX; }
with R_UNLESS(!cond, ResultX());.
- Reworks the R_TRY_CATCH macros (and the result macros in general).
This commit is contained in:
@@ -79,7 +79,7 @@ Result SetMitmService::EnsureLocale() {
|
||||
}
|
||||
}
|
||||
|
||||
return ResultSuccess;
|
||||
return ResultSuccess();
|
||||
}
|
||||
|
||||
Result SetMitmService::GetLanguageCode(Out<u64> out_lang_code) {
|
||||
@@ -90,7 +90,7 @@ Result SetMitmService::GetLanguageCode(Out<u64> out_lang_code) {
|
||||
}
|
||||
|
||||
out_lang_code.SetValue(this->locale.language_code);
|
||||
return ResultSuccess;
|
||||
return ResultSuccess();
|
||||
}
|
||||
|
||||
Result SetMitmService::GetRegionCode(Out<u32> out_region_code) {
|
||||
@@ -101,5 +101,5 @@ Result SetMitmService::GetRegionCode(Out<u32> out_region_code) {
|
||||
}
|
||||
|
||||
out_region_code.SetValue(this->locale.region_code);
|
||||
return ResultSuccess;
|
||||
return ResultSuccess();
|
||||
}
|
||||
|
||||
@@ -75,5 +75,5 @@ Result VersionManager::GetFirmwareVersion(sts::ncm::TitleId title_id, SetSysFirm
|
||||
*out = g_fw_version;
|
||||
}
|
||||
|
||||
return ResultSuccess;
|
||||
return ResultSuccess();
|
||||
}
|
||||
@@ -32,7 +32,7 @@ Result SetSysMitmService::GetFirmwareVersion(OutPointerWithServerSize<SetSysFirm
|
||||
/* GetFirmwareVersion sanitizes these fields. */
|
||||
out.pointer->revision_major = 0;
|
||||
out.pointer->revision_minor = 0;
|
||||
return ResultSuccess;
|
||||
return ResultSuccess();
|
||||
}
|
||||
|
||||
Result SetSysMitmService::GetFirmwareVersion2(OutPointerWithServerSize<SetSysFirmwareVersion, 0x1> out) {
|
||||
@@ -64,7 +64,7 @@ Result SetSysMitmService::GetSettingsItemValueSize(Out<u64> out_size, InPointer<
|
||||
R_TRY(setsysGetSettingsItemValueSize(name, key, out_size.GetPointer()));
|
||||
}
|
||||
|
||||
return ResultSuccess;
|
||||
return ResultSuccess();
|
||||
}
|
||||
|
||||
Result SetSysMitmService::GetSettingsItemValue(Out<u64> out_size, OutBuffer<u8> out_value, InPointer<char> in_name, InPointer<char> in_key) {
|
||||
@@ -96,5 +96,5 @@ Result SetSysMitmService::GetSettingsItemValue(Out<u64> out_size, OutBuffer<u8>
|
||||
R_TRY(setsysGetSettingsItemValueFwd(this->forward_service.get(), name, key, out_value.buffer, out_value.num_elements, out_size.GetPointer()));
|
||||
}
|
||||
|
||||
return ResultSuccess;
|
||||
return ResultSuccess();
|
||||
}
|
||||
|
||||
@@ -84,7 +84,7 @@ Result SettingsItemManager::ValidateName(const char *name, size_t max_size) {
|
||||
return ResultSettingsItemNameInvalidFormat;
|
||||
}
|
||||
|
||||
return ResultSuccess;
|
||||
return ResultSuccess();
|
||||
}
|
||||
|
||||
Result SettingsItemManager::ValidateName(const char *name) {
|
||||
@@ -107,7 +107,7 @@ Result SettingsItemManager::ValidateKey(const char *key, size_t max_size) {
|
||||
return ResultSettingsItemKeyInvalidFormat;
|
||||
}
|
||||
|
||||
return ResultSuccess;
|
||||
return ResultSuccess();
|
||||
}
|
||||
|
||||
Result SettingsItemManager::ValidateKey(const char *key) {
|
||||
@@ -219,7 +219,7 @@ static Result ParseValue(const char *name, const char *key, const char *val_tup)
|
||||
}
|
||||
|
||||
g_settings_items[kv] = value;
|
||||
return ResultSuccess;
|
||||
return ResultSuccess();
|
||||
}
|
||||
|
||||
static Result ParseSettingsItemValue(const char *name, const char *key, const char *value) {
|
||||
@@ -227,7 +227,7 @@ static Result ParseSettingsItemValue(const char *name, const char *key, const ch
|
||||
R_TRY(SettingsItemManager::ValidateName(name));
|
||||
R_TRY(SettingsItemManager::ValidateKey(name));
|
||||
R_TRY(ParseValue(name, key, value));
|
||||
return ResultSuccess;
|
||||
return ResultSuccess();
|
||||
}
|
||||
|
||||
static int SettingsItemIniHandler(void *user, const char *name, const char *key, const char *value) {
|
||||
@@ -282,7 +282,7 @@ Result SettingsItemManager::GetValueSize(const char *name, const char *key, u64
|
||||
}
|
||||
|
||||
*out_size = it->second.size;
|
||||
return ResultSuccess;
|
||||
return ResultSuccess();
|
||||
}
|
||||
|
||||
Result SettingsItemManager::GetValue(const char *name, const char *key, void *out, size_t max_size, u64 *out_size) {
|
||||
@@ -300,5 +300,5 @@ Result SettingsItemManager::GetValue(const char *name, const char *key, void *ou
|
||||
*out_size = copy_size;
|
||||
|
||||
memcpy(out, it->second.data, copy_size);
|
||||
return ResultSuccess;
|
||||
return ResultSuccess();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user