From 4d68daea0f3b092743a7793748f684c2827d6210 Mon Sep 17 00:00:00 2001 From: Ben Noordhuis Date: Sun, 26 May 2013 17:06:45 +0200 Subject: src: replace c-style casts with c++-style casts --- src/cares_wrap.cc | 15 +++++++++------ src/fs_event_wrap.cc | 4 ++-- src/node.cc | 6 +++--- src/node_win32_etw_provider.cc | 8 ++++---- src/pipe_wrap.cc | 13 ++++++++----- src/process_wrap.cc | 2 +- src/stream_wrap.cc | 6 +++--- src/tcp_wrap.cc | 16 ++++++++++------ src/timer_wrap.cc | 2 +- src/tty_wrap.cc | 2 +- src/udp_wrap.cc | 4 ++-- 11 files changed, 44 insertions(+), 34 deletions(-) diff --git a/src/cares_wrap.cc b/src/cares_wrap.cc index 8cca4214bd..ae4d174196 100644 --- a/src/cares_wrap.cc +++ b/src/cares_wrap.cc @@ -120,7 +120,7 @@ static void ares_poll_close_cb(uv_handle_t* watcher) { /* Allocates and returns a new ares_task_t */ static ares_task_t* ares_task_create(uv_loop_t* loop, ares_socket_t sock) { - ares_task_t* task = (ares_task_t*) malloc(sizeof *task); + ares_task_t* task = static_cast(malloc(sizeof(*task))); if (task == NULL) { /* Out of memory. */ @@ -141,9 +141,11 @@ static ares_task_t* ares_task_create(uv_loop_t* loop, ares_socket_t sock) { /* Callback from ares when socket operation is started */ -static void ares_sockstate_cb(void* data, ares_socket_t sock, - int read, int write) { - uv_loop_t* loop = (uv_loop_t*) data; +static void ares_sockstate_cb(void* data, + ares_socket_t sock, + int read, + int write) { + uv_loop_t* loop = static_cast(data); ares_task_t* task; ares_task_t lookup_task; @@ -155,7 +157,7 @@ static void ares_sockstate_cb(void* data, ares_socket_t sock, /* New socket */ /* If this is the first socket then start the timer. */ - if (!uv_is_active((uv_handle_t*) &ares_timer)) { + if (!uv_is_active(reinterpret_cast(&ares_timer))) { assert(RB_EMPTY(&ares_tasks)); uv_timer_start(&ares_timer, ares_timeout, 1000, 1000); } @@ -185,7 +187,8 @@ static void ares_sockstate_cb(void* data, ares_socket_t sock, "When an ares socket is closed we should have a handle for it"); RB_REMOVE(ares_task_list, &ares_tasks, task); - uv_close((uv_handle_t*) &task->poll_watcher, ares_poll_close_cb); + uv_close(reinterpret_cast(&task->poll_watcher), + ares_poll_close_cb); if (RB_EMPTY(&ares_tasks)) { uv_timer_stop(&ares_timer); diff --git a/src/fs_event_wrap.cc b/src/fs_event_wrap.cc index 985171fcd4..69d3b155e6 100644 --- a/src/fs_event_wrap.cc +++ b/src/fs_event_wrap.cc @@ -51,8 +51,8 @@ private: }; -FSEventWrap::FSEventWrap(Handle object): HandleWrap(object, - (uv_handle_t*)&handle_) { +FSEventWrap::FSEventWrap(Handle object) + : HandleWrap(object, reinterpret_cast(&handle_)) { handle_.data = static_cast(this); initialized_ = false; } diff --git a/src/node.cc b/src/node.cc index b681c292af..968832825f 100644 --- a/src/node.cc +++ b/src/node.cc @@ -179,7 +179,7 @@ Isolate* node_isolate = NULL; static void Spin(uv_idle_t* handle, int status) { - assert((uv_idle_t*) handle == &tick_spinner); + assert(handle == &tick_spinner); assert(status == 0); // Avoid entering a V8 scope. @@ -2972,7 +2972,7 @@ char** Init(int argc, char *argv[]) { uv_idle_init(uv_default_loop(), &tick_spinner); uv_check_init(uv_default_loop(), &check_immediate_watcher); - uv_unref((uv_handle_t*) &check_immediate_watcher); + uv_unref(reinterpret_cast(&check_immediate_watcher)); uv_idle_init(uv_default_loop(), &idle_immediate_dummy); V8::SetFatalErrorHandler(node::OnFatalError); @@ -2987,7 +2987,7 @@ char** Init(int argc, char *argv[]) { static uv_signal_t signal_watcher; uv_signal_init(uv_default_loop(), &signal_watcher); uv_signal_start(&signal_watcher, EnableDebugSignalHandler, SIGUSR1); - uv_unref((uv_handle_t*)&signal_watcher); + uv_unref(reinterpret_cast(&signal_watcher)); #endif // __POSIX__ } diff --git a/src/node_win32_etw_provider.cc b/src/node_win32_etw_provider.cc index 26769b0e5a..258005c8b8 100644 --- a/src/node_win32_etw_provider.cc +++ b/src/node_win32_etw_provider.cc @@ -173,9 +173,9 @@ void init_etw() { // create async object used to invoke main thread from callback uv_async_init(uv_default_loop(), - &dispatch_etw_events_change_async, - etw_events_change_async); - uv_unref((uv_handle_t*) &dispatch_etw_events_change_async); + &dispatch_etw_events_change_async, + etw_events_change_async); + uv_unref(reinterpret_cast(&dispatch_etw_events_change_async)); if (event_register) { DWORD status = event_register(&NODE_ETW_PROVIDER, @@ -202,4 +202,4 @@ void shutdown_etw() { advapi = NULL; } } -} \ No newline at end of file +} diff --git a/src/pipe_wrap.cc b/src/pipe_wrap.cc index ba71292038..dd2cbd6fb1 100644 --- a/src/pipe_wrap.cc +++ b/src/pipe_wrap.cc @@ -135,7 +135,7 @@ Handle PipeWrap::New(const Arguments& args) { PipeWrap::PipeWrap(Handle object, bool ipc) - : StreamWrap(object, (uv_stream_t*) &handle_) { + : StreamWrap(object, reinterpret_cast(&handle_)) { int r = uv_pipe_init(uv_default_loop(), &handle_, ipc); assert(r == 0); // How do we proxy this error up to javascript? // Suggestion: uv_pipe_init() returns void. @@ -182,7 +182,9 @@ Handle PipeWrap::Listen(const Arguments& args) { int backlog = args[0]->Int32Value(); - int r = uv_listen((uv_stream_t*)&wrap->handle_, backlog, OnConnection); + int r = uv_listen(reinterpret_cast(&wrap->handle_), + backlog, + OnConnection); // Error starting the pipe. if (r) SetErrno(uv_last_error(uv_default_loop())); @@ -196,7 +198,7 @@ void PipeWrap::OnConnection(uv_stream_t* handle, int status) { HandleScope scope(node_isolate); PipeWrap* wrap = static_cast(handle->data); - assert(&wrap->handle_ == (uv_pipe_t*)handle); + assert(&wrap->handle_ == reinterpret_cast(handle)); // We should not be getting this callback if someone as already called // uv_close() on the handle. @@ -215,8 +217,9 @@ void PipeWrap::OnConnection(uv_stream_t* handle, int status) { assert(client_obj->InternalFieldCount() > 0); PipeWrap* client_wrap = static_cast(client_obj->GetAlignedPointerFromInternalField(0)); - - if (uv_accept(handle, (uv_stream_t*)&client_wrap->handle_)) return; + uv_stream_t* client_handle = + reinterpret_cast(&client_wrap->handle_); + if (uv_accept(handle, client_handle)) return; // Successful accept. Call the onconnection callback in JavaScript land. Local argv[1] = { client_obj }; diff --git a/src/process_wrap.cc b/src/process_wrap.cc index edc19116a9..8ed8976f77 100644 --- a/src/process_wrap.cc +++ b/src/process_wrap.cc @@ -248,7 +248,7 @@ class ProcessWrap : public HandleWrap { SetErrno(uv_last_error(uv_default_loop())); } else { - wrap->SetHandle((uv_handle_t*)&wrap->process_); + wrap->SetHandle(reinterpret_cast(&wrap->process_)); assert(wrap->process_.data == wrap); wrap->object_->Set(String::New("pid"), Integer::New(wrap->process_.pid, node_isolate)); diff --git a/src/stream_wrap.cc b/src/stream_wrap.cc index 84c1b99d8d..aaf4491c4e 100644 --- a/src/stream_wrap.cc +++ b/src/stream_wrap.cc @@ -110,7 +110,7 @@ void StreamWrap::Initialize(Handle target) { StreamWrap::StreamWrap(Handle object, uv_stream_t* stream) - : HandleWrap(object, (uv_handle_t*)stream) { + : HandleWrap(object, reinterpret_cast(stream)) { stream_ = stream; if (stream) { stream->data = this; @@ -151,7 +151,7 @@ Handle StreamWrap::ReadStart(const Arguments& args) { UNWRAP(StreamWrap) bool ipc_pipe = wrap->stream_->type == UV_NAMED_PIPE && - ((uv_pipe_t*)wrap->stream_)->ipc; + reinterpret_cast(wrap->stream_)->ipc; int r; if (ipc_pipe) { r = uv_read2_start(wrap->stream_, OnAlloc, OnRead2); @@ -385,7 +385,7 @@ Handle StreamWrap::WriteStringImpl(const Arguments& args) { buf.len = data_size; bool ipc_pipe = wrap->stream_->type == UV_NAMED_PIPE && - ((uv_pipe_t*)wrap->stream_)->ipc; + reinterpret_cast(wrap->stream_)->ipc; if (!ipc_pipe) { r = uv_write(&req_wrap->req_, diff --git a/src/tcp_wrap.cc b/src/tcp_wrap.cc index b1979a2d21..43199637ad 100644 --- a/src/tcp_wrap.cc +++ b/src/tcp_wrap.cc @@ -156,7 +156,7 @@ Handle TCPWrap::New(const Arguments& args) { TCPWrap::TCPWrap(Handle object) - : StreamWrap(object, (uv_stream_t*) &handle_) { + : StreamWrap(object, reinterpret_cast(&handle_)) { int r = uv_tcp_init(uv_default_loop(), &handle_); assert(r == 0); // How do we proxy this error up to javascript? // Suggestion: uv_tcp_init() returns void. @@ -310,7 +310,9 @@ Handle TCPWrap::Listen(const Arguments& args) { int backlog = args[0]->Int32Value(); - int r = uv_listen((uv_stream_t*)&wrap->handle_, backlog, OnConnection); + int r = uv_listen(reinterpret_cast(&wrap->handle_), + backlog, + OnConnection); // Error starting the tcp. if (r) SetErrno(uv_last_error(uv_default_loop())); @@ -323,7 +325,7 @@ void TCPWrap::OnConnection(uv_stream_t* handle, int status) { HandleScope scope(node_isolate); TCPWrap* wrap = static_cast(handle->data); - assert(&wrap->handle_ == (uv_tcp_t*)handle); + assert(&wrap->handle_ == reinterpret_cast(handle)); // We should not be getting this callback if someone as already called // uv_close() on the handle. @@ -337,10 +339,12 @@ void TCPWrap::OnConnection(uv_stream_t* handle, int status) { // Unwrap the client javascript object. assert(client_obj->InternalFieldCount() > 0); - TCPWrap* client_wrap = static_cast( - client_obj->GetAlignedPointerFromInternalField(0)); - if (uv_accept(handle, (uv_stream_t*)&client_wrap->handle_)) return; + void* client_wrap_v = client_obj->GetAlignedPointerFromInternalField(0); + TCPWrap* client_wrap = static_cast(client_wrap_v); + uv_stream_t* client_handle = + reinterpret_cast(&client_wrap->handle_); + if (uv_accept(handle, client_handle)) return; // Successful accept. Call the onconnection callback in JavaScript land. argv[0] = client_obj; diff --git a/src/timer_wrap.cc b/src/timer_wrap.cc index 90bb553f05..5e8ab051a6 100644 --- a/src/timer_wrap.cc +++ b/src/timer_wrap.cc @@ -83,7 +83,7 @@ class TimerWrap : public HandleWrap { } TimerWrap(Handle object) - : HandleWrap(object, (uv_handle_t*) &handle_) { + : HandleWrap(object, reinterpret_cast(&handle_)) { int r = uv_timer_init(uv_default_loop(), &handle_); assert(r == 0); handle_.data = this; diff --git a/src/tty_wrap.cc b/src/tty_wrap.cc index ed83e71f52..1e70a4ff2a 100644 --- a/src/tty_wrap.cc +++ b/src/tty_wrap.cc @@ -199,7 +199,7 @@ Handle TTYWrap::New(const Arguments& args) { TTYWrap::TTYWrap(Handle object, int fd, bool readable) - : StreamWrap(object, (uv_stream_t*)&handle_) { + : StreamWrap(object, reinterpret_cast(&handle_)) { uv_tty_init(uv_default_loop(), &handle_, fd, readable); } diff --git a/src/udp_wrap.cc b/src/udp_wrap.cc index 31cadb5e76..f014a62cc6 100644 --- a/src/udp_wrap.cc +++ b/src/udp_wrap.cc @@ -65,8 +65,8 @@ static void DeleteSlabAllocator(void*) { } -UDPWrap::UDPWrap(Handle object): HandleWrap(object, - (uv_handle_t*)&handle_) { +UDPWrap::UDPWrap(Handle object) + : HandleWrap(object, reinterpret_cast(&handle_)) { int r = uv_udp_init(uv_default_loop(), &handle_); assert(r == 0); // can't fail anyway handle_.data = reinterpret_cast(this); -- cgit v1.2.3