Browse Source

src: replace c-style casts with c++-style casts

v0.11.3-release
Ben Noordhuis 12 years ago
parent
commit
4d68daea0f
  1. 15
      src/cares_wrap.cc
  2. 4
      src/fs_event_wrap.cc
  3. 6
      src/node.cc
  4. 2
      src/node_win32_etw_provider.cc
  5. 13
      src/pipe_wrap.cc
  6. 2
      src/process_wrap.cc
  7. 6
      src/stream_wrap.cc
  8. 16
      src/tcp_wrap.cc
  9. 2
      src/timer_wrap.cc
  10. 2
      src/tty_wrap.cc
  11. 4
      src/udp_wrap.cc

15
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 */ /* Allocates and returns a new ares_task_t */
static ares_task_t* ares_task_create(uv_loop_t* loop, ares_socket_t sock) { 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<ares_task_t*>(malloc(sizeof(*task)));
if (task == NULL) { if (task == NULL) {
/* Out of memory. */ /* 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 */ /* Callback from ares when socket operation is started */
static void ares_sockstate_cb(void* data, ares_socket_t sock, static void ares_sockstate_cb(void* data,
int read, int write) { ares_socket_t sock,
uv_loop_t* loop = (uv_loop_t*) data; int read,
int write) {
uv_loop_t* loop = static_cast<uv_loop_t*>(data);
ares_task_t* task; ares_task_t* task;
ares_task_t lookup_task; ares_task_t lookup_task;
@ -155,7 +157,7 @@ static void ares_sockstate_cb(void* data, ares_socket_t sock,
/* New socket */ /* New socket */
/* If this is the first socket then start the timer. */ /* 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<uv_handle_t*>(&ares_timer))) {
assert(RB_EMPTY(&ares_tasks)); assert(RB_EMPTY(&ares_tasks));
uv_timer_start(&ares_timer, ares_timeout, 1000, 1000); 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"); "When an ares socket is closed we should have a handle for it");
RB_REMOVE(ares_task_list, &ares_tasks, task); RB_REMOVE(ares_task_list, &ares_tasks, task);
uv_close((uv_handle_t*) &task->poll_watcher, ares_poll_close_cb); uv_close(reinterpret_cast<uv_handle_t*>(&task->poll_watcher),
ares_poll_close_cb);
if (RB_EMPTY(&ares_tasks)) { if (RB_EMPTY(&ares_tasks)) {
uv_timer_stop(&ares_timer); uv_timer_stop(&ares_timer);

4
src/fs_event_wrap.cc

@ -51,8 +51,8 @@ private:
}; };
FSEventWrap::FSEventWrap(Handle<Object> object): HandleWrap(object, FSEventWrap::FSEventWrap(Handle<Object> object)
(uv_handle_t*)&handle_) { : HandleWrap(object, reinterpret_cast<uv_handle_t*>(&handle_)) {
handle_.data = static_cast<void*>(this); handle_.data = static_cast<void*>(this);
initialized_ = false; initialized_ = false;
} }

6
src/node.cc

@ -179,7 +179,7 @@ Isolate* node_isolate = NULL;
static void Spin(uv_idle_t* handle, int status) { static void Spin(uv_idle_t* handle, int status) {
assert((uv_idle_t*) handle == &tick_spinner); assert(handle == &tick_spinner);
assert(status == 0); assert(status == 0);
// Avoid entering a V8 scope. // Avoid entering a V8 scope.
@ -2972,7 +2972,7 @@ char** Init(int argc, char *argv[]) {
uv_idle_init(uv_default_loop(), &tick_spinner); uv_idle_init(uv_default_loop(), &tick_spinner);
uv_check_init(uv_default_loop(), &check_immediate_watcher); uv_check_init(uv_default_loop(), &check_immediate_watcher);
uv_unref((uv_handle_t*) &check_immediate_watcher); uv_unref(reinterpret_cast<uv_handle_t*>(&check_immediate_watcher));
uv_idle_init(uv_default_loop(), &idle_immediate_dummy); uv_idle_init(uv_default_loop(), &idle_immediate_dummy);
V8::SetFatalErrorHandler(node::OnFatalError); V8::SetFatalErrorHandler(node::OnFatalError);
@ -2987,7 +2987,7 @@ char** Init(int argc, char *argv[]) {
static uv_signal_t signal_watcher; static uv_signal_t signal_watcher;
uv_signal_init(uv_default_loop(), &signal_watcher); uv_signal_init(uv_default_loop(), &signal_watcher);
uv_signal_start(&signal_watcher, EnableDebugSignalHandler, SIGUSR1); uv_signal_start(&signal_watcher, EnableDebugSignalHandler, SIGUSR1);
uv_unref((uv_handle_t*)&signal_watcher); uv_unref(reinterpret_cast<uv_handle_t*>(&signal_watcher));
#endif // __POSIX__ #endif // __POSIX__
} }

2
src/node_win32_etw_provider.cc

@ -175,7 +175,7 @@ void init_etw() {
uv_async_init(uv_default_loop(), uv_async_init(uv_default_loop(),
&dispatch_etw_events_change_async, &dispatch_etw_events_change_async,
etw_events_change_async); etw_events_change_async);
uv_unref((uv_handle_t*) &dispatch_etw_events_change_async); uv_unref(reinterpret_cast<uv_handle_t*>(&dispatch_etw_events_change_async));
if (event_register) { if (event_register) {
DWORD status = event_register(&NODE_ETW_PROVIDER, DWORD status = event_register(&NODE_ETW_PROVIDER,

13
src/pipe_wrap.cc

@ -135,7 +135,7 @@ Handle<Value> PipeWrap::New(const Arguments& args) {
PipeWrap::PipeWrap(Handle<Object> object, bool ipc) PipeWrap::PipeWrap(Handle<Object> object, bool ipc)
: StreamWrap(object, (uv_stream_t*) &handle_) { : StreamWrap(object, reinterpret_cast<uv_stream_t*>(&handle_)) {
int r = uv_pipe_init(uv_default_loop(), &handle_, ipc); int r = uv_pipe_init(uv_default_loop(), &handle_, ipc);
assert(r == 0); // How do we proxy this error up to javascript? assert(r == 0); // How do we proxy this error up to javascript?
// Suggestion: uv_pipe_init() returns void. // Suggestion: uv_pipe_init() returns void.
@ -182,7 +182,9 @@ Handle<Value> PipeWrap::Listen(const Arguments& args) {
int backlog = args[0]->Int32Value(); int backlog = args[0]->Int32Value();
int r = uv_listen((uv_stream_t*)&wrap->handle_, backlog, OnConnection); int r = uv_listen(reinterpret_cast<uv_stream_t*>(&wrap->handle_),
backlog,
OnConnection);
// Error starting the pipe. // Error starting the pipe.
if (r) SetErrno(uv_last_error(uv_default_loop())); 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); HandleScope scope(node_isolate);
PipeWrap* wrap = static_cast<PipeWrap*>(handle->data); PipeWrap* wrap = static_cast<PipeWrap*>(handle->data);
assert(&wrap->handle_ == (uv_pipe_t*)handle); assert(&wrap->handle_ == reinterpret_cast<uv_pipe_t*>(handle));
// We should not be getting this callback if someone as already called // We should not be getting this callback if someone as already called
// uv_close() on the handle. // uv_close() on the handle.
@ -215,8 +217,9 @@ void PipeWrap::OnConnection(uv_stream_t* handle, int status) {
assert(client_obj->InternalFieldCount() > 0); assert(client_obj->InternalFieldCount() > 0);
PipeWrap* client_wrap = PipeWrap* client_wrap =
static_cast<PipeWrap*>(client_obj->GetAlignedPointerFromInternalField(0)); static_cast<PipeWrap*>(client_obj->GetAlignedPointerFromInternalField(0));
uv_stream_t* client_handle =
if (uv_accept(handle, (uv_stream_t*)&client_wrap->handle_)) return; reinterpret_cast<uv_stream_t*>(&client_wrap->handle_);
if (uv_accept(handle, client_handle)) return;
// Successful accept. Call the onconnection callback in JavaScript land. // Successful accept. Call the onconnection callback in JavaScript land.
Local<Value> argv[1] = { client_obj }; Local<Value> argv[1] = { client_obj };

2
src/process_wrap.cc

@ -248,7 +248,7 @@ class ProcessWrap : public HandleWrap {
SetErrno(uv_last_error(uv_default_loop())); SetErrno(uv_last_error(uv_default_loop()));
} }
else { else {
wrap->SetHandle((uv_handle_t*)&wrap->process_); wrap->SetHandle(reinterpret_cast<uv_handle_t*>(&wrap->process_));
assert(wrap->process_.data == wrap); assert(wrap->process_.data == wrap);
wrap->object_->Set(String::New("pid"), wrap->object_->Set(String::New("pid"),
Integer::New(wrap->process_.pid, node_isolate)); Integer::New(wrap->process_.pid, node_isolate));

6
src/stream_wrap.cc

@ -110,7 +110,7 @@ void StreamWrap::Initialize(Handle<Object> target) {
StreamWrap::StreamWrap(Handle<Object> object, uv_stream_t* stream) StreamWrap::StreamWrap(Handle<Object> object, uv_stream_t* stream)
: HandleWrap(object, (uv_handle_t*)stream) { : HandleWrap(object, reinterpret_cast<uv_handle_t*>(stream)) {
stream_ = stream; stream_ = stream;
if (stream) { if (stream) {
stream->data = this; stream->data = this;
@ -151,7 +151,7 @@ Handle<Value> StreamWrap::ReadStart(const Arguments& args) {
UNWRAP(StreamWrap) UNWRAP(StreamWrap)
bool ipc_pipe = wrap->stream_->type == UV_NAMED_PIPE && bool ipc_pipe = wrap->stream_->type == UV_NAMED_PIPE &&
((uv_pipe_t*)wrap->stream_)->ipc; reinterpret_cast<uv_pipe_t*>(wrap->stream_)->ipc;
int r; int r;
if (ipc_pipe) { if (ipc_pipe) {
r = uv_read2_start(wrap->stream_, OnAlloc, OnRead2); r = uv_read2_start(wrap->stream_, OnAlloc, OnRead2);
@ -385,7 +385,7 @@ Handle<Value> StreamWrap::WriteStringImpl(const Arguments& args) {
buf.len = data_size; buf.len = data_size;
bool ipc_pipe = wrap->stream_->type == UV_NAMED_PIPE && bool ipc_pipe = wrap->stream_->type == UV_NAMED_PIPE &&
((uv_pipe_t*)wrap->stream_)->ipc; reinterpret_cast<uv_pipe_t*>(wrap->stream_)->ipc;
if (!ipc_pipe) { if (!ipc_pipe) {
r = uv_write(&req_wrap->req_, r = uv_write(&req_wrap->req_,

16
src/tcp_wrap.cc

@ -156,7 +156,7 @@ Handle<Value> TCPWrap::New(const Arguments& args) {
TCPWrap::TCPWrap(Handle<Object> object) TCPWrap::TCPWrap(Handle<Object> object)
: StreamWrap(object, (uv_stream_t*) &handle_) { : StreamWrap(object, reinterpret_cast<uv_stream_t*>(&handle_)) {
int r = uv_tcp_init(uv_default_loop(), &handle_); int r = uv_tcp_init(uv_default_loop(), &handle_);
assert(r == 0); // How do we proxy this error up to javascript? assert(r == 0); // How do we proxy this error up to javascript?
// Suggestion: uv_tcp_init() returns void. // Suggestion: uv_tcp_init() returns void.
@ -310,7 +310,9 @@ Handle<Value> TCPWrap::Listen(const Arguments& args) {
int backlog = args[0]->Int32Value(); int backlog = args[0]->Int32Value();
int r = uv_listen((uv_stream_t*)&wrap->handle_, backlog, OnConnection); int r = uv_listen(reinterpret_cast<uv_stream_t*>(&wrap->handle_),
backlog,
OnConnection);
// Error starting the tcp. // Error starting the tcp.
if (r) SetErrno(uv_last_error(uv_default_loop())); 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); HandleScope scope(node_isolate);
TCPWrap* wrap = static_cast<TCPWrap*>(handle->data); TCPWrap* wrap = static_cast<TCPWrap*>(handle->data);
assert(&wrap->handle_ == (uv_tcp_t*)handle); assert(&wrap->handle_ == reinterpret_cast<uv_tcp_t*>(handle));
// We should not be getting this callback if someone as already called // We should not be getting this callback if someone as already called
// uv_close() on the handle. // uv_close() on the handle.
@ -337,10 +339,12 @@ void TCPWrap::OnConnection(uv_stream_t* handle, int status) {
// Unwrap the client javascript object. // Unwrap the client javascript object.
assert(client_obj->InternalFieldCount() > 0); assert(client_obj->InternalFieldCount() > 0);
TCPWrap* client_wrap = static_cast<TCPWrap*>(
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<TCPWrap*>(client_wrap_v);
uv_stream_t* client_handle =
reinterpret_cast<uv_stream_t*>(&client_wrap->handle_);
if (uv_accept(handle, client_handle)) return;
// Successful accept. Call the onconnection callback in JavaScript land. // Successful accept. Call the onconnection callback in JavaScript land.
argv[0] = client_obj; argv[0] = client_obj;

2
src/timer_wrap.cc

@ -83,7 +83,7 @@ class TimerWrap : public HandleWrap {
} }
TimerWrap(Handle<Object> object) TimerWrap(Handle<Object> object)
: HandleWrap(object, (uv_handle_t*) &handle_) { : HandleWrap(object, reinterpret_cast<uv_handle_t*>(&handle_)) {
int r = uv_timer_init(uv_default_loop(), &handle_); int r = uv_timer_init(uv_default_loop(), &handle_);
assert(r == 0); assert(r == 0);
handle_.data = this; handle_.data = this;

2
src/tty_wrap.cc

@ -199,7 +199,7 @@ Handle<Value> TTYWrap::New(const Arguments& args) {
TTYWrap::TTYWrap(Handle<Object> object, int fd, bool readable) TTYWrap::TTYWrap(Handle<Object> object, int fd, bool readable)
: StreamWrap(object, (uv_stream_t*)&handle_) { : StreamWrap(object, reinterpret_cast<uv_stream_t*>(&handle_)) {
uv_tty_init(uv_default_loop(), &handle_, fd, readable); uv_tty_init(uv_default_loop(), &handle_, fd, readable);
} }

4
src/udp_wrap.cc

@ -65,8 +65,8 @@ static void DeleteSlabAllocator(void*) {
} }
UDPWrap::UDPWrap(Handle<Object> object): HandleWrap(object, UDPWrap::UDPWrap(Handle<Object> object)
(uv_handle_t*)&handle_) { : HandleWrap(object, reinterpret_cast<uv_handle_t*>(&handle_)) {
int r = uv_udp_init(uv_default_loop(), &handle_); int r = uv_udp_init(uv_default_loop(), &handle_);
assert(r == 0); // can't fail anyway assert(r == 0); // can't fail anyway
handle_.data = reinterpret_cast<void*>(this); handle_.data = reinterpret_cast<void*>(this);

Loading…
Cancel
Save