Commit 92407bfcd7

Joran Dirk Greef <joran@ronomon.com>
2020-09-19 18:29:50
Upgrade check_errno() to an exhaustive switch (safer)
1 parent ba18420
Changed files (1)
lib
std
os
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)
     }
 }