diff options
| author | Luna <git@l4.pm> | 2019-11-10 14:17:39 -0300 |
|---|---|---|
| committer | Luna <git@l4.pm> | 2019-11-10 14:17:39 -0300 |
| commit | d99ecef9433d677b4f834d466d7057b0f35e4dbf (patch) | |
| tree | 9ea518aeb280793470ea3757baf3d0a63f05b4a8 /lib/std/net.zig | |
| parent | 2d02920a905e20b7f43991657cdc028e444b9df7 (diff) | |
| download | zig-d99ecef9433d677b4f834d466d7057b0f35e4dbf.tar.gz zig-d99ecef9433d677b4f834d466d7057b0f35e4dbf.zip | |
replace panic to unreachable
- remove error.UnsupportedOS from StreamServer.listen
Diffstat (limited to 'lib/std/net.zig')
| -rw-r--r-- | lib/std/net.zig | 14 |
1 files 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; |
