From 55f482f915021b0f51abcc3705937bc8bfe064cd Mon Sep 17 00:00:00 2001 From: Erik Frojdh Date: Tue, 14 May 2019 17:11:27 +0200 Subject: [PATCH] clang-tidy nullptr --- slsSupportLib/src/ClientSocket.cpp | 2 +- slsSupportLib/src/DataSocket.cpp | 8 ++++---- slsSupportLib/src/network_utils.cpp | 2 +- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/slsSupportLib/src/ClientSocket.cpp b/slsSupportLib/src/ClientSocket.cpp index ab8978390..793ca1019 100755 --- a/slsSupportLib/src/ClientSocket.cpp +++ b/slsSupportLib/src/ClientSocket.cpp @@ -20,7 +20,7 @@ ClientSocket::ClientSocket(std::string stype, const std::string &host, hints.ai_socktype = SOCK_STREAM; hints.ai_flags |= AI_CANONNAME; - if (getaddrinfo(host.c_str(), NULL, &hints, &result) != 0) { + if (getaddrinfo(host.c_str(), nullptr, &hints, &result) != 0) { std::string msg = "ClientSocket cannot decode host:" + host + " on port " + std::to_string(port) + "\n"; throw SocketError(msg); diff --git a/slsSupportLib/src/DataSocket.cpp b/slsSupportLib/src/DataSocket.cpp index 83f223f82..1af3db89f 100755 --- a/slsSupportLib/src/DataSocket.cpp +++ b/slsSupportLib/src/DataSocket.cpp @@ -108,7 +108,7 @@ ConvertHostnameToInternetAddress(const std::string &hostname) { hints.ai_flags |= AI_CANONNAME; struct sockaddr_in serverAddr {}; - if (getaddrinfo(hostname.c_str(), NULL, &hints, &result) != 0) { + if (getaddrinfo(hostname.c_str(), nullptr, &hints, &result) != 0) { freeaddrinfo(result); std::string msg = "ClientSocket cannot decode host:" + hostname + "\n"; throw SocketError(msg); @@ -129,13 +129,13 @@ int ConvertHostnameToInternetAddress(const char *const hostname, hints.ai_family = AF_INET; hints.ai_socktype = SOCK_STREAM; // get host info into res - int errcode = getaddrinfo(hostname, NULL, &hints, res); + int errcode = getaddrinfo(hostname, nullptr, &hints, res); if (errcode != 0) { FILE_LOG(logERROR) << "Could not convert hostname (" << hostname << ") to internet address (zmq):" << gai_strerror(errcode); } else { - if (*res == NULL) { + if (*res == nullptr) { FILE_LOG(logERROR) << "Could not converthostname (" << hostname << ") to internet address (zmq):" "gettaddrinfo returned null"; @@ -160,7 +160,7 @@ int ConvertInternetAddresstoIpString(struct ::addrinfo *res, char *ip, const int ipsize) { if (inet_ntop(res->ai_family, &((struct sockaddr_in *)res->ai_addr)->sin_addr, ip, - ipsize) != NULL) { + ipsize) != nullptr) { ::freeaddrinfo(res); return 0; } diff --git a/slsSupportLib/src/network_utils.cpp b/slsSupportLib/src/network_utils.cpp index d1b2afec7..a3dba74a8 100755 --- a/slsSupportLib/src/network_utils.cpp +++ b/slsSupportLib/src/network_utils.cpp @@ -83,7 +83,7 @@ uint32_t HostnameToIp(const char *hostname) { memset(&hints, 0, sizeof(hints)); hints.ai_family = AF_INET; hints.ai_socktype = SOCK_STREAM; - if (getaddrinfo(hostname, NULL, &hints, &result)) { + if (getaddrinfo(hostname, nullptr, &hints, &result)) { freeaddrinfo(result); throw RuntimeError("Could not convert hostname to ip"); }