Use proper types instead of void pointers to store loop callbacks

This commit is contained in:
Bert Belder 2011-06-08 21:59:05 +02:00
parent cd6ceb0ef4
commit 9b1123b219
2 changed files with 13 additions and 13 deletions

View File

@ -1094,7 +1094,7 @@ static void uv_tcp_return_req(uv_tcp_t* handle, uv_req_t* req) {
uv_last_error_ = req->error;
buf.base = 0;
buf.len = 0;
((uv_read_cb)handle->read_cb)(handle, -1, buf);
handle->read_cb(handle, -1, buf);
break;
}
@ -1112,7 +1112,7 @@ static void uv_tcp_return_req(uv_tcp_t* handle, uv_req_t* req) {
NULL) != SOCKET_ERROR) {
if (bytes > 0) {
/* Successful read */
((uv_read_cb)handle->read_cb)(handle, bytes, buf);
handle->read_cb(handle, bytes, buf);
/* Read again only if bytes == buf.len */
if (bytes < buf.len) {
break;
@ -1123,7 +1123,7 @@ static void uv_tcp_return_req(uv_tcp_t* handle, uv_req_t* req) {
handle->flags |= UV_HANDLE_EOF;
uv_last_error_.code = UV_EOF;
uv_last_error_.sys_errno_ = ERROR_SUCCESS;
((uv_read_cb)handle->read_cb)(handle, -1, buf);
handle->read_cb(handle, -1, buf);
break;
}
} else {
@ -1131,11 +1131,11 @@ static void uv_tcp_return_req(uv_tcp_t* handle, uv_req_t* req) {
if (err == WSAEWOULDBLOCK) {
/* Read buffer was completely empty, report a 0-byte read. */
uv_set_sys_error(WSAEWOULDBLOCK);
((uv_read_cb)handle->read_cb)(handle, 0, buf);
handle->read_cb(handle, 0, buf);
} else {
/* Ouch! serious error. */
uv_set_sys_error(err);
((uv_read_cb)handle->read_cb)(handle, -1, buf);
handle->read_cb(handle, -1, buf);
}
break;
}
@ -1156,7 +1156,7 @@ static void uv_tcp_return_req(uv_tcp_t* handle, uv_req_t* req) {
handle->flags &= ~UV_HANDLE_LISTENING;
if (handle->connection_cb) {
uv_last_error_ = req->error;
((uv_connection_cb)handle->connection_cb)(handle, -1);
handle->connection_cb(handle, -1);
}
break;
}
@ -1169,7 +1169,7 @@ static void uv_tcp_return_req(uv_tcp_t* handle, uv_req_t* req) {
sizeof(handle->socket)) == 0) {
/* Accept and SO_UPDATE_ACCEPT_CONTEXT were successful. */
if (handle->connection_cb) {
((uv_connection_cb)handle->connection_cb)(handle, 0);
handle->connection_cb(handle, 0);
}
} else {
/* Error related to accepted socket is ignored because the server */
@ -1402,7 +1402,7 @@ static void uv_loop_invoke(uv_handle_t* list) {
handle = uv_next_loop_handle_;
uv_next_loop_handle_ = handle->loop_next;
((uv_loop_cb)handle->loop_cb)(handle, 0);
handle->loop_cb(handle, 0);
}
}
@ -1576,7 +1576,7 @@ static void uv_process_timers() {
timer->flags &= ~UV_HANDLE_ACTIVE;
}
((uv_loop_cb) timer->timer_cb)((uv_handle_t*)timer, 0);
timer->timer_cb((uv_handle_t*) timer, 0);
}
}

View File

@ -55,13 +55,13 @@ typedef struct uv_buf_t {
#define uv_tcp_connection_fields \
uv_alloc_cb alloc_cb; \
void* read_cb; \
uv_read_cb read_cb; \
struct uv_req_s read_req; \
unsigned int write_reqs_pending; \
uv_req_t* shutdown_req;
#define uv_tcp_server_fields \
void *connection_cb; \
uv_connection_cb connection_cb; \
SOCKET accept_socket; \
struct uv_req_s accept_req; \
char accept_buffer[sizeof(struct sockaddr_storage) * 2 + 32];
@ -81,12 +81,12 @@ typedef struct uv_buf_t {
RB_ENTRY(uv_timer_s) tree_entry; \
int64_t due; \
int64_t repeat; \
void* timer_cb;
uv_loop_cb timer_cb;
#define UV_LOOP_PRIVATE_FIELDS \
uv_handle_t* loop_prev; \
uv_handle_t* loop_next; \
void* loop_cb;
uv_loop_cb loop_cb;
#define UV_ASYNC_PRIVATE_FIELDS \
struct uv_req_s async_req; \