From 92407bfcd7b65f153b7523d97ac5f69193561d27 Mon Sep 17 00:00:00 2001 From: Joran Dirk Greef Date: Sat, 19 Sep 2020 18:29:50 +0200 Subject: [PATCH] Upgrade check_errno() to an exhaustive switch (safer) --- lib/std/os/linux/io_uring.zig | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/std/os/linux/io_uring.zig b/lib/std/os/linux/io_uring.zig index 82c7dd7cc4..2c17614b04 100644 --- a/lib/std/os/linux/io_uring.zig +++ b/lib/std/os/linux/io_uring.zig @@ -608,10 +608,10 @@ pub const CompletionQueue = struct { }; inline fn check_errno(res: usize) !void { - const errno = linux.getErrno(res); - if (errno != 0) { - if (errno == linux.ENOSYS) return error.UnsupportedKernel; - return os.unexpectedErrno(errno); + switch (linux.getErrno(res)) { + 0 => return, + linux.ENOSYS => return error.UnsupportedKernel, + else => |errno| return os.unexpectedErrno(errno) } }