mirror of
https://github.com/nodejs/node.git
synced 2026-11-29 14:27:57 -05:00
src: remove void* -> char* -> void* casts
When passing the return value of `BackingStore::Data()` as the first or second argument to `memcpy()`, it is unnecessary to cast the returned pointer to `char*`. Refs: https://github.com/nodejs/node/pull/52292 PR-URL: https://github.com/nodejs/node/pull/57791 Reviewed-By: Michaël Zasso <targos@protonmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Darshan Sen <raisinten@gmail.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com> Reviewed-By: Gerhard Stöbich <deb2001-github@yahoo.de> Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
This commit is contained in:
1 parent
f2cdc98e75
commit
d50b8a8815
6 files changed
+9
-25
No files matched your search
@@ -716,9 +716,7 @@ CipherBase::UpdateResult CipherBase::Update(
|
||||
} else if (static_cast<size_t>(buf_len) != (*out)->ByteLength()) {
|
||||
std::unique_ptr<BackingStore> old_out = std::move(*out);
|
||||
*out = ArrayBuffer::NewBackingStore(env()->isolate(), buf_len);
|
||||
memcpy(static_cast<char*>((*out)->Data()),
|
||||
static_cast<char*>(old_out->Data()),
|
||||
buf_len);
|
||||
memcpy((*out)->Data(), old_out->Data(), buf_len);
|
||||
}
|
||||
|
||||
// When in CCM mode, EVP_CipherUpdate will fail if the authentication tag is
|
||||
@@ -814,9 +812,7 @@ bool CipherBase::Final(std::unique_ptr<BackingStore>* out) {
|
||||
} else if (static_cast<size_t>(out_len) != (*out)->ByteLength()) {
|
||||
std::unique_ptr<BackingStore> old_out = std::move(*out);
|
||||
*out = ArrayBuffer::NewBackingStore(env()->isolate(), out_len);
|
||||
memcpy(static_cast<char*>((*out)->Data()),
|
||||
static_cast<char*>(old_out->Data()),
|
||||
out_len);
|
||||
memcpy((*out)->Data(), old_out->Data(), out_len);
|
||||
}
|
||||
|
||||
if (ok && kind_ == kCipher && IsAuthenticatedMode()) {
|
||||
@@ -892,9 +888,7 @@ bool PublicKeyCipher::Cipher(
|
||||
*out = ArrayBuffer::NewBackingStore(env->isolate(), 0);
|
||||
} else {
|
||||
*out = ArrayBuffer::NewBackingStore(env->isolate(), buf.size());
|
||||
memcpy(static_cast<char*>((*out)->Data()),
|
||||
static_cast<char*>(buf.get()),
|
||||
buf.size());
|
||||
memcpy((*out)->Data(), buf.get(), buf.size());
|
||||
}
|
||||
|
||||
return true;
|
||||
|
||||
@@ -101,9 +101,7 @@ std::unique_ptr<BackingStore> Node_SignFinal(Environment* env,
|
||||
if (sig_buf.len < sig->ByteLength()) {
|
||||
auto new_sig = ArrayBuffer::NewBackingStore(env->isolate(), sig_buf.len);
|
||||
if (sig_buf.len > 0) [[likely]] {
|
||||
memcpy(static_cast<char*>(new_sig->Data()),
|
||||
static_cast<char*>(sig->Data()),
|
||||
sig_buf.len);
|
||||
memcpy(new_sig->Data(), sig->Data(), sig_buf.len);
|
||||
}
|
||||
sig = std::move(new_sig);
|
||||
}
|
||||
|
||||
+1
-3
@@ -329,9 +329,7 @@ MaybeLocal<Object> New(Isolate* isolate,
|
||||
if (actual < length) {
|
||||
std::unique_ptr<BackingStore> old_store = std::move(store);
|
||||
store = ArrayBuffer::NewBackingStore(isolate, actual);
|
||||
memcpy(static_cast<char*>(store->Data()),
|
||||
static_cast<char*>(old_store->Data()),
|
||||
actual);
|
||||
memcpy(store->Data(), old_store->Data(), actual);
|
||||
}
|
||||
Local<ArrayBuffer> buf = ArrayBuffer::New(isolate, std::move(store));
|
||||
Local<Object> obj;
|
||||
|
||||
+1
-3
@@ -2084,9 +2084,7 @@ void Http2Session::OnStreamRead(ssize_t nread, const uv_buf_t& buf_) {
|
||||
// Shrink to the actual amount of used data.
|
||||
std::unique_ptr<BackingStore> old_bs = std::move(bs);
|
||||
bs = ArrayBuffer::NewBackingStore(env()->isolate(), nread);
|
||||
memcpy(static_cast<char*>(bs->Data()),
|
||||
static_cast<char*>(old_bs->Data()),
|
||||
nread);
|
||||
memcpy(bs->Data(), old_bs->Data(), nread);
|
||||
} else {
|
||||
// This is a very unlikely case, and should only happen if the ReadStart()
|
||||
// call in OnStreamAfterWrite() immediately provides data. If that does
|
||||
|
||||
+2
-4
@@ -401,7 +401,7 @@ int StreamBase::WriteString(const FunctionCallbackInfo<Value>& args) {
|
||||
// Copy partial data
|
||||
bs = ArrayBuffer::NewBackingStore(
|
||||
isolate, buf.len, BackingStoreInitializationMode::kUninitialized);
|
||||
memcpy(static_cast<char*>(bs->Data()), buf.base, buf.len);
|
||||
memcpy(bs->Data(), buf.base, buf.len);
|
||||
data_size = buf.len;
|
||||
} else {
|
||||
// Write it
|
||||
@@ -709,9 +709,7 @@ void EmitToJSStreamListener::OnStreamRead(ssize_t nread, const uv_buf_t& buf_) {
|
||||
if (static_cast<size_t>(nread) != bs->ByteLength()) {
|
||||
std::unique_ptr<BackingStore> old_bs = std::move(bs);
|
||||
bs = ArrayBuffer::NewBackingStore(isolate, nread);
|
||||
memcpy(static_cast<char*>(bs->Data()),
|
||||
static_cast<char*>(old_bs->Data()),
|
||||
nread);
|
||||
memcpy(bs->Data(), old_bs->Data(), nread);
|
||||
}
|
||||
|
||||
stream->CallJSOnreadMethod(nread, ArrayBuffer::New(isolate, std::move(bs)));
|
||||
|
||||
+1
-3
@@ -760,9 +760,7 @@ void UDPWrap::OnRecv(ssize_t nread,
|
||||
CHECK_LE(static_cast<size_t>(nread), bs->ByteLength());
|
||||
std::unique_ptr<BackingStore> old_bs = std::move(bs);
|
||||
bs = ArrayBuffer::NewBackingStore(isolate, nread);
|
||||
memcpy(static_cast<char*>(bs->Data()),
|
||||
static_cast<char*>(old_bs->Data()),
|
||||
nread);
|
||||
memcpy(bs->Data(), old_bs->Data(), nread);
|
||||
}
|
||||
|
||||
Local<Object> address;
|
||||
|
||||
Reference in new issue
Block a user