From 901aab8761daa5c2dae5e470d51f5b3bf76e2b78 Mon Sep 17 00:00:00 2001 From: Luna Date: Sun, 29 Mar 2020 17:45:43 -0300 Subject: Add ioctl errors --- lib/std/net.zig | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) (limited to 'lib/std/net.zig') diff --git a/lib/std/net.zig b/lib/std/net.zig index 5cc9a8f740..78ed8bc913 100644 --- a/lib/std/net.zig +++ b/lib/std/net.zig @@ -533,7 +533,18 @@ fn if_nametoindex(name: []const u8) !u32 { @ptrToInt(&ifr), ); - return ifr.ifr_ifru.ifru_ivalue; + switch (os.errno(rc)) { + os.EBADF => return error.BadFile, + os.EINTR => return error.CaughtSignal, + os.EINVAL => unreachable, + os.EIO => return error.FileSystem, + os.ENOTTY => unreachable, + os.ENXIO => unreachable, + os.ENODEV => return error.Unsupported, + else => {}, + } + + return @bitCast(u32, ifr.ifr_ifru.ifru_ivalue); } pub const AddressList = struct { -- cgit v1.2.3