Skip to content
This repository has been archived by the owner on May 4, 2018. It is now read-only.

Fix a couple warnings, added some asserts, and compiling with gcc-4.5 and mingw-w64 #186

Closed
wants to merge 4 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/unix/fs.c
Expand Up @@ -504,11 +504,11 @@ static int _futime(const uv_file file, double atime, double mtime) {

int uv_fs_futime(uv_loop_t* loop, uv_fs_t* req, uv_file file, double atime,
double mtime, uv_fs_cb cb) {
#if defined(HAVE_FUTIMES)
const char* path = NULL;

uv_fs_req_init(loop, req, UV_FS_FUTIME, path, cb);

#if defined(HAVE_FUTIMES)
WRAP_EIO(UV_FS_FUTIME, eio_futime, _futime, ARGS3(file, atime, mtime))
#else
uv_err_new(loop, ENOSYS);
Expand Down
4 changes: 2 additions & 2 deletions src/win/winapi.h
Expand Up @@ -4079,8 +4079,8 @@
(FACILITY_NTWIN32 << 16) | ERROR_SEVERITY_WARNING)))

/* from ntifs.h */
/* MinGW already has it */
#ifndef __MINGW32__
/* MinGW32 already has it */
#if !defined(__MINGW32__) || defined(__MINGW64_VERSION_MAJOR)
typedef struct _REPARSE_DATA_BUFFER {
ULONG ReparseTag;
USHORT ReparseDataLength;
Expand Down
6 changes: 4 additions & 2 deletions test/benchmark-pump.c
Expand Up @@ -273,10 +273,12 @@ static void connection_cb(uv_stream_t* s, int status) {

if (type == TCP) {
stream = (uv_stream_t*)malloc(sizeof(uv_tcp_t));
uv_tcp_init(loop, (uv_tcp_t*)stream);
r = uv_tcp_init(loop, (uv_tcp_t*)stream);
ASSERT(r == 0);
} else {
stream = (uv_stream_t*)malloc(sizeof(uv_pipe_t));
uv_pipe_init(loop, (uv_pipe_t*)stream);
r = uv_pipe_init(loop, (uv_pipe_t*)stream);
ASSERT(r == 0);
}

r = uv_accept(s, stream);
Expand Down
3 changes: 2 additions & 1 deletion test/dns-server.c
Expand Up @@ -272,7 +272,8 @@ static void on_connection(uv_stream_t* server, int status) {
handle->state.prevbuf_pos = 0;
handle->state.prevbuf_rem = 0;

uv_tcp_init(loop, (uv_tcp_t*)handle);
r = uv_tcp_init(loop, (uv_tcp_t*)handle);
ASSERT(r == 0);

r = uv_accept(server, (uv_stream_t*)handle);
ASSERT(r == 0);
Expand Down
6 changes: 4 additions & 2 deletions test/echo-server.c
Expand Up @@ -144,13 +144,15 @@ static void on_connection(uv_stream_t* server, int status) {
case TCP:
stream = malloc(sizeof(uv_tcp_t));
ASSERT(stream != NULL);
uv_tcp_init(loop, (uv_tcp_t*)stream);
r = uv_tcp_init(loop, (uv_tcp_t*)stream);
ASSERT(r == 0);
break;

case PIPE:
stream = malloc(sizeof(uv_pipe_t));
ASSERT(stream != NULL);
uv_pipe_init(loop, (uv_pipe_t*)stream);
r = uv_pipe_init(loop, (uv_pipe_t*)stream);
ASSERT(r == 0);
break;

default:
Expand Down
5 changes: 4 additions & 1 deletion test/test-connection-fail.c
Expand Up @@ -134,7 +134,10 @@ TEST_IMPL(connection_fail) {
* attempt.
*/
TEST_IMPL(connection_fail_doesnt_auto_close) {
uv_timer_init(uv_default_loop(), &timer);
int r;

r = uv_timer_init(uv_default_loop(), &timer);
ASSERT(r == 0);

connection_fail(on_connect_without_close);

Expand Down
3 changes: 2 additions & 1 deletion test/test-delayed-accept.c
Expand Up @@ -57,7 +57,8 @@ static void do_accept(uv_timer_t* timer_handle, int status) {
ASSERT(status == 0);
ASSERT(accepted_handle != NULL);

uv_tcp_init(uv_default_loop(), accepted_handle);
r = uv_tcp_init(uv_default_loop(), accepted_handle);
ASSERT(r == 0);

/* Test to that uv_default_loop()->counters.tcp_init does not increase across the uv_accept. */
tcpcnt = uv_default_loop()->counters.tcp_init;
Expand Down
3 changes: 2 additions & 1 deletion test/test-getsockname.c
Expand Up @@ -117,7 +117,8 @@ static void on_connection(uv_stream_t* server, int status) {
handle = (uv_handle_t*) malloc(sizeof(uv_tcp_t));
ASSERT(handle != NULL);

uv_tcp_init(loop, (uv_tcp_t*)handle);
r = uv_tcp_init(loop, (uv_tcp_t*)handle);
ASSERT(r == 0);

/* associate server with stream */
handle->data = server;
Expand Down
26 changes: 13 additions & 13 deletions test/test-ping-pong.c
Expand Up @@ -43,7 +43,7 @@ typedef struct {
union {
uv_tcp_t tcp;
uv_pipe_t pipe;
};
} stream;
uv_connect_t connect_req;
char read_buffer[BUFSIZE];
} pinger_t;
Expand Down Expand Up @@ -85,7 +85,7 @@ static void pinger_write_ping(pinger_t* pinger) {

req = malloc(sizeof(uv_write_t));

if (uv_write(req, (uv_stream_t*)&pinger->tcp, &buf, 1, pinger_after_write)) {
if (uv_write(req, (uv_stream_t*)&pinger->stream.tcp, &buf, 1, pinger_after_write)) {
FATAL("uv_write failed");
}

Expand All @@ -108,7 +108,7 @@ static void pinger_read_cb(uv_stream_t* stream, ssize_t nread, uv_buf_t buf) {
free(buf.base);
}

uv_close((uv_handle_t*)(&pinger->tcp), pinger_on_close);
uv_close((uv_handle_t*)(&pinger->stream.tcp), pinger_on_close);

return;
}
Expand All @@ -123,7 +123,7 @@ static void pinger_read_cb(uv_stream_t* stream, ssize_t nread, uv_buf_t buf) {
if (pinger->pongs < NUM_PINGS) {
pinger_write_ping(pinger);
} else {
uv_close((uv_handle_t*)(&pinger->tcp), pinger_on_close);
uv_close((uv_handle_t*)(&pinger->stream.tcp), pinger_on_close);
return;
}
}
Expand Down Expand Up @@ -155,13 +155,13 @@ static void tcp_pinger_v6_new() {
pinger->pongs = 0;

/* Try to connec to the server and do NUM_PINGS ping-pongs. */
r = uv_tcp_init(uv_default_loop(), &pinger->tcp);
pinger->tcp.data = pinger;
r = uv_tcp_init(uv_default_loop(), &pinger->stream.tcp);
pinger->stream.tcp.data = pinger;
ASSERT(!r);

/* We are never doing multiple reads/connects at a time anyway. */
/* so these handles can be pre-initialized. */
r = uv_tcp_connect6(&pinger->connect_req, &pinger->tcp, server_addr,
r = uv_tcp_connect6(&pinger->connect_req, &pinger->stream.tcp, server_addr,
pinger_on_connect);
ASSERT(!r);

Expand All @@ -180,13 +180,13 @@ static void tcp_pinger_new() {
pinger->pongs = 0;

/* Try to connec to the server and do NUM_PINGS ping-pongs. */
r = uv_tcp_init(uv_default_loop(), &pinger->tcp);
pinger->tcp.data = pinger;
r = uv_tcp_init(uv_default_loop(), &pinger->stream.tcp);
pinger->stream.tcp.data = pinger;
ASSERT(!r);

/* We are never doing multiple reads/connects at a time anyway. */
/* so these handles can be pre-initialized. */
r = uv_tcp_connect(&pinger->connect_req, &pinger->tcp, server_addr,
r = uv_tcp_connect(&pinger->connect_req, &pinger->stream.tcp, server_addr,
pinger_on_connect);
ASSERT(!r);

Expand All @@ -204,14 +204,14 @@ static void pipe_pinger_new() {
pinger->pongs = 0;

/* Try to connec to the server and do NUM_PINGS ping-pongs. */
r = uv_pipe_init(uv_default_loop(), &pinger->pipe);
pinger->pipe.data = pinger;
r = uv_pipe_init(uv_default_loop(), &pinger->stream.pipe);
pinger->stream.pipe.data = pinger;
ASSERT(!r);

/* We are never doing multiple reads/connects at a time anyway. */
/* so these handles can be pre-initialized. */

r = uv_pipe_connect(&pinger->connect_req, &pinger->pipe, TEST_PIPENAME,
r = uv_pipe_connect(&pinger->connect_req, &pinger->stream.pipe, TEST_PIPENAME,
pinger_on_connect);
ASSERT(!r);

Expand Down
4 changes: 3 additions & 1 deletion test/test-shutdown-eof.c
Expand Up @@ -156,7 +156,9 @@ TEST_IMPL(shutdown_eof) {
qbuf.base = "Q";
qbuf.len = 1;

uv_timer_init(uv_default_loop(), &timer);
r = uv_timer_init(uv_default_loop(), &timer);
ASSERT(r == 0);

uv_timer_start(&timer, timer_cb, 100, 0);

server_addr = uv_ip4_addr("127.0.0.1", TEST_PORT);
Expand Down
6 changes: 3 additions & 3 deletions uv.gyp
Expand Up @@ -126,7 +126,7 @@
],
'link_settings': {
'libraries': [
'-lws2_32.lib',
'-lws2_32',
],
},
}, { # Not Windows i.e. POSIX
Expand Down Expand Up @@ -275,7 +275,7 @@
'test/runner-win.c',
'test/runner-win.h'
],
'libraries': [ 'ws2_32.lib' ]
'libraries': [ '-lws2_32' ]
}, { # POSIX
'defines': [ '_GNU_SOURCE' ],
'ldflags': [ '-pthread' ],
Expand Down Expand Up @@ -319,7 +319,7 @@
'test/runner-win.c',
'test/runner-win.h',
],
'libraries': [ 'ws2_32.lib' ]
'libraries': [ '-lws2_32' ]
}, { # POSIX
'defines': [ '_GNU_SOURCE' ],
'ldflags': [ '-pthread' ],
Expand Down