Upgrade check_errno() to an exhaustive switch (safer)

This commit is contained in:
Joran Dirk Greef
2020-09-19 18:29:50 +02:00
parent ba18420b27
commit 92407bfcd7

View File

@@ -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)
}
}