Skip to content

Commit

Permalink
src: fix compiler warning in udp_wrap.cc
Browse files Browse the repository at this point in the history
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: #15402
Reviewed-By: Franziska Hinkelmann <[email protected]>
  • Loading branch information
danbev authored and MylesBorins committed Oct 11, 2017
1 parent e365814 commit 6551bb3
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/udp_wrap.cc
Original file line number Diff line number Diff line change
Expand Up @@ -234,16 +234,16 @@ 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
return env->ThrowUVException(EINVAL, "uv_send_buffer_size");
}

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);
Expand Down

0 comments on commit 6551bb3

Please sign in to comment.