From 87bdddaf412678f1b109e20d03b899714a0bf64c Mon Sep 17 00:00:00 2001 From: Daniel Bevenius Date: Thu, 14 Sep 2017 08:36:37 +0200 Subject: [PATCH] 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()->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 --- src/udp_wrap.cc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/udp_wrap.cc b/src/udp_wrap.cc index 6a32ebd1c3..1f67296076 100644 --- a/src/udp_wrap.cc +++ b/src/udp_wrap.cc @@ -234,9 +234,8 @@ void UDPWrap::BufferSize(const FunctionCallbackInfo& args) { CHECK(args[0]->IsUint32()); CHECK(args[1]->IsUint32()); - int size = static_cast(args[0].As()->Value()); - if (size != args[0].As()->Value()) { + if (!args[0]->IsInt32()) { if (args[1].As()->Value() == 0) return env->ThrowUVException(EINVAL, "uv_recv_buffer_size"); else @@ -244,6 +243,7 @@ void UDPWrap::BufferSize(const FunctionCallbackInfo& args) { } int err; + int size = static_cast(args[0].As()->Value()); if (args[1].As()->Value() == 0) { err = uv_recv_buffer_size(reinterpret_cast(&wrap->handle_), &size);