Skip to content

Commit

Permalink
src: assignment to valid type
Browse files Browse the repository at this point in the history
We are converting the argument to a uint32_t value
but the lvalue is not consistent with the casting.
  • Loading branch information
yashLadha committed Apr 25, 2020
1 parent 24a4e61 commit 9489beb
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/tcp_wrap.cc
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ void TCPWrap::SetKeepAlive(const FunctionCallbackInfo<Value>& args) {
Environment* env = wrap->env();
int enable;
if (!args[0]->Int32Value(env->context()).To(&enable)) return;
unsigned int delay = args[1].As<Uint32>()->Value();
unsigned int delay = static_cast<unsigned int>(args[1].As<Uint32>()->Value());
int err = uv_tcp_keepalive(&wrap->handle_, enable, delay);
args.GetReturnValue().Set(err);
}
Expand Down Expand Up @@ -278,7 +278,8 @@ void TCPWrap::Listen(const FunctionCallbackInfo<Value>& args) {

void TCPWrap::Connect(const FunctionCallbackInfo<Value>& args) {
CHECK(args[2]->IsUint32());
int port = args[2].As<Uint32>()->Value();
// explicit cast to fit to libuv's type expectation
int port = static_cast<int>(args[2].As<Uint32>()->Value());
Connect<sockaddr_in>(args,
[port](const char* ip_address, sockaddr_in* addr) {
return uv_ip4_addr(ip_address, port, addr);
Expand Down

0 comments on commit 9489beb

Please sign in to comment.