Browse Source

[1784] added some notes about why we do null check for 'res' from getaddrinfo.

JINMEI Tatuya 13 years ago
parent
commit
02cb1de4a0
1 changed files with 3 additions and 0 deletions
  1. 3 0
      src/lib/asiodns/tests/dns_service_unittest.cc

+ 3 - 0
src/lib/asiodns/tests/dns_service_unittest.cc

@@ -257,6 +257,9 @@ getSocketFD(int family, const char* const address, const char* const port) {
     int s = -1;
     int error = getaddrinfo(address, port, &hints, &res);
     if (error == 0) {
+        // If getaddrinfo returns 0, res should be set to a non NULL valid
+        // pointer, but some variants of cppcheck reportedly complains about
+        // it, so we satisfy them here.
         if (res != NULL) {
             s = socket(res->ai_family, res->ai_socktype, res->ai_protocol);
             if (s >= 0) {