diff options
author | Himbeer <himbeer@disroot.org> | 2024-07-27 16:30:35 +0200 |
---|---|---|
committer | Himbeer <himbeer@disroot.org> | 2024-07-27 16:30:35 +0200 |
commit | 360fd4e87bfc261966480efa72befa892dc41cb6 (patch) | |
tree | c61d1dc0a725457a09f9d99a0d96cefb571147f6 /src/lib/syscall.zig | |
parent | fc78c1561a57456aec002c294d95585a23943a18 (diff) |
syscall: Use std.math.cast instead of checked @truncate
Diffstat (limited to 'src/lib/syscall.zig')
-rw-r--r-- | src/lib/syscall.zig | 9 |
1 files changed, 4 insertions, 5 deletions
diff --git a/src/lib/syscall.zig b/src/lib/syscall.zig index d886360..a4c803a 100644 --- a/src/lib/syscall.zig +++ b/src/lib/syscall.zig @@ -84,12 +84,11 @@ pub const TerminateError = error{ // terminate(pid: u16, tid: usize) !void fn terminate(proc: *const process.Info, trap_frame: *const trap.Frame) !void { - const pid: u16 = @truncate(trap_frame.general_purpose_registers[10]); - const tid = trap_frame.general_purpose_registers[11]; - - if (pid != trap_frame.general_purpose_registers[10]) { + const pid_wide = trap_frame.general_purpose_registers[10]; + const pid = std.math.cast(u16, pid_wide) orelse { return TerminateError.PidOutOfRange; - } + }; + const tid = trap_frame.general_purpose_registers[11]; const target = process.findThread(pid, tid) orelse { return TerminateError.ProcessNotFound; |