aboutsummaryrefslogtreecommitdiff
path: root/lib/std/net.zig
diff options
context:
space:
mode:
Diffstat (limited to 'lib/std/net.zig')
-rw-r--r--lib/std/net.zig24
1 files changed, 6 insertions, 18 deletions
diff --git a/lib/std/net.zig b/lib/std/net.zig
index 866a7b0cca..22c3d6d895 100644
--- a/lib/std/net.zig
+++ b/lib/std/net.zig
@@ -545,24 +545,12 @@ fn if_nametoindex(name: []const u8) !u32 {
std.mem.copy(u8, &ifr.ifr_ifrn.name, name);
ifr.ifr_ifrn.name[name.len] = 0;
- const rc = os.system.syscall3(
- os.linux.SYS_ioctl,
- @bitCast(usize, @as(isize, sockfd)),
- os.linux.SIOCGIFINDEX,
- @ptrToInt(&ifr),
- );
-
- switch (os.errno(rc)) {
- os.EBADF => return error.BadFile,
- os.EINTR => return error.CaughtSignal,
- os.EIO => return error.FileSystem,
- os.EINVAL => unreachable,
- os.ENOTTY => unreachable,
- os.ENXIO => unreachable,
- // ioctl() sends ENODEV for an unknown scope id.
- os.ENODEV => return error.InterfaceNotFound,
- else => {},
- }
+ std.os.ioctl(sockfd, os.linux.SIOCGIFINDEX, @ptrToInt(&ifr)) catch |err| {
+ switch (err) {
+ error.NoDevice => return error.InterfaceNotFound,
+ else => return err,
+ }
+ };
return @bitCast(u32, ifr.ifr_ifru.ifru_ivalue);
}