]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
Remove useless code in error path of getnameinfo()
authorDaniel P. Berrange <berrange@redhat.com>
Wed, 20 Oct 2010 12:53:27 +0000 (13:53 +0100)
committerDaniel P. Berrange <berrange@redhat.com>
Fri, 22 Oct 2010 10:15:14 +0000 (11:15 +0100)
If getnameinfo() with NI_NUMERICHOST set fails, there are no
grounds to expect inet_ntop to succeed, since these calls
are functionally equivalent. Remove useless inet_ntop code
in the getnameinfo() error path.

* daemon/remote.c, src/remote/remote_driver.c: Remove
  calls to inet_ntop

daemon/remote.c
src/remote/remote_driver.c

index 75df9b5a93c341a2e2672b76d2e9cdd1f3e27631..ae7a2d35fd2aef602aa9333a3cbf4a6b8654472b 100644 (file)
@@ -3653,23 +3653,9 @@ static char *addrToString(remote_error *rerr,
                            host, sizeof(host),
                            port, sizeof(port),
                            NI_NUMERICHOST | NI_NUMERICSERV)) != 0) {
-        char ip[INET6_ADDRSTRLEN];
-        void *rawaddr;
-
-        if (sa->sa_family == AF_INET)
-            rawaddr = &((struct sockaddr_in *)sa)->sin_addr;
-        else
-            rawaddr = &((struct sockaddr_in6 *)sa)->sin6_addr;
-
-        if (inet_ntop(sa->sa_family, rawaddr, ip, sizeof ip)) {
-            remoteDispatchFormatError(rerr,
-                                      _("Cannot resolve address %s: %s"),
-                                      ip, gai_strerror(err));
-        } else {
-            remoteDispatchFormatError(rerr,
-                                      _("Cannot resolve address: %s"),
-                                      gai_strerror(err));
-        }
+        remoteDispatchFormatError(rerr,
+                                  _("Cannot convert socket address to string: %s"),
+                                  gai_strerror(err));
         return NULL;
     }
 
index 37c37ef50ccea67e3698b6a9387458ad94823744..38e2d5557b84701823a4437ee88c61a2fc1107c6 100644 (file)
@@ -6910,23 +6910,9 @@ static char *addrToString(struct sockaddr_storage *ss, socklen_t salen)
                            host, sizeof(host),
                            port, sizeof(port),
                            NI_NUMERICHOST | NI_NUMERICSERV)) != 0) {
-        char ip[INET6_ADDRSTRLEN];
-        void *rawaddr;
-
-        if (sa->sa_family == AF_INET)
-            rawaddr = &((struct sockaddr_in *)sa)->sin_addr;
-        else
-            rawaddr = &((struct sockaddr_in6 *)sa)->sin6_addr;
-
-        if (inet_ntop(sa->sa_family, rawaddr, ip, sizeof ip)) {
-            remoteError(VIR_ERR_UNKNOWN_HOST,
-                        _("Cannot resolve address %s: %s"),
-                        ip, gai_strerror(err));
-        } else {
-            remoteError(VIR_ERR_UNKNOWN_HOST,
-                        _("Cannot resolve address: %s"),
-                        gai_strerror(err));
-        }
+        remoteError(VIR_ERR_UNKNOWN_HOST,
+                    _("Cannot convert socket address to string: %s"),
+                    gai_strerror(err));
         return NULL;
     }