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

@ -56,7 +56,7 @@ namespace ams::ldr {
Result MountNspFileSystem(const char *device_name, const char *path) {
FsFileSystem fs;
R_TRY(fsOpenFileSystemWithId(&fs, 0, FsFileSystemType_ApplicationPackage, path));
AMS_ASSERT(fsdevMountDevice(device_name, fs) >= 0);
AMS_ABORT_UNLESS(fsdevMountDevice(device_name, fs) >= 0);
return ResultSuccess();
}
@ -150,7 +150,7 @@ namespace ams::ldr {
/* Try to mount the content path. */
FsFileSystem fs;
R_TRY(fsldrOpenCodeFileSystem(static_cast<u64>(loc.program_id), path, &fs));
AMS_ASSERT(fsdevMountDevice(CodeFileSystemDeviceName, fs) != -1);
AMS_ABORT_UNLESS(fsdevMountDevice(CodeFileSystemDeviceName, fs) != -1);
/* Note that we mounted code. */
this->is_code_mounted = true;
@ -190,7 +190,7 @@ namespace ams::ldr {
/* Check if we're ready to mount the SD card. */
if (!g_has_mounted_sd_card) {
if (is_sd_initialized) {
R_ASSERT(MountSdCardFileSystem());
R_ABORT_UNLESS(MountSdCardFileSystem());
g_has_mounted_sd_card = true;
}
}
@ -219,7 +219,7 @@ namespace ams::ldr {
}
void ScopedCodeMount::InitializeOverrideStatus(const ncm::ProgramLocation &loc) {
AMS_ASSERT(!this->has_status);
AMS_ABORT_UNLESS(!this->has_status);
this->override_status = cfg::CaptureOverrideStatus(loc.program_id);
this->has_status = true;
}

View file

@ -45,7 +45,7 @@ namespace ams::ldr {
}
const cfg::OverrideStatus &GetOverrideStatus() const {
AMS_ASSERT(this->has_status);
AMS_ABORT_UNLESS(this->has_status);
return this->override_status;
}

View file

@ -92,7 +92,7 @@ namespace ams::ldr::ecs {
R_UNLESS(g_map.size() < MaxExternalContentSourceCount, ldr::ResultTooManyArguments());
/* Clear any sources. */
R_ASSERT(Clear(program_id));
R_ABORT_UNLESS(Clear(program_id));
/* Generate mountpoint. */
char device_name[DeviceNameSizeMax];

View file

@ -102,7 +102,7 @@ namespace ams::ldr {
}
void LoaderService::AtmosphereClearExternalContentSource(ncm::ProgramId program_id) {
R_ASSERT(ecs::Clear(program_id));
R_ABORT_UNLESS(ecs::Clear(program_id));
}
void LoaderService::AtmosphereHasLaunchedProgram(sf::Out<bool> out, ncm::ProgramId program_id) {

View file

@ -72,9 +72,9 @@ void __appInit(void) {
/* Initialize services we need. */
sm::DoWithSession([&]() {
R_ASSERT(fsInitialize());
R_ASSERT(lrInitialize());
R_ASSERT(fsldrInitialize());
R_ABORT_UNLESS(fsInitialize());
R_ABORT_UNLESS(lrInitialize());
R_ABORT_UNLESS(fsldrInitialize());
});
ams::CheckApiVersion();
@ -115,9 +115,9 @@ namespace {
int main(int argc, char **argv)
{
/* Add services to manager. */
R_ASSERT((g_server_manager.RegisterServer<ldr::pm::ProcessManagerInterface>(ProcessManagerServiceName, ProcessManagerMaxSessions)));
R_ASSERT((g_server_manager.RegisterServer<ldr::shell::ShellInterface>(ShellServiceName, ShellMaxSessions)));
R_ASSERT((g_server_manager.RegisterServer<ldr::dmnt::DebugMonitorInterface>(DebugMonitorServiceName, DebugMonitorMaxSessions)));
R_ABORT_UNLESS((g_server_manager.RegisterServer<ldr::pm::ProcessManagerInterface>(ProcessManagerServiceName, ProcessManagerMaxSessions)));
R_ABORT_UNLESS((g_server_manager.RegisterServer<ldr::shell::ShellInterface>(ShellServiceName, ShellMaxSessions)));
R_ABORT_UNLESS((g_server_manager.RegisterServer<ldr::dmnt::DebugMonitorInterface>(DebugMonitorServiceName, DebugMonitorMaxSessions)));
/* Loop forever, servicing our services. */
g_server_manager.LoopProcess();

View file

@ -48,7 +48,7 @@ namespace ams::ldr {
};
constexpr const char *GetNsoName(size_t idx) {
AMS_ASSERT(idx < Nso_Count);
AMS_ABORT_UNLESS(idx < Nso_Count);
constexpr const char *NsoNames[Nso_Count] = {
"rtld",
@ -606,7 +606,7 @@ namespace ams::ldr {
}
/* Clear the ECS entry for the program. */
R_ASSERT(ecs::Clear(loc.program_id));
R_ABORT_UNLESS(ecs::Clear(loc.program_id));
/* Note that we've created the program. */
SetLaunchedProgram(loc.program_id);