std.os: make setsockopt receive a slice as option

This commit is contained in:
Luna 2019-12-01 13:12:23 -03:00 committed by Andrew Kelley
parent ea8f496970
commit 5efc0ea89e
No known key found for this signature in database
GPG Key ID: 7C5F548F728501A9

View File

@ -3252,8 +3252,8 @@ pub fn sched_yield() SchedYieldError!void {
}
/// Set a socket's options.
pub fn setsockopt(fd: fd_t, level: u32, optname: u32, optval: [*]const u8, optlen: socklen_t) !void {
switch (errno(system.setsockopt(fd, level, optname, optval, optlen))) {
pub fn setsockopt(fd: fd_t, level: u32, optname: u32, opt: []const u8) !void {
switch (errno(system.setsockopt(fd, level, optname, opt.ptr, @intCast(socklen_t, opt.len)))) {
0 => {},
EBADF => unreachable,
EINVAL => unreachable,
@ -3261,7 +3261,6 @@ pub fn setsockopt(fd: fd_t, level: u32, optname: u32, optval: [*]const u8, optle
EISCONN => return error.AlreadyConnected,
ENOPROTOOPT => return error.InvalidProtocolOption,
ENOTSOCK => return error.NotSocket,
ENOMEM => return error.OutOfMemory,
ENOBUFS => return error.SystemResources,