Merge pull request #3818 from ogniK5377/err-log

Don't fail silently for vi, sm, set and ns services
This commit is contained in:
Mat M 2020-04-28 21:41:13 -04:00 committed by GitHub
commit c3c3e07263
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 27 additions and 3 deletions

View File

@ -371,10 +371,15 @@ ResultVal<u8> IApplicationManagerInterface::GetApplicationDesiredLanguage(
// Convert to application language, get priority list // Convert to application language, get priority list
const auto application_language = ConvertToApplicationLanguage(language_code); const auto application_language = ConvertToApplicationLanguage(language_code);
if (application_language == std::nullopt) { if (application_language == std::nullopt) {
LOG_ERROR(Service_NS, "Could not convert application language! language_code={}",
language_code);
return ERR_APPLICATION_LANGUAGE_NOT_FOUND; return ERR_APPLICATION_LANGUAGE_NOT_FOUND;
} }
const auto priority_list = GetApplicationLanguagePriorityList(*application_language); const auto priority_list = GetApplicationLanguagePriorityList(*application_language);
if (!priority_list) { if (!priority_list) {
LOG_ERROR(Service_NS,
"Could not find application language priorities! application_language={}",
*application_language);
return ERR_APPLICATION_LANGUAGE_NOT_FOUND; return ERR_APPLICATION_LANGUAGE_NOT_FOUND;
} }
@ -386,6 +391,8 @@ ResultVal<u8> IApplicationManagerInterface::GetApplicationDesiredLanguage(
} }
} }
LOG_ERROR(Service_NS, "Could not find a valid language! supported_languages={:08X}",
supported_languages);
return ERR_APPLICATION_LANGUAGE_NOT_FOUND; return ERR_APPLICATION_LANGUAGE_NOT_FOUND;
} }
@ -410,6 +417,7 @@ ResultVal<u64> IApplicationManagerInterface::ConvertApplicationLanguageToLanguag
const auto language_code = const auto language_code =
ConvertToLanguageCode(static_cast<ApplicationLanguage>(application_language)); ConvertToLanguageCode(static_cast<ApplicationLanguage>(application_language));
if (language_code == std::nullopt) { if (language_code == std::nullopt) {
LOG_ERROR(Service_NS, "Language not found! application_language={}", application_language);
return ERR_APPLICATION_LANGUAGE_NOT_FOUND; return ERR_APPLICATION_LANGUAGE_NOT_FOUND;
} }

View File

