]> git.ipfire.org Git - thirdparty/squid.git/blobdiff - src/ip/Address.cc
Maintenance: Removed most NULLs using modernize-use-nullptr (#1075)
[thirdparty/squid.git] / src / ip / Address.cc
index 10890306d0eabf7db834828b11755364b3587d1a..04f556ab5d1407962a7ca7a65973a667ea835e2e 100644 (file)
@@ -112,7 +112,7 @@ bool
 Ip::Address::applyMask(const unsigned int cidrMask, int mtype)
 {
     uint8_t clearbits = 0;
-    uint8_t* p = NULL;
+    uint8_t* p = nullptr;
 
     // validation and short-cuts.
     if (cidrMask > 128)
@@ -384,8 +384,8 @@ Ip::Address::lookupHostIP(const char *s, bool nodns)
     }
 
     int err = 0;
-    struct addrinfo *res = NULL;
-    if ( (err = getaddrinfo(s, NULL, &want, &res)) != 0) {
+    struct addrinfo *res = nullptr;
+    if ( (err = getaddrinfo(s, nullptr, &want, &res)) != 0) {
         debugs(14,3, "Given Non-IP '" << s << "': " << gai_strerror(err) );
         /* free the memory getaddrinfo() dynamically allocated. */
         if (res)
@@ -402,7 +402,7 @@ Ip::Address::lookupHostIP(const char *s, bool nodns)
                 break;
             maybeIpv4 = maybeIpv4->ai_next;
         }
-        if (maybeIpv4 != NULL)
+        if (maybeIpv4 != nullptr)
             res = maybeIpv4;
         // else IPv6-only host, let the caller deal with first-IP anyway.
     }
@@ -501,9 +501,9 @@ bool
 Ip::Address::operator =(const struct hostent &s)
 {
 
-    struct in_addr* ipv4 = NULL;
+    struct in_addr* ipv4 = nullptr;
 
-    struct in6_addr* ipv6 = NULL;
+    struct in6_addr* ipv6 = nullptr;
 
     //struct hostent {
     //        char    *h_name;        /* official name of host */
@@ -545,9 +545,9 @@ bool
 Ip::Address::operator =(const struct addrinfo &s)
 {
 
-    struct sockaddr_in* ipv4 = NULL;
+    struct sockaddr_in* ipv4 = nullptr;
 
-    struct sockaddr_in6* ipv6 = NULL;
+    struct sockaddr_in6* ipv6 = nullptr;
 
     //struct addrinfo {
     //             int ai_flags;           /* input flags */
@@ -580,7 +580,7 @@ Ip::Address::operator =(const struct addrinfo &s)
     default:
         // attempt to handle partially initialised addrinfo.
         // such as those where data only comes from getsockopt()
-        if (s.ai_addr != NULL) {
+        if (s.ai_addr != nullptr) {
             if (s.ai_addrlen == sizeof(struct sockaddr_in6)) {
                 operator=(*((struct sockaddr_in6*)s.ai_addr));
                 return true;
@@ -598,7 +598,7 @@ Ip::Address::operator =(const struct addrinfo &s)
 void
 Ip::Address::getAddrInfo(struct addrinfo *&dst, int force) const
 {
-    if (dst == NULL) {
+    if (dst == nullptr) {
         dst = new addrinfo;
     }
 
@@ -667,7 +667,7 @@ Ip::Address::getAddrInfo(struct addrinfo *&dst, int force) const
 void
 Ip::Address::InitAddr(struct addrinfo *&ai)
 {
-    if (ai == NULL) {
+    if (ai == nullptr) {
         ai = new addrinfo;
         memset(ai,0,sizeof(struct addrinfo));
     }
@@ -685,18 +685,18 @@ Ip::Address::InitAddr(struct addrinfo *&ai)
 void
 Ip::Address::FreeAddr(struct addrinfo *&ai)
 {
-    if (ai == NULL) return;
+    if (ai == nullptr) return;
 
     if (ai->ai_addr) delete ai->ai_addr;
 
-    ai->ai_addr = NULL;
+    ai->ai_addr = nullptr;
 
     ai->ai_addrlen = 0;
 
     // NP: name fields are NOT allocated at present.
     delete ai;
 
-    ai = NULL;
+    ai = nullptr;
 }
 
 int
@@ -792,8 +792,8 @@ char *
 Ip::Address::toStr(char* buf, const unsigned int blen, int force) const
 {
     // Ensure we have a buffer.
-    if (buf == NULL) {
-        return NULL;
+    if (buf == nullptr) {
+        return nullptr;
     }
 
     /* some external code may have blindly memset a parent. */
@@ -877,8 +877,8 @@ Ip::Address::toUrl(char* buf, unsigned int blen) const
 
     // Ensure we have a buffer.
 
-    if (buf == NULL) {
-        return NULL;
+    if (buf == nullptr) {
+        return nullptr;
     }
 
     p += toHostStr(p, blen);
@@ -923,7 +923,7 @@ Ip::Address::fromHost(const char *host)
 void
 Ip::Address::getSockAddr(struct sockaddr_storage &addr, const int family) const
 {
-    struct sockaddr_in *sin = NULL;
+    struct sockaddr_in *sin = nullptr;
 
     if ( family == AF_INET && !isIPv4()) {
         // TODO INET6: caller using the wrong socket type!