authorgravatar for git@l4.pmLuna <git@l4.pm> 2019-11-10 14:17:39-03:00
committergravatar for git@l4.pmLuna <git@l4.pm> 2019-11-10 14:17:39-03:00
logd99ecef9433d677b4f834d466d7057b0f35e4dbf
tree9ea518aeb280793470ea3757baf3d0a63f05b4a8
parent2d02920a905e20b7f43991657cdc028e444b9df7

replace panic to unreachable

- remove error.UnsupportedOS from StreamServer.listen

1 files changed, 4 insertions(+), 10 deletions(-)

lib/std/net.zig+4-10
...@@ -340,8 +340,8 @@ pub const Address = extern union {...@@ -340,8 +340,8 @@ pub const Address = extern union {
340 try std.fmt.format(context, Errors, output, "]:{}", port);340 try std.fmt.format(context, Errors, output, "]:{}", port);
341 },341 },
342 os.AF_UNIX => {342 os.AF_UNIX => {
343 if (@typeOf(self.un) == void) {343 if (!has_unix_sockets) {
344 @panic("unsupported OS");344 unreachable;
345 }345 }
346346
347 try std.fmt.format(context, Errors, output, "{}", self.un.path);347 try std.fmt.format(context, Errors, output, "{}", self.un.path);
...@@ -361,8 +361,8 @@ pub const Address = extern union {...@@ -361,8 +361,8 @@ pub const Address = extern union {
361 os.AF_INET => return @sizeOf(os.sockaddr_in),361 os.AF_INET => return @sizeOf(os.sockaddr_in),
362 os.AF_INET6 => return @sizeOf(os.sockaddr_in6),362 os.AF_INET6 => return @sizeOf(os.sockaddr_in6),
363 os.AF_UNIX => {363 os.AF_UNIX => {
364 if (@typeOf(self.un) == void) {364 if (!has_unix_sockets) {
365 @panic("unsupported OS");365 unreachable;
366 }366 }
367367
368 const path_len = std.mem.len(u8, &self.un.path);368 const path_len = std.mem.len(u8, &self.un.path);
...@@ -1321,12 +1321,6 @@ pub const StreamServer = struct {...@@ -1321,12 +1321,6 @@ pub const StreamServer = struct {
1321 const nonblock = if (std.io.is_async) os.SOCK_NONBLOCK else 0;1321 const nonblock = if (std.io.is_async) os.SOCK_NONBLOCK else 0;
1322 const sock_flags = os.SOCK_STREAM | os.SOCK_CLOEXEC | nonblock;1322 const sock_flags = os.SOCK_STREAM | os.SOCK_CLOEXEC | nonblock;
1323 const proto = if (address.any.family == os.AF_UNIX) @as(u32, 0) else os.IPPROTO_TCP;1323 const proto = if (address.any.family == os.AF_UNIX) @as(u32, 0) else os.IPPROTO_TCP;
1324 if (address.any.family == os.AF_UNIX and @typeOf(address.un) == void) {
1325 return error{
1326 /// When the OS does not have support for AF_UNIX sockets.
1327 UnsupportedOS,
1328 }.UnsupportedOS;
1329 }
13301324
1331 const sockfd = try os.socket(address.any.family, sock_flags, proto);1325 const sockfd = try os.socket(address.any.family, sock_flags, proto);
1332 self.sockfd = sockfd;1326 self.sockfd = sockfd;