Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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.
  • Loading branch information
danbev committed Sep 17, 2017
commit ff211e935d1ff16980800886b99eae7fd840bdd7
4 changes: 2 additions & 2 deletions src/udp_wrap.cc
Original file line number Diff line number Diff line change
Expand Up @@ -233,16 +233,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