From 587c905d11a437954990bb857731c250d1fbaad3 Mon Sep 17 00:00:00 2001 From: Eugene Ostroukhov Date: Thu, 22 Jun 2017 10:43:03 -0700 Subject: [PATCH] test: check uv_ip4_addr return value Fixes Coverity errors. PR-URL: https://github.com/nodejs/node/pull/13878 Reviewed-By: Colin Ihrig Reviewed-By: Ben Noordhuis --- test/cctest/test_inspector_socket.cc | 2 +- test/cctest/test_inspector_socket_server.cc | 9 +++++---- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/test/cctest/test_inspector_socket.cc b/test/cctest/test_inspector_socket.cc index 181ab6e017a32d..741c7b189c2f38 100644 --- a/test/cctest/test_inspector_socket.cc +++ b/test/cctest/test_inspector_socket.cc @@ -370,7 +370,7 @@ class InspectorSocketTest : public ::testing::Test { sockaddr_in addr; uv_tcp_init(&loop, &server); uv_tcp_init(&loop, &client_socket); - uv_ip4_addr("127.0.0.1", PORT, &addr); + GTEST_ASSERT_EQ(0, uv_ip4_addr("127.0.0.1", PORT, &addr)); uv_tcp_bind(&server, reinterpret_cast(&addr), 0); GTEST_ASSERT_EQ(0, uv_listen(reinterpret_cast(&server), 1, on_new_connection)); diff --git a/test/cctest/test_inspector_socket_server.cc b/test/cctest/test_inspector_socket_server.cc index a8c3bcd2f7f5d5..61cf2867291b0a 100644 --- a/test/cctest/test_inspector_socket_server.cc +++ b/test/cctest/test_inspector_socket_server.cc @@ -194,10 +194,11 @@ class SocketWrapper { contents_.clear(); uv_tcp_init(loop_, &socket_); sockaddr_in addr; - uv_ip4_addr(host.c_str(), port, &addr); - int err = uv_tcp_connect(&connect_, &socket_, - reinterpret_cast(&addr), - ConnectionMustFail_); + int err = uv_ip4_addr(host.c_str(), port, &addr); + ASSERT_EQ(0, err); + err = uv_tcp_connect(&connect_, &socket_, + reinterpret_cast(&addr), + ConnectionMustFail_); ASSERT_EQ(0, err); SPIN_WHILE(!connection_failed_) uv_read_start(reinterpret_cast(&socket_), AllocCallback,