@ -67,6 +67,7 @@ void SET::MakeLanguageCode(Kernel::HLERequestContext& ctx) {
const auto index = rp.Pop<u32>(); const auto index = rp.Pop<u32>();
if (index >= available_language_codes.size()) { if (index >= available_language_codes.size()) {
LOG_ERROR(Service_SET, "Invalid language code index! index={}", index);
IPC::ResponseBuilder rb{ctx, 2}; IPC::ResponseBuilder rb{ctx, 2};
rb.Push(ERR_INVALID_LANGUAGE); rb.Push(ERR_INVALID_LANGUAGE);
return; return;

View File

@ -28,9 +28,11 @@ void ServiceManager::InvokeControlRequest(Kernel::HLERequestContext& context) {
static ResultCode ValidateServiceName(const std::string& name) { static ResultCode ValidateServiceName(const std::string& name) {
if (name.size() <= 0 || name.size() > 8) { if (name.size() <= 0 || name.size() > 8) {
LOG_ERROR(Service_SM, "Invalid service name! service={}", name);
return ERR_INVALID_NAME; return ERR_INVALID_NAME;
} }
if (name.find('\0') != std::string::npos) { if (name.find('\0') != std::string::npos) {
LOG_ERROR(Service_SM, "A non null terminated service was passed");
return ERR_INVALID_NAME; return ERR_INVALID_NAME;
} }
return RESULT_SUCCESS; return RESULT_SUCCESS;
@ -51,8 +53,10 @@ ResultVal<std::shared_ptr<Kernel::ServerPort>> ServiceManager::RegisterService(
CASCADE_CODE(ValidateServiceName(name)); CASCADE_CODE(ValidateServiceName(name));
if (registered_services.find(name) != registered_services.end()) if (registered_services.find(name) != registered_services.end()) {
LOG_ERROR(Service_SM, "Service is already registered! service={}", name);
return ERR_ALREADY_REGISTERED; return ERR_ALREADY_REGISTERED;
}
auto& kernel = Core::System::GetInstance().Kernel(); auto& kernel = Core::System::GetInstance().Kernel();
auto [server_port, client_port] = auto [server_port, client_port] =
@ -66,9 +70,10 @@ ResultCode ServiceManager::UnregisterService(const std::string& name) {
CASCADE_CODE(ValidateServiceName(name)); CASCADE_CODE(ValidateServiceName(name));
const auto iter = registered_services.find(name); const auto iter = registered_services.find(name);
if (iter == registered_services.end()) if (iter == registered_services.end()) {
LOG_ERROR(Service_SM, "Server is not registered! service={}", name);
return ERR_SERVICE_NOT_REGISTERED; return ERR_SERVICE_NOT_REGISTERED;
}
registered_services.erase(iter); registered_services.erase(iter);
return RESULT_SUCCESS; return RESULT_SUCCESS;
} }
@ -79,6 +84,7 @@ ResultVal<std::shared_ptr<Kernel::ClientPort>> ServiceManager::GetServicePort(
CASCADE_CODE(ValidateServiceName(name)); CASCADE_CODE(ValidateServiceName(name));
auto it = registered_services.find(name); auto it = registered_services.find(name);
if (it == registered_services.end()) { if (it == registered_services.end()) {
LOG_ERROR(Service_SM, "Server is not registered! service={}", name);
return ERR_SERVICE_NOT_REGISTERED; return ERR_SERVICE_NOT_REGISTERED;
} }

View File

@ -867,6 +867,7 @@ private:
const auto layer_id = nv_flinger->CreateLayer(display); const auto layer_id = nv_flinger->CreateLayer(display);
if (!layer_id) { if (!layer_id) {
LOG_ERROR(Service_VI, "Layer not found! display=0x{:016X}", display);
IPC::ResponseBuilder rb{ctx, 2}; IPC::ResponseBuilder rb{ctx, 2};
rb.Push(ERR_NOT_FOUND); rb.Push(ERR_NOT_FOUND);
return; return;
@ -983,6 +984,7 @@ private:
const auto display_id = nv_flinger->OpenDisplay(name); const auto display_id = nv_flinger->OpenDisplay(name);
if (!display_id) { if (!display_id) {
LOG_ERROR(Service_VI, "Display not found! display_name={}", name);
IPC::ResponseBuilder rb{ctx, 2}; IPC::ResponseBuilder rb{ctx, 2};
rb.Push(ERR_NOT_FOUND); rb.Push(ERR_NOT_FOUND);
return; return;
@ -1082,6 +1084,7 @@ private:
const auto display_id = nv_flinger->OpenDisplay(display_name); const auto display_id = nv_flinger->OpenDisplay(display_name);
if (!display_id) { if (!display_id) {
LOG_ERROR(Service_VI, "Layer not found! layer_id={}", layer_id);
IPC::ResponseBuilder rb{ctx, 2}; IPC::ResponseBuilder rb{ctx, 2};
rb.Push(ERR_NOT_FOUND); rb.Push(ERR_NOT_FOUND);
return; return;
@ -1089,6 +1092,7 @@ private:
const auto buffer_queue_id = nv_flinger->FindBufferQueueId(*display_id, layer_id); const auto buffer_queue_id = nv_flinger->FindBufferQueueId(*display_id, layer_id);
if (!buffer_queue_id) { if (!buffer_queue_id) {
LOG_ERROR(Service_VI, "Buffer queue id not found! display_id={}", *display_id);
IPC::ResponseBuilder rb{ctx, 2}; IPC::ResponseBuilder rb{ctx, 2};
rb.Push(ERR_NOT_FOUND); rb.Push(ERR_NOT_FOUND);
return; return;
@ -1124,6 +1128,7 @@ private:
const auto layer_id = nv_flinger->CreateLayer(display_id); const auto layer_id = nv_flinger->CreateLayer(display_id);
if (!layer_id) { if (!layer_id) {
LOG_ERROR(Service_VI, "Layer not found! layer_id={}", *layer_id);
IPC::ResponseBuilder rb{ctx, 2}; IPC::ResponseBuilder rb{ctx, 2};
rb.Push(ERR_NOT_FOUND); rb.Push(ERR_NOT_FOUND);
return; return;
@ -1131,6 +1136,7 @@ private:
const auto buffer_queue_id = nv_flinger->FindBufferQueueId(display_id, *layer_id); const auto buffer_queue_id = nv_flinger->FindBufferQueueId(display_id, *layer_id);
if (!buffer_queue_id) { if (!buffer_queue_id) {
LOG_ERROR(Service_VI, "Buffer queue id not found! display_id={}", display_id);
IPC::ResponseBuilder rb{ctx, 2}; IPC::ResponseBuilder rb{ctx, 2};
rb.Push(ERR_NOT_FOUND); rb.Push(ERR_NOT_FOUND);
return; return;
@ -1161,6 +1167,7 @@ private:
const auto vsync_event = nv_flinger->FindVsyncEvent(display_id); const auto vsync_event = nv_flinger->FindVsyncEvent(display_id);
if (!vsync_event) { if (!vsync_event) {
LOG_ERROR(Service_VI, "Vsync event was not found for display_id={}", display_id);
IPC::ResponseBuilder rb{ctx, 2}; IPC::ResponseBuilder rb{ctx, 2};
rb.Push(ERR_NOT_FOUND); rb.Push(ERR_NOT_FOUND);
return; return;
@ -1201,6 +1208,7 @@ private:
case NintendoScaleMode::PreserveAspectRatio: case NintendoScaleMode::PreserveAspectRatio:
return MakeResult(ConvertedScaleMode::PreserveAspectRatio); return MakeResult(ConvertedScaleMode::PreserveAspectRatio);
default: default:
LOG_ERROR(Service_VI, "Invalid scaling mode specified, mode={}", mode);
return ERR_OPERATION_FAILED; return ERR_OPERATION_FAILED;
} }
} }
@ -1257,6 +1265,7 @@ void detail::GetDisplayServiceImpl(Kernel::HLERequestContext& ctx,
const auto policy = rp.PopEnum<Policy>(); const auto policy = rp.PopEnum<Policy>();
if (!IsValidServiceAccess(permission, policy)) { if (!IsValidServiceAccess(permission, policy)) {
LOG_ERROR(Service_VI, "Permission denied for policy {}", static_cast<u32>(policy));
IPC::ResponseBuilder rb{ctx, 2}; IPC::ResponseBuilder rb{ctx, 2};
rb.Push(ERR_PERMISSION_DENIED); rb.Push(ERR_PERMISSION_DENIED);
return; return;