unix: remove apple guard and fix code style

This commit is contained in:
verycosy 2025-02-10 18:20:42 +09:00 committed by Colin Ihrig
parent 636ec91fa5
commit 216e9490ac
2 changed files with 5 additions and 14 deletions

View File

@ -190,7 +190,7 @@ static int uv__process_init_stdio(uv_stdio_container_t* container, int fds[2]) {
int fd;
int ret;
int size = 64 * 1024;
int options[] = {SO_RCVBUF, SO_SNDBUF};
int i;
mask = UV_IGNORE | UV_CREATE_PIPE | UV_INHERIT_FD | UV_INHERIT_STREAM;
@ -205,18 +205,11 @@ static int uv__process_init_stdio(uv_stdio_container_t* container, int fds[2]) {
else {
ret = uv_socketpair(SOCK_STREAM, 0, fds, 0, 0);
#ifdef __APPLE__
if (ret == 0) {
for (int i = 0; i < 2; i++) {
for (int j = 0; j < 2; j++) {
ret = setsockopt(fds[i], SOL_SOCKET, options[j], &size, sizeof(size));
if (ret != 0)
return ret;
}
if (ret == 0)
for (i = 0; i < 2; i++) {
setsockopt(fds[i], SOL_SOCKET, SO_RCVBUF, &size, sizeof(size));
setsockopt(fds[i], SOL_SOCKET, SO_SNDBUF, &size, sizeof(size));
}
}
#endif
return ret;
}

View File

@ -603,7 +603,6 @@ TEST_IMPL(spawn_stdin) {
r = uv_spawn(uv_default_loop(), &process, &options);
ASSERT_OK(r);
#ifdef __APPLE__
int recv_buf;
int recv_fd;
int send_buf;
@ -618,7 +617,6 @@ TEST_IMPL(spawn_stdin) {
ASSERT_OK(uv_fileno((uv_handle_t*) options.stdio[1].data.stream, &send_fd));
ASSERT_OK(getsockopt(send_fd, SOL_SOCKET, SO_SNDBUF, &send_buf, &optlen));
ASSERT_EQ(send_buf, size);
#endif
buf.base = buffer;
buf.len = sizeof(buffer);