From d99ecef9433d677b4f834d466d7057b0f35e4dbf Mon Sep 17 00:00:00 2001 From: Luna Date: Sun, 10 Nov 2019 14:17:39 -0300 Subject: [PATCH] replace panic to unreachable - remove error.UnsupportedOS from StreamServer.listen --- lib/std/net.zig | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) diff --git a/lib/std/net.zig b/lib/std/net.zig index 7ee8b9a756..af79f22757 100644 --- a/lib/std/net.zig +++ b/lib/std/net.zig @@ -340,8 +340,8 @@ pub const Address = extern union { try std.fmt.format(context, Errors, output, "]:{}", port); }, os.AF_UNIX => { - if (@typeOf(self.un) == void) { - @panic("unsupported OS"); + if (!has_unix_sockets) { + unreachable; } try std.fmt.format(context, Errors, output, "{}", self.un.path); @@ -361,8 +361,8 @@ pub const Address = extern union { os.AF_INET => return @sizeOf(os.sockaddr_in), os.AF_INET6 => return @sizeOf(os.sockaddr_in6), os.AF_UNIX => { - if (@typeOf(self.un) == void) { - @panic("unsupported OS"); + if (!has_unix_sockets) { + unreachable; } const path_len = std.mem.len(u8, &self.un.path); @@ -1321,12 +1321,6 @@ pub const StreamServer = struct { const nonblock = if (std.io.is_async) os.SOCK_NONBLOCK else 0; const sock_flags = os.SOCK_STREAM | os.SOCK_CLOEXEC | nonblock; const proto = if (address.any.family == os.AF_UNIX) @as(u32, 0) else os.IPPROTO_TCP; - if (address.any.family == os.AF_UNIX and @typeOf(address.un) == void) { - return error{ - /// When the OS does not have support for AF_UNIX sockets. - UnsupportedOS, - }.UnsupportedOS; - } const sockfd = try os.socket(address.any.family, sock_flags, proto); self.sockfd = sockfd;