src: fix compiler warning in udp_wrap.cc
Currently the following compiler warning is generated: 1 warning generated. ../src/udp_wrap.cc:238:12: warning: comparison of integers of different signs: 'int' and 'uint32_t' (aka 'unsigned int') [-Wsign-compare] if (size != args[0].As<Uint32>()->Value()) { ~~~~ ^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1 warning generated. This commit changes the check to see that the Uint32 value does not exceed the max int size instead of first casting and then comparing. PR-URL: https://github.com/nodejs/node/pull/15402 Reviewed-By: Franziska Hinkelmann <franziska.hinkelmann@gmail.com>
This commit is contained in:
parent
602fd36d95
commit
87bdddaf41
@ -234,9 +234,8 @@ void UDPWrap::BufferSize(const FunctionCallbackInfo<Value>& args) {
|
||||
|
||||
CHECK(args[0]->IsUint32());
|
||||
CHECK(args[1]->IsUint32());
|
||||
int size = static_cast<int>(args[0].As<Uint32>()->Value());
|
||||
|
||||
if (size != args[0].As<Uint32>()->Value()) {
|
||||
if (!args[0]->IsInt32()) {
|
||||
if (args[1].As<Uint32>()->Value() == 0)
|
||||
return env->ThrowUVException(EINVAL, "uv_recv_buffer_size");
|
||||
else
|
||||
@ -244,6 +243,7 @@ void UDPWrap::BufferSize(const FunctionCallbackInfo<Value>& args) {
|
||||
}
|
||||
|
||||
int err;
|
||||
int size = static_cast<int>(args[0].As<Uint32>()->Value());
|
||||
if (args[1].As<Uint32>()->Value() == 0) {
|
||||
err = uv_recv_buffer_size(reinterpret_cast<uv_handle_t*>(&wrap->handle_),
|
||||
&size);
|
||||
|
Loading…
x
Reference in New Issue
Block a user