nfci: address some style nits

PR-URL: https://github.com/libuv/libuv/pull/2954
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
This commit is contained in:
Jameson Nash 2020-08-21 17:25:42 -04:00 committed by GitHub
parent 707dd7f17d
commit 79c531cb7d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
15 changed files with 234 additions and 85 deletions

View File

@ -535,8 +535,8 @@ Helper functions
For a OS-dependent handle, get the file descriptor in the C runtime.
On UNIX, returns the ``os_fd`` intact. On Windows, this calls `_open_osfhandle <https://docs.microsoft.com/en-us/cpp/c-runtime-library/reference/open-osfhandle?view=vs-2019>`_.
Note that the return value is still owned by the CRT,
any attempts to close it or to use it after closing the handle may lead to malfunction.
Note that this consumes the argument, any attempts to close it or to use it
after closing the return value may lead to malfunction.
.. versionadded:: 1.23.0

View File

@ -1,3 +1,24 @@
/* Copyright libuv project contributors. All rights reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to
* deal in the Software without restriction, including without limitation the
* rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
* sell copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
* IN THE SOFTWARE.
*/
#include "strscpy.h"
#include <limits.h> /* SSIZE_MAX */

View File

@ -1,3 +1,24 @@
/* Copyright libuv project contributors. All rights reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to
* deal in the Software without restriction, including without limitation the
* rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
* sell copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
* IN THE SOFTWARE.
*/
#ifndef UV_STRSCPY_H_
#define UV_STRSCPY_H_

View File

@ -1,3 +1,24 @@
/* Copyright libuv project contributors. All rights reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to
* deal in the Software without restriction, including without limitation the
* rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
* sell copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
* IN THE SOFTWARE.
*/
#include "uv.h"
const char* uv_handle_type_name(uv_handle_type type) {

View File

@ -1,3 +1,24 @@
/* Copyright libuv project contributors. All rights reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to
* deal in the Software without restriction, including without limitation the
* rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
* sell copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
* IN THE SOFTWARE.
*/
#include "uv.h"
#include "internal.h"
#include "winapi.h"

View File

@ -1,3 +1,24 @@
/* Copyright libuv project contributors. All rights reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to
* deal in the Software without restriction, including without limitation the
* rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
* sell copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
* IN THE SOFTWARE.
*/
#ifndef UV_WIN_FS_FD_HASH_INL_H_
#define UV_WIN_FS_FD_HASH_INL_H_

View File

@ -244,9 +244,8 @@ int uv_stdio_pipe_server(uv_loop_t* loop, uv_pipe_t* handle, DWORD access,
return 0;
error:
if (pipeHandle != INVALID_HANDLE_VALUE) {
if (pipeHandle != INVALID_HANDLE_VALUE)
CloseHandle(pipeHandle);
}
return err;
}
@ -554,7 +553,7 @@ int uv_pipe_bind(uv_pipe_t* handle, const char* name) {
/* Convert name to UTF16. */
nameSize = MultiByteToWideChar(CP_UTF8, 0, name, -1, NULL, 0) * sizeof(WCHAR);
handle->name = (WCHAR*)uv__malloc(nameSize);
handle->name = uv__malloc(nameSize);
if (!handle->name) {
uv_fatal_error(ERROR_OUTOFMEMORY, "uv__malloc");
}
@ -621,9 +620,8 @@ static DWORD WINAPI pipe_connect_thread_proc(void* parameter) {
while (WaitNamedPipeW(handle->name, 30000)) {
/* The pipe is now available, try to connect. */
pipeHandle = open_named_pipe(handle->name, &duplex_flags);
if (pipeHandle != INVALID_HANDLE_VALUE) {
if (pipeHandle != INVALID_HANDLE_VALUE)
break;
}
SwitchToThread();
}
@ -655,7 +653,7 @@ void uv_pipe_connect(uv_connect_t* req, uv_pipe_t* handle,
/* Convert name to UTF16. */
nameSize = MultiByteToWideChar(CP_UTF8, 0, name, -1, NULL, 0) * sizeof(WCHAR);
handle->name = (WCHAR*)uv__malloc(nameSize);
handle->name = uv__malloc(nameSize);
if (!handle->name) {
uv_fatal_error(ERROR_OUTOFMEMORY, "uv__malloc");
}
@ -2147,7 +2145,7 @@ int uv_pipe_open(uv_pipe_t* pipe, uv_file file) {
if (pipe->ipc) {
assert(!(pipe->flags & UV_HANDLE_NON_OVERLAPPED_PIPE));
pipe->pipe.conn.ipc_remote_pid = uv_os_getppid();
assert(pipe->pipe.conn.ipc_remote_pid != (DWORD) -1);
assert(pipe->pipe.conn.ipc_remote_pid != (DWORD)(uv_pid_t) -1);
}
return 0;
}

View File

@ -28,13 +28,13 @@
static unsigned int read_cb_called;
static void alloc_cb(uv_handle_t *handle, size_t size, uv_buf_t *buf) {
static void alloc_cb(uv_handle_t* handle, size_t size, uv_buf_t* buf) {
static char slab[1];
buf->base = slab;
buf->len = sizeof(slab);
}
static void read_cb(uv_stream_t *handle, ssize_t nread, const uv_buf_t *buf) {
static void read_cb(uv_stream_t* handle, ssize_t nread, const uv_buf_t* buf) {
switch (++read_cb_called) {
case 1:
ASSERT(nread == 1);

View File

@ -58,7 +58,7 @@ static char empty_file[FILE_NAME_SIZE];
static char dummy_file[FILE_NAME_SIZE];
static char empty_dir[] = "empty_dir";
static void setup() {
static void setup(void) {
int r;
/* empty_dir */
@ -73,7 +73,7 @@ static void setup() {
uv_fs_req_cleanup(&mkdir_req);
}
static void refresh() {
static void refresh(void) {
int r;
/* absent_file */
@ -119,7 +119,7 @@ static void refresh() {
uv_fs_req_cleanup(&close_req);
}
static void cleanup() {
static void cleanup(void) {
unlink(absent_file);
unlink(empty_file);
unlink(dummy_file);

View File

@ -28,12 +28,8 @@
#include <sys/stat.h>
#include <limits.h> /* INT_MAX, PATH_MAX, IOV_MAX */
/* FIXME we shouldn't need to branch in this file */
#if defined(__unix__) || defined(__POSIX__) || \
defined(__APPLE__) || defined(__sun) || \
defined(_AIX) || defined(__MVS__) || \
defined(__HAIKU__)
#include <unistd.h> /* unlink, rmdir, etc. */
#ifndef _WIN32
# include <unistd.h> /* unlink, rmdir, etc. */
#else
# include <winioctl.h>
# include <direct.h>
@ -3888,7 +3884,7 @@ TEST_IMPL(fs_file_pos_after_op_with_offset) {
}
#ifdef _WIN32
static void fs_file_pos_common() {
static void fs_file_pos_common(void) {
int r;
iov = uv_buf_init("abc", 3);

View File

@ -1,3 +1,24 @@
/* Copyright libuv project contributors. All rights reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to
* deal in the Software without restriction, including without limitation the
* rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
* sell copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
* IN THE SOFTWARE.
*/
#include "uv.h"
#include "task.h"
#include <string.h>

View File

@ -1,8 +1,29 @@
/* Copyright libuv project contributors. All rights reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to
* deal in the Software without restriction, including without limitation the
* rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
* sell copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
* IN THE SOFTWARE.
*/
#include "uv.h"
#include "task.h"
#include <string.h> /* memset */
#define NS_MS 1000000
#define UV_NS_TO_MS 1000000
static void timer_spin_cb(uv_timer_t* handle) {
@ -11,7 +32,7 @@ static void timer_spin_cb(uv_timer_t* handle) {
(*(int*) handle->data)++;
t = uv_hrtime();
/* Spin for 500 ms to spin loop time out of the delta check. */
while (uv_hrtime() - t < 600 * NS_MS) { }
while (uv_hrtime() - t < 600 * UV_NS_TO_MS) { }
}
@ -34,8 +55,8 @@ TEST_IMPL(metrics_idle_time) {
idle_time = uv_metrics_idle_time(uv_default_loop());
/* Permissive check that the idle time matches within the timeout ±500 ms. */
ASSERT((idle_time <= (timeout + 500) * NS_MS) &&
(idle_time >= (timeout - 500) * NS_MS));
ASSERT((idle_time <= (timeout + 500) * UV_NS_TO_MS) &&
(idle_time >= (timeout - 500) * UV_NS_TO_MS));
MAKE_VALGRIND_HAPPY();
return 0;
@ -66,7 +87,7 @@ static void metrics_routine_cb(void* arg) {
* may have been thread contention, causing the event loop to be delayed in
* the idle phase longer than expected.
*/
ASSERT_GE(idle_time, (timeout - 500) * NS_MS);
ASSERT_GE(idle_time, (timeout - 500) * UV_NS_TO_MS);
close_loop(&loop);
ASSERT_EQ(0, uv_loop_close(&loop));

View File

@ -70,14 +70,14 @@ static void pinger_on_close(uv_handle_t* handle) {
}
static void pinger_after_write(uv_write_t *req, int status) {
static void pinger_after_write(uv_write_t* req, int status) {
ASSERT(status == 0);
free(req);
}
static void pinger_write_ping(pinger_t* pinger) {
uv_write_t *req;
uv_write_t* req;
uv_buf_t bufs[sizeof PING - 1];
int i, nbufs;
@ -112,7 +112,7 @@ static void pinger_read_cb(uv_stream_t* stream,
ssize_t i;
pinger_t* pinger;
pinger = (pinger_t*)stream->data;
pinger = (pinger_t*) stream->data;
if (nread < 0) {
ASSERT(nread == UV_EOF);
@ -148,8 +148,8 @@ static void pinger_read_cb(uv_stream_t* stream,
}
static void pinger_on_connect(uv_connect_t *req, int status) {
pinger_t *pinger = (pinger_t*)req->handle->data;
static void pinger_on_connect(uv_connect_t* req, int status) {
pinger_t* pinger = (pinger_t*)req->handle->data;
pinger_on_connect_count++;
@ -169,10 +169,10 @@ static void pinger_on_connect(uv_connect_t *req, int status) {
static void tcp_pinger_v6_new(int vectored_writes) {
int r;
struct sockaddr_in6 server_addr;
pinger_t *pinger;
pinger_t* pinger;
ASSERT(0 ==uv_ip6_addr("::1", TEST_PORT, &server_addr));
ASSERT(0 == uv_ip6_addr("::1", TEST_PORT, &server_addr));
pinger = malloc(sizeof(*pinger));
ASSERT(pinger != NULL);
pinger->vectored_writes = vectored_writes;
@ -200,7 +200,7 @@ static void tcp_pinger_v6_new(int vectored_writes) {
static void tcp_pinger_new(int vectored_writes) {
int r;
struct sockaddr_in server_addr;
pinger_t *pinger;
pinger_t* pinger;
ASSERT(0 == uv_ip4_addr("127.0.0.1", TEST_PORT, &server_addr));
pinger = malloc(sizeof(*pinger));
@ -229,9 +229,9 @@ static void tcp_pinger_new(int vectored_writes) {
static void pipe_pinger_new(int vectored_writes) {
int r;
pinger_t *pinger;
pinger_t* pinger;
pinger = (pinger_t*)malloc(sizeof(*pinger));
pinger = malloc(sizeof(*pinger));
ASSERT(pinger != NULL);
pinger->vectored_writes = vectored_writes;
pinger->state = 0;

View File

@ -24,29 +24,35 @@ TEST_IMPL(pipe_set_non_blocking) {
#else /* !_WIN32 */
#include <errno.h>
#include <string.h>
#include <sys/socket.h>
#include <string.h> /* memset */
#include <unistd.h> /* close */
#include <sys/types.h>
#include <sys/un.h>
#include <unistd.h>
#include <sys/socket.h>
struct thread_ctx {
uv_barrier_t barrier;
int fd;
uv_file fd;
};
static void thread_main(void* arg) {
struct thread_ctx* ctx;
uv_fs_t req;
uv_buf_t bufs[1];
char buf[4096];
ssize_t n;
int uv_errno;
bufs[0] = uv_buf_init(buf, sizeof(buf));
ctx = arg;
uv_barrier_wait(&ctx->barrier);
do
n = read(ctx->fd, buf, sizeof(buf));
while (n > 0 || (n == -1 && errno == EINTR));
uv_sleep(100); /* make sure we are forcing the writer to block a bit */
do {
uv_errno = uv_fs_read(NULL, &req, ctx->fd, bufs, 1, -1, NULL);
n = req.result;
uv_fs_req_cleanup(&req);
} while (n > 0 || (n == -1 && uv_errno == UV_EINTR));
ASSERT(n == 0);
}
@ -58,15 +64,16 @@ TEST_IMPL(pipe_set_non_blocking) {
size_t nwritten;
char data[4096];
uv_buf_t buf;
int fd[2];
uv_file fd[2];
int n;
ASSERT(0 == uv_pipe_init(uv_default_loop(), &pipe_handle, 0));
ASSERT(0 == socketpair(AF_UNIX, SOCK_STREAM, 0, fd));
ASSERT(0 == uv_pipe_open(&pipe_handle, fd[0]));
ASSERT(0 == uv_pipe_open(&pipe_handle, fd[1]));
ASSERT(0 == uv_stream_set_blocking((uv_stream_t*) &pipe_handle, 1));
fd[1] = -1; /* fd[1] is owned by pipe_handle now. */
ctx.fd = fd[1];
ctx.fd = fd[0];
ASSERT(0 == uv_barrier_init(&ctx.barrier, 2));
ASSERT(0 == uv_thread_create(&thread, thread_main, &ctx));
uv_barrier_wait(&ctx.barrier);
@ -89,7 +96,8 @@ TEST_IMPL(pipe_set_non_blocking) {
ASSERT(0 == uv_run(uv_default_loop(), UV_RUN_DEFAULT));
ASSERT(0 == uv_thread_join(&thread));
ASSERT(0 == close(fd[1])); /* fd[0] is closed by uv_close(). */
ASSERT(0 == close(fd[0])); /* fd[1] is closed by uv_close(). */
fd[0] = -1;
uv_barrier_destroy(&ctx.barrier);
MAKE_VALGRIND_HAPPY();

View File

@ -71,7 +71,7 @@ static void exit_cb(uv_process_t* process,
exit_cb_called++;
ASSERT(exit_status == 1);
ASSERT(term_signal == 0);
uv_close((uv_handle_t*)process, close_cb);
uv_close((uv_handle_t*) process, close_cb);
}
@ -104,7 +104,7 @@ static void kill_cb(uv_process_t* process,
#else
ASSERT(no_term_signal || term_signal == SIGTERM);
#endif
uv_close((uv_handle_t*)process, close_cb);
uv_close((uv_handle_t*) process, close_cb);
/*
* Sending signum == 0 should check if the
@ -135,7 +135,7 @@ static void on_read(uv_stream_t* tcp, ssize_t nread, const uv_buf_t* buf) {
output_used += nread;
} else if (nread < 0) {
ASSERT(nread == UV_EOF);
uv_close((uv_handle_t*)tcp, close_cb);
uv_close((uv_handle_t*) tcp, close_cb);
}
}
@ -150,7 +150,7 @@ static void on_read_once(uv_stream_t* tcp, ssize_t nread, const uv_buf_t* buf) {
static void write_cb(uv_write_t* req, int status) {
ASSERT(status == 0);
uv_close((uv_handle_t*)req->handle, close_cb);
uv_close((uv_handle_t*) req->handle, close_cb);
}
@ -172,8 +172,8 @@ static void init_process_options(char* test, uv_exit_cb exit_cb) {
static void timer_cb(uv_timer_t* handle) {
uv_process_kill(&process, /* SIGTERM */ 15);
uv_close((uv_handle_t*)handle, close_cb);
uv_process_kill(&process, SIGTERM);
uv_close((uv_handle_t*) handle, close_cb);
}
@ -291,7 +291,7 @@ TEST_IMPL(spawn_stdout) {
options.stdio = stdio;
options.stdio[0].flags = UV_IGNORE;
options.stdio[1].flags = UV_CREATE_PIPE | UV_WRITABLE_PIPE;
options.stdio[1].data.stream = (uv_stream_t*)&out;
options.stdio[1].data.stream = (uv_stream_t*) &out;
options.stdio_count = 2;
r = uv_spawn(uv_default_loop(), &process, &options);
@ -595,9 +595,9 @@ TEST_IMPL(spawn_stdin) {
uv_pipe_init(uv_default_loop(), &in, 0);
options.stdio = stdio;
options.stdio[0].flags = UV_CREATE_PIPE | UV_READABLE_PIPE;
options.stdio[0].data.stream = (uv_stream_t*)&in;
options.stdio[0].data.stream = (uv_stream_t*) &in;
options.stdio[1].flags = UV_CREATE_PIPE | UV_WRITABLE_PIPE;
options.stdio[1].data.stream = (uv_stream_t*)&out;
options.stdio[1].data.stream = (uv_stream_t*) &out;
options.stdio_count = 2;
r = uv_spawn(uv_default_loop(), &process, &options);
@ -605,7 +605,7 @@ TEST_IMPL(spawn_stdin) {
buf.base = buffer;
buf.len = sizeof(buffer);
r = uv_write(&write_req, (uv_stream_t*)&in, &buf, 1, write_cb);
r = uv_write(&write_req, (uv_stream_t*) &in, &buf, 1, write_cb);
ASSERT(r == 0);
r = uv_read_start((uv_stream_t*) &out, on_alloc, on_read);
@ -636,7 +636,7 @@ TEST_IMPL(spawn_stdio_greater_than_3) {
options.stdio[1].flags = UV_IGNORE;
options.stdio[2].flags = UV_IGNORE;
options.stdio[3].flags = UV_CREATE_PIPE | UV_WRITABLE_PIPE;
options.stdio[3].data.stream = (uv_stream_t*)&pipe;
options.stdio[3].data.stream = (uv_stream_t*) &pipe;
options.stdio_count = 4;
r = uv_spawn(uv_default_loop(), &process, &options);
@ -677,7 +677,7 @@ int spawn_tcp_server_helper(void) {
/* Make sure that we can listen on a socket that was
* passed down from the parent process
*/
r = uv_listen((uv_stream_t*)&tcp, SOMAXCONN, NULL);
r = uv_listen((uv_stream_t*) &tcp, SOMAXCONN, NULL);
ASSERT(r == 0);
return 1;
@ -703,10 +703,10 @@ TEST_IMPL(spawn_tcp_server) {
r = uv_tcp_bind(&tcp_server, (const struct sockaddr*) &addr, 0);
ASSERT(r == 0);
#ifdef _WIN32
r = uv_fileno((uv_handle_t*)&tcp_server, &handle);
r = uv_fileno((uv_handle_t*) &tcp_server, &handle);
fd = _open_osfhandle((intptr_t) handle, 0);
#else
r = uv_fileno((uv_handle_t*)&tcp_server, &fd);
r = uv_fileno((uv_handle_t*) &tcp_server, &fd);
#endif
ASSERT(r == 0);
ASSERT(fd > 0);
@ -833,7 +833,7 @@ TEST_IMPL(spawn_detached) {
r = uv_spawn(uv_default_loop(), &process, &options);
ASSERT(r == 0);
uv_unref((uv_handle_t*)&process);
uv_unref((uv_handle_t*) &process);
r = uv_run(uv_default_loop(), UV_RUN_DEFAULT);
ASSERT(r == 0);
@ -845,7 +845,7 @@ TEST_IMPL(spawn_detached) {
r = uv_kill(process.pid, 0);
ASSERT(r == 0);
r = uv_kill(process.pid, 15);
r = uv_kill(process.pid, SIGTERM);
ASSERT(r == 0);
MAKE_VALGRIND_HAPPY();
@ -874,11 +874,11 @@ TEST_IMPL(spawn_and_kill_with_std) {
options.stdio = stdio;
options.stdio[0].flags = UV_CREATE_PIPE | UV_READABLE_PIPE;
options.stdio[0].data.stream = (uv_stream_t*)&in;
options.stdio[0].data.stream = (uv_stream_t*) &in;
options.stdio[1].flags = UV_CREATE_PIPE | UV_WRITABLE_PIPE;
options.stdio[1].data.stream = (uv_stream_t*)&out;
options.stdio[1].data.stream = (uv_stream_t*) &out;
options.stdio[2].flags = UV_CREATE_PIPE | UV_WRITABLE_PIPE;
options.stdio[2].data.stream = (uv_stream_t*)&err;
options.stdio[2].data.stream = (uv_stream_t*) &err;
options.stdio_count = 3;
r = uv_spawn(uv_default_loop(), &process, &options);
@ -925,9 +925,9 @@ TEST_IMPL(spawn_and_ping) {
uv_pipe_init(uv_default_loop(), &in, 0);
options.stdio = stdio;
options.stdio[0].flags = UV_CREATE_PIPE | UV_READABLE_PIPE;
options.stdio[0].data.stream = (uv_stream_t*)&in;
options.stdio[0].data.stream = (uv_stream_t*) &in;
options.stdio[1].flags = UV_CREATE_PIPE | UV_WRITABLE_PIPE;
options.stdio[1].data.stream = (uv_stream_t*)&out;
options.stdio[1].data.stream = (uv_stream_t*) &out;
options.stdio_count = 2;
r = uv_spawn(uv_default_loop(), &process, &options);
@ -939,10 +939,10 @@ TEST_IMPL(spawn_and_ping) {
r = uv_process_kill(&process, 0);
ASSERT(r == 0);
r = uv_write(&write_req, (uv_stream_t*)&in, &buf, 1, write_cb);
r = uv_write(&write_req, (uv_stream_t*) &in, &buf, 1, write_cb);
ASSERT(r == 0);
r = uv_read_start((uv_stream_t*)&out, on_alloc, on_read);
r = uv_read_start((uv_stream_t*) &out, on_alloc, on_read);
ASSERT(r == 0);
ASSERT(exit_cb_called == 0);
@ -972,9 +972,9 @@ TEST_IMPL(spawn_same_stdout_stderr) {
uv_pipe_init(uv_default_loop(), &in, 0);
options.stdio = stdio;
options.stdio[0].flags = UV_CREATE_PIPE | UV_READABLE_PIPE;
options.stdio[0].data.stream = (uv_stream_t*)&in;
options.stdio[0].data.stream = (uv_stream_t*) &in;
options.stdio[1].flags = UV_CREATE_PIPE | UV_WRITABLE_PIPE;
options.stdio[1].data.stream = (uv_stream_t*)&out;
options.stdio[1].data.stream = (uv_stream_t*) &out;
options.stdio_count = 2;
r = uv_spawn(uv_default_loop(), &process, &options);
@ -986,10 +986,10 @@ TEST_IMPL(spawn_same_stdout_stderr) {
r = uv_process_kill(&process, 0);
ASSERT(r == 0);
r = uv_write(&write_req, (uv_stream_t*)&in, &buf, 1, write_cb);
r = uv_write(&write_req, (uv_stream_t*) &in, &buf, 1, write_cb);
ASSERT(r == 0);
r = uv_read_start((uv_stream_t*)&out, on_alloc, on_read);
r = uv_read_start((uv_stream_t*) &out, on_alloc, on_read);
ASSERT(r == 0);
ASSERT(exit_cb_called == 0);
@ -1077,7 +1077,7 @@ TEST_IMPL(kill) {
ASSERT(r == 0);
/* Kill the process. */
r = uv_kill(process.pid, /* SIGTERM */ 15);
r = uv_kill(process.pid, SIGTERM);
ASSERT(r == 0);
r = uv_run(uv_default_loop(), UV_RUN_DEFAULT);
@ -1105,7 +1105,7 @@ TEST_IMPL(spawn_detect_pipe_name_collisions_on_windows) {
options.stdio = stdio;
options.stdio[0].flags = UV_IGNORE;
options.stdio[1].flags = UV_CREATE_PIPE | UV_WRITABLE_PIPE;
options.stdio[1].data.stream = (uv_stream_t*)&out;
options.stdio[1].data.stream = (uv_stream_t*) &out;
options.stdio_count = 2;
/* Create a pipe that'll cause a collision. */
@ -1821,32 +1821,32 @@ TEST_IMPL(spawn_inherit_streams) {
ASSERT(uv_is_writable((uv_stream_t*) &pipe_stdout_parent) == bidir);
child_stdio[0].flags = UV_INHERIT_STREAM;
child_stdio[0].data.stream = (uv_stream_t *)&pipe_stdin_child;
child_stdio[0].data.stream = (uv_stream_t *) &pipe_stdin_child;
child_stdio[1].flags = UV_INHERIT_STREAM;
child_stdio[1].data.stream = (uv_stream_t *)&pipe_stdout_child;
child_stdio[1].data.stream = (uv_stream_t *) &pipe_stdout_child;
options.stdio = child_stdio;
options.stdio_count = 2;
ASSERT(uv_spawn(loop, &child_req, &options) == 0);
uv_close((uv_handle_t*)&pipe_stdin_child, NULL);
uv_close((uv_handle_t*)&pipe_stdout_child, NULL);
uv_close((uv_handle_t*) &pipe_stdin_child, NULL);
uv_close((uv_handle_t*) &pipe_stdout_child, NULL);
buf = uv_buf_init((char*)ubuf, sizeof ubuf);
buf = uv_buf_init((char*) ubuf, sizeof ubuf);
for (i = 0; i < sizeof ubuf; ++i)
ubuf[i] = i & 255u;
memset(output, 0, sizeof ubuf);
r = uv_write(&write_req,
(uv_stream_t*)&pipe_stdin_parent,
(uv_stream_t*) &pipe_stdin_parent,
&buf,
1,
write_cb);
ASSERT(r == 0);
r = uv_read_start((uv_stream_t*)&pipe_stdout_parent, on_alloc, on_read);
r = uv_read_start((uv_stream_t*) &pipe_stdout_parent, on_alloc, on_read);
ASSERT(r == 0);
r = uv_run(loop, UV_RUN_DEFAULT);