cybersecurity · beginner · ~15 min
Normalise a syscall return into success/failure.
Normalise a raw syscall return into a clean success/failure signal — the discipline of checking every call before proceeding.
Implement int handle_rc(int rc) that returns 0 for success and -1 for failure.
rc: a return code (a syscall-style result) the grader passes.Returns int: 0 if rc >= 0 (success), -1 otherwise.
handle_rc(5) -> 0
handle_rc(0) -> 0
handle_rc(-1) -> -1
rc == 0 counts as success.An int rc (a syscall-style return code).
An int: 0 if rc >= 0, else -1.
rc == 0 is success.
int handle_rc(int rc) {
/* TODO */
return -1;
}
Solve this exercise in the browser editor — compile and run against the test harness, no setup required.