Re: [libvirt PATCH 1/2] esx: call freeaddrinfo earlier in esxUtil_ResolveHostname

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

 



On 10/5/20 7:41 AM, Pino Toscano wrote:
Call freeaddrinfo() as soon as @result is not needed anymore, i.e. right
after getnameinfo(); this avoids calling freeaddrinfo() in two branches.

Signed-off-by: Pino Toscano <ptoscano@xxxxxxxxxx>


Reviewed-by: Laine Stump <laine@xxxxxxxxxx>

---
  src/esx/esx_util.c | 4 +---
  1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/src/esx/esx_util.c b/src/esx/esx_util.c
index 9100873326..555158f953 100644
--- a/src/esx/esx_util.c
+++ b/src/esx/esx_util.c
@@ -310,17 +310,15 @@ esxUtil_ResolveHostname(const char *hostname,
errcode = getnameinfo(result->ai_addr, result->ai_addrlen, ipAddress,
                            ipAddress_length, NULL, 0, NI_NUMERICHOST);
+    freeaddrinfo(result);
if (errcode != 0) {
          virReportError(VIR_ERR_INTERNAL_ERROR,
                         _("Formatting IP address for host '%s' failed: %s"), hostname,
                         gai_strerror(errcode));
-        freeaddrinfo(result);
          return -1;
      }
- freeaddrinfo(result);
-
      return 0;
  }





[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]

  Powered by Linux