zig

fork of https://codeberg.org/ziglang/zig
Log | Files | Refs | README | LICENSE

commit d99ecef9433d677b4f834d466d7057b0f35e4dbf (tree)
parent 2d02920a905e20b7f43991657cdc028e444b9df7
Author: Luna <git@l4.pm>
Date:   Sun, 10 Nov 2019 14:17:39 -0300

replace panic to unreachable

 - remove error.UnsupportedOS from StreamServer.listen

Diffstat:
Mlib/std/net.zig | 14++++----------
1 file changed, 4 insertions(+), 10 deletions(-)

diff --git 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;