mirror of
https://github.com/nodejs/node-v0.x-archive.git
synced 2026-04-28 03:01:10 -04:00
src: use static_cast where appropriate
Use static_cast instead of reinterpret_cast when casting from void* to another type. This is mostly an aesthetic change but may help catch bugs when the affected code is modified.
This commit is contained in:
@@ -311,7 +311,7 @@ class QueryWrap {
|
||||
|
||||
static void Callback(void *arg, int status, int timeouts,
|
||||
unsigned char* answer_buf, int answer_len) {
|
||||
QueryWrap* wrap = reinterpret_cast<QueryWrap*>(arg);
|
||||
QueryWrap* wrap = static_cast<QueryWrap*>(arg);
|
||||
|
||||
if (status != ARES_SUCCESS) {
|
||||
wrap->ParseError(status);
|
||||
@@ -324,7 +324,7 @@ class QueryWrap {
|
||||
|
||||
static void Callback(void *arg, int status, int timeouts,
|
||||
struct hostent* host) {
|
||||
QueryWrap* wrap = reinterpret_cast<QueryWrap*>(arg);
|
||||
QueryWrap* wrap = static_cast<QueryWrap*>(arg);
|
||||
|
||||
if (status != ARES_SUCCESS) {
|
||||
wrap->ParseError(status);
|
||||
|
||||
@@ -51,7 +51,7 @@ private:
|
||||
|
||||
FSEventWrap::FSEventWrap(Handle<Object> object): HandleWrap(object,
|
||||
(uv_handle_t*)&handle_) {
|
||||
handle_.data = reinterpret_cast<void*>(this);
|
||||
handle_.data = static_cast<void*>(this);
|
||||
initialized_ = false;
|
||||
}
|
||||
|
||||
@@ -119,7 +119,7 @@ void FSEventWrap::OnEvent(uv_fs_event_t* handle, const char* filename,
|
||||
HandleScope scope;
|
||||
Local<String> eventStr;
|
||||
|
||||
FSEventWrap* wrap = reinterpret_cast<FSEventWrap*>(handle->data);
|
||||
FSEventWrap* wrap = static_cast<FSEventWrap*>(handle->data);
|
||||
|
||||
assert(wrap->object_.IsEmpty() == false);
|
||||
|
||||
|
||||
@@ -75,7 +75,7 @@ class NODE_EXTERN Buffer: public ObjectWrap {
|
||||
static inline char* Data(v8::Handle<v8::Value> val) {
|
||||
assert(val->IsObject());
|
||||
void* data = val.As<v8::Object>()->GetIndexedPropertiesExternalArrayData();
|
||||
return reinterpret_cast<char*>(data);
|
||||
return static_cast<char*>(data);
|
||||
}
|
||||
|
||||
static inline char* Data(Buffer *b) {
|
||||
|
||||
@@ -129,7 +129,7 @@ PipeWrap::PipeWrap(Handle<Object> object, bool ipc)
|
||||
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.
|
||||
handle_.data = reinterpret_cast<void*>(this);
|
||||
handle_.data = static_cast<void*>(this);
|
||||
UpdateWriteQueueSize();
|
||||
}
|
||||
|
||||
|
||||
@@ -255,7 +255,7 @@ class TypedArray {
|
||||
}
|
||||
|
||||
void* buf = buffer->GetIndexedPropertiesExternalArrayData();
|
||||
char* begin = reinterpret_cast<char*>(buf) + byte_offset;
|
||||
char* begin = static_cast<char*>(buf) + byte_offset;
|
||||
|
||||
if (!checkAlignment(reinterpret_cast<uintptr_t>(begin), TBytes))
|
||||
return ThrowRangeError("Byte offset is not aligned.");
|
||||
@@ -374,7 +374,7 @@ class TypedArray {
|
||||
// place as if all the data is first copied into a temporary buffer that
|
||||
// does not overlap either of the arrays, and then the data from the
|
||||
// temporary buffer is copied into the current array.
|
||||
memmove(reinterpret_cast<char*>(dst_ptr) + offset * TBytes, src_ptr,
|
||||
memmove(static_cast<char*>(dst_ptr) + offset * TBytes, src_ptr,
|
||||
src_length * TBytes);
|
||||
} else { // type[]
|
||||
if (args[1]->Int32Value() < 0)
|
||||
@@ -643,7 +643,7 @@ class DataView {
|
||||
|
||||
// Like ArrayBuffer, we violate the spec and add an operator[].
|
||||
args.This()->SetIndexedPropertiesToExternalArrayData(
|
||||
reinterpret_cast<char*>(buf) + byte_offset,
|
||||
static_cast<char*>(buf) + byte_offset,
|
||||
v8::kExternalUnsignedByteArray, byte_length);
|
||||
|
||||
args.This()->Set(v8::String::New("buffer"),
|
||||
@@ -670,7 +670,7 @@ class DataView {
|
||||
template <typename T>
|
||||
static T getValue(void* ptr, unsigned int index, bool swiz) {
|
||||
char buf[sizeof(T)];
|
||||
memcpy(buf, reinterpret_cast<char*>(ptr) + index, sizeof(T));
|
||||
memcpy(buf, static_cast<char*>(ptr) + index, sizeof(T));
|
||||
if (swiz)
|
||||
swizzle(buf, sizeof(T));
|
||||
T val;
|
||||
@@ -684,7 +684,7 @@ class DataView {
|
||||
memcpy(buf, &val, sizeof(T));
|
||||
if (swiz)
|
||||
swizzle(buf, sizeof(T));
|
||||
memcpy(reinterpret_cast<char*>(ptr) + index, buf, sizeof(T));
|
||||
memcpy(static_cast<char*>(ptr) + index, buf, sizeof(T));
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
|
||||
Reference in New Issue
Block a user