Re: [PATCH 01/11] Remove useless code in error path of getnameinfo()

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



 On 10/21/2010 02:17 PM, Daniel P. Berrange wrote:
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            |   20 +++-----------------
  src/remote/remote_driver.c |   20 +++-----------------
  2 files changed, 6 insertions(+), 34 deletions(-)

diff --git a/daemon/remote.c b/daemon/remote.c
index 75df9b5..ae7a2d3 100644
--- a/daemon/remote.c
+++ b/daemon/remote.c
@@ -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;
      }

diff --git a/src/remote/remote_driver.c b/src/remote/remote_driver.c
index 37c37ef..38e2d55 100644
--- a/src/remote/remote_driver.c
+++ b/src/remote/remote_driver.c
@@ -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;
      }


Aren't you removing these functions in PATCH 8/11 anyway?

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list


[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]