clang-tidy nullptr

This commit is contained in:
Erik Frojdh 2019-05-14 17:11:27 +02:00
parent 74d67261a9
commit 55f482f915
3 changed files with 6 additions and 6 deletions

View File

@ -20,7 +20,7 @@ ClientSocket::ClientSocket(std::string stype, const std::string &host,
hints.ai_socktype = SOCK_STREAM; hints.ai_socktype = SOCK_STREAM;
hints.ai_flags |= AI_CANONNAME; 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 + std::string msg = "ClientSocket cannot decode host:" + host +
" on port " + std::to_string(port) + "\n"; " on port " + std::to_string(port) + "\n";
throw SocketError(msg); throw SocketError(msg);

View File

@ -108,7 +108,7 @@ ConvertHostnameToInternetAddress(const std::string &hostname) {
hints.ai_flags |= AI_CANONNAME; hints.ai_flags |= AI_CANONNAME;
struct sockaddr_in serverAddr {}; struct sockaddr_in serverAddr {};
if (getaddrinfo(hostname.c_str(), NULL, &hints, &result) != 0) { if (getaddrinfo(hostname.c_str(), nullptr, &hints, &result) != 0) {
freeaddrinfo(result); freeaddrinfo(result);
std::string msg = "ClientSocket cannot decode host:" + hostname + "\n"; std::string msg = "ClientSocket cannot decode host:" + hostname + "\n";
throw SocketError(msg); throw SocketError(msg);
@ -129,13 +129,13 @@ int ConvertHostnameToInternetAddress(const char *const hostname,
hints.ai_family = AF_INET; hints.ai_family = AF_INET;
hints.ai_socktype = SOCK_STREAM; hints.ai_socktype = SOCK_STREAM;
// get host info into res // get host info into res
int errcode = getaddrinfo(hostname, NULL, &hints, res); int errcode = getaddrinfo(hostname, nullptr, &hints, res);
if (errcode != 0) { if (errcode != 0) {
FILE_LOG(logERROR) << "Could not convert hostname (" << hostname FILE_LOG(logERROR) << "Could not convert hostname (" << hostname
<< ") to internet address (zmq):" << ") to internet address (zmq):"
<< gai_strerror(errcode); << gai_strerror(errcode);
} else { } else {
if (*res == NULL) { if (*res == nullptr) {
FILE_LOG(logERROR) << "Could not converthostname (" << hostname FILE_LOG(logERROR) << "Could not converthostname (" << hostname
<< ") to internet address (zmq):" << ") to internet address (zmq):"
"gettaddrinfo returned null"; "gettaddrinfo returned null";
@ -160,7 +160,7 @@ int ConvertInternetAddresstoIpString(struct ::addrinfo *res, char *ip,
const int ipsize) { const int ipsize) {
if (inet_ntop(res->ai_family, if (inet_ntop(res->ai_family,
&((struct sockaddr_in *)res->ai_addr)->sin_addr, ip, &((struct sockaddr_in *)res->ai_addr)->sin_addr, ip,
ipsize) != NULL) { ipsize) != nullptr) {
::freeaddrinfo(res); ::freeaddrinfo(res);
return 0; return 0;
} }

View File

@ -83,7 +83,7 @@ uint32_t HostnameToIp(const char *hostname) {
memset(&hints, 0, sizeof(hints)); memset(&hints, 0, sizeof(hints));
hints.ai_family = AF_INET; hints.ai_family = AF_INET;
hints.ai_socktype = SOCK_STREAM; hints.ai_socktype = SOCK_STREAM;
if (getaddrinfo(hostname, NULL, &hints, &result)) { if (getaddrinfo(hostname, nullptr, &hints, &result)) {
freeaddrinfo(result); freeaddrinfo(result);
throw RuntimeError("Could not convert hostname to ip"); throw RuntimeError("Could not convert hostname to ip");
} }