[PATCH 2/5] libvirt_nss: Use VIR_AUTOPTR and VIR_AUTOFREE

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

 



Signed-off-by: Michal Privoznik <mprivozn@xxxxxxxxxx>
---
 tools/nss/libvirt_nss.c | 12 ++++--------
 1 file changed, 4 insertions(+), 8 deletions(-)

diff --git a/tools/nss/libvirt_nss.c b/tools/nss/libvirt_nss.c
index 4de960d6f1..e55bf144bc 100644
--- a/tools/nss/libvirt_nss.c
+++ b/tools/nss/libvirt_nss.c
@@ -244,11 +244,11 @@ findLease(const char *name,
     int ret = -1;
     const char *leaseDir = LEASEDIR;
     struct dirent *entry;
-    virJSONValuePtr leases_array = NULL;
+    VIR_AUTOPTR(virJSONValue) leases_array = NULL;
     ssize_t nleases;
-    leaseAddress *tmpAddress = NULL;
+    VIR_AUTOFREE(leaseAddress *) tmpAddress = NULL;
     size_t ntmpAddress = 0;
-    virMacMapPtr *macmaps = NULL;
+    VIR_AUTOFREE(virMacMapPtr *) macmaps = NULL;
     size_t nMacmaps = 0;
 
     *address = NULL;
@@ -340,12 +340,9 @@ findLease(const char *name,
 
  cleanup:
     *errnop = errno;
-    VIR_FREE(tmpAddress);
-    virJSONValueFree(leases_array);
     VIR_DIR_CLOSE(dir);
     while (nMacmaps)
         virObjectUnref(macmaps[--nMacmaps]);
-    VIR_FREE(macmaps);
     return ret;
 }
 
@@ -389,7 +386,7 @@ NSS_NAME(gethostbyname3)(const char *name, int af, struct hostent *result,
 {
     enum nss_status ret = NSS_STATUS_UNAVAIL;
     char *r_name, **r_aliases, *r_addr, *r_addr_next, **r_addr_list;
-    leaseAddress *addr = NULL;
+    VIR_AUTOFREE(leaseAddress *) addr = NULL;
     size_t naddr, i;
     bool found = false;
     size_t nameLen, need, idx = 0;
@@ -495,7 +492,6 @@ NSS_NAME(gethostbyname3)(const char *name, int af, struct hostent *result,
 
     ret = NSS_STATUS_SUCCESS;
  cleanup:
-    VIR_FREE(addr);
     return ret;
 }
 
-- 
2.21.0

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

  Powered by Linux