ams: revamp assertion system

This commit is contained in:
Michael Scire 2020-02-22 23:05:14 -08:00
parent 9572fb2ce3
commit 40400aee1f
168 changed files with 1014 additions and 696 deletions

View file

@ -161,11 +161,11 @@ namespace ams::sm::impl {
cfg::GetInitialProcessRange(&this->min, &this->max);
/* Ensure range is sane. */
AMS_ASSERT(this->min <= this->max);
AMS_ABORT_UNLESS(this->min <= this->max);
}
bool IsInitialProcess(os::ProcessId process_id) const {
AMS_ASSERT(process_id != os::InvalidProcessId);
AMS_ABORT_UNLESS(process_id != os::InvalidProcessId);
return this->min <= process_id && process_id <= this->max;
}
};
@ -228,7 +228,7 @@ namespace ams::sm::impl {
void GetMitmProcessInfo(MitmProcessInfo *out_info, os::ProcessId process_id) {
/* Anything that can request a mitm session must have a process info. */
const auto process_info = GetProcessInfo(process_id);
AMS_ASSERT(process_info != nullptr);
AMS_ABORT_UNLESS(process_info != nullptr);
/* Write to output. */
out_info->process_id = process_id;
@ -383,7 +383,7 @@ namespace ams::sm::impl {
GetMitmProcessInfo(&client_info, process_id);
if (!IsMitmDisallowed(client_info.program_id)) {
/* We're mitm'd. Assert, because mitm service host dead is an error state. */
R_ASSERT(GetMitmServiceHandleImpl(out, service_info, client_info));
R_ABORT_UNLESS(GetMitmServiceHandleImpl(out, service_info, client_info));
return ResultSuccess();
}
}

View file

@ -23,7 +23,7 @@ namespace ams::sm {
}
void DmntService::AtmosphereListRecords(const sf::OutArray<ServiceRecord> &records, sf::Out<u64> out_count, u64 offset) {
R_ASSERT(impl::ListServiceRecords(records.GetPointer(), out_count.GetPointer(), offset, records.GetSize()));
R_ABORT_UNLESS(impl::ListServiceRecords(records.GetPointer(), out_count.GetPointer(), offset, records.GetSize()));
}
void DmntService::AtmosphereGetRecordSize(sf::Out<u64> record_size) {

View file

@ -95,14 +95,14 @@ int main(int argc, char **argv)
/* Create sm:, (and thus allow things to register to it). */
{
Handle sm_h;
R_ASSERT(svcManageNamedPort(&sm_h, "sm:", 0x40));
R_ABORT_UNLESS(svcManageNamedPort(&sm_h, "sm:", 0x40));
g_server_manager.RegisterServer<sm::UserService>(sm_h);
}
/* Create sm:m manually. */
{
Handle smm_h;
R_ASSERT(sm::impl::RegisterServiceForSelf(&smm_h, sm::ServiceName::Encode("sm:m"), 1));
R_ABORT_UNLESS(sm::impl::RegisterServiceForSelf(&smm_h, sm::ServiceName::Encode("sm:m"), 1));
g_server_manager.RegisterServer<sm::ManagerService>(smm_h);
}
@ -110,7 +110,7 @@ int main(int argc, char **argv)
/* Create sm:dmnt manually. */
{
Handle smdmnt_h;
R_ASSERT(sm::impl::RegisterServiceForSelf(&smdmnt_h, sm::ServiceName::Encode("sm:dmnt"), 1));
R_ABORT_UNLESS(sm::impl::RegisterServiceForSelf(&smdmnt_h, sm::ServiceName::Encode("sm:dmnt"), 1));
g_server_manager.RegisterServer<sm::DmntService>(smdmnt_h);
}

View file

@ -27,11 +27,11 @@ namespace ams::sm {
}
void ManagerService::AtmosphereEndInitDefers() {
R_ASSERT(impl::EndInitialDefers());
R_ABORT_UNLESS(impl::EndInitialDefers());
}
void ManagerService::AtmosphereHasMitm(sf::Out<bool> out, ServiceName service) {
R_ASSERT(impl::HasMitm(out.GetPointer(), service));
R_ABORT_UNLESS(impl::HasMitm(out.GetPointer(), service));
}
Result ManagerService::AtmosphereRegisterProcess(os::ProcessId process_id, ncm::ProgramId program_id, cfg::OverrideStatus override_status, const sf::InBuffer &acid_sac, const sf::InBuffer &aci_sac) {