fix: fix faulty syscall result/status code compares
This commit is contained in:
1 parent
abfd9de8f6
commit
a81298fb24
7 files changed
+19
-14
No files matched your search
@@ -234,10 +234,7 @@ void filemanager_read_system_configuration(FileManagerState* fm);
|
||||
// Map a raw syscall result (kernel StatusCodes are negative) to a userspace
|
||||
// montauk::StatusCodes. Non-negative results (handles, counts) are Success.
|
||||
inline montauk::StatusCode filemanager_status_from_result(int rc) {
|
||||
if (rc >= 0) return montauk::Success;
|
||||
int code = -rc;
|
||||
if (code > montauk::OutOfMemory) return montauk::GenericFailure;
|
||||
return (montauk::StatusCode)code;
|
||||
return montauk::StatusFromResult(rc);
|
||||
}
|
||||
|
||||
// The path itself may not be modified. Falling back to copy + delete after a
|
||||
|
||||
@@ -501,7 +501,7 @@ static void apply_changes() {
|
||||
if (g_driver_available && g_selected_mode != g_info.currentMode) {
|
||||
int result = montauk::display_set_mode(g_selected_mode);
|
||||
if (result < 0) {
|
||||
set_status(result == montauk::UnsupportedOp
|
||||
set_status(montauk::StatusFromResult(result) == montauk::UnsupportedOp
|
||||
? "Mode needs unsupported display-link training"
|
||||
: "Mode change failed; previous mode restored");
|
||||
refresh_state(true);
|
||||
|
||||
@@ -262,7 +262,7 @@ void perform_graceful_shutdown(LoginState* ls, int action) {
|
||||
// A successful power-control syscall never returns. If it does return,
|
||||
// keep the trusted supervisor alive and make the authorization failure
|
||||
// visible instead of falling through an unreachable-code assumption.
|
||||
show_stage(ls, heading, rc == montauk::CapabilityDenied
|
||||
show_stage(ls, heading, montauk::StatusFromResult(rc) == montauk::CapabilityDenied
|
||||
? "Power control permission denied."
|
||||
: "Power control failed.");
|
||||
for (;;) montauk::sleep_ms(1000);
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
extern "C" void _start() {
|
||||
montauk::print("Rebooting...\n");
|
||||
int rc = montauk::reset();
|
||||
if (rc == montauk::CapabilityDenied)
|
||||
if (montauk::StatusFromResult(rc) == montauk::CapabilityDenied)
|
||||
montauk::print("reset: permission denied\n");
|
||||
else
|
||||
montauk::print("reset: reboot failed\n");
|
||||
|
||||
@@ -196,7 +196,7 @@ static int process_command(const char* line) {
|
||||
: montauk::abi::POWER_REQ_SHUTDOWN;
|
||||
int rc = montauk::power_request(action);
|
||||
if (rc == 0) montauk::exit(0);
|
||||
montauk::print(rc == montauk::CapabilityDenied
|
||||
montauk::print(montauk::StatusFromResult(rc) == montauk::CapabilityDenied
|
||||
? "power: permission denied\n"
|
||||
: "power: request failed\n");
|
||||
return 1;
|
||||
@@ -204,7 +204,7 @@ static int process_command(const char* line) {
|
||||
|
||||
if (streq(cmd, "suspend")) {
|
||||
int rc = montauk::suspend();
|
||||
if (rc == montauk::CapabilityDenied)
|
||||
if (montauk::StatusFromResult(rc) == montauk::CapabilityDenied)
|
||||
montauk::print("suspend: permission denied\n");
|
||||
return rc == 0 ? 0 : 1;
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user