Skip to content

Commit 6551bb3

Browse files
danbevMylesBorins
authored andcommitted
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: #15402 Reviewed-By: Franziska Hinkelmann <franziska.hinkelmann@gmail.com>
1 parent e365814 commit 6551bb3

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

src/udp_wrap.cc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -234,16 +234,16 @@ void UDPWrap::BufferSize(const FunctionCallbackInfo<Value>& args) {
234234

235235
CHECK(args[0]->IsUint32());
236236
CHECK(args[1]->IsUint32());
237-
int size = static_cast<int>(args[0].As<Uint32>()->Value());
238237

239-
if (size != args[0].As<Uint32>()->Value()) {
238+
if (!args[0]->IsInt32()) {
240239
if (args[1].As<Uint32>()->Value() == 0)
241240
return env->ThrowUVException(EINVAL, "uv_recv_buffer_size");
242241
else
243242
return env->ThrowUVException(EINVAL, "uv_send_buffer_size");
244243
}
245244

246245
int err;
246+
int size = static_cast<int>(args[0].As<Uint32>()->Value());
247247
if (args[1].As<Uint32>()->Value() == 0) {
248248
err = uv_recv_buffer_size(reinterpret_cast<uv_handle_t*>(&wrap->handle_),
249249
&size);

0 commit comments

Comments
 (0)