From ff211e935d1ff16980800886b99eae7fd840bdd7 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. --- 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 8a43ae91f81e4f..110508b4fae9c2 100644 --- a/src/udp_wrap.cc +++ b/src/udp_wrap.cc @@ -233,9 +233,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 @@ -243,6 +242,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);