[PATCH v2 40/41] util: lease: use VIR_AUTOFREE instead of VIR_FREE for scalar types

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

 



By making use of GNU C's cleanup attribute handled by the
VIR_AUTOFREE macro for declaring scalar variables, majority
of the VIR_FREE calls can be dropped, which in turn leads to
getting rid of most of our cleanup sections.

Signed-off-by: Sukrit Bhatnagar <skrtbhtngr@xxxxxxxxx>
Reviewed-by: Erik Skultety <eskultet@xxxxxxxxxx>
---
 src/util/virlease.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/src/util/virlease.c b/src/util/virlease.c
index b49105d..baaceaf 100644
--- a/src/util/virlease.c
+++ b/src/util/virlease.c
@@ -55,7 +55,7 @@ virLeaseReadCustomLeaseFile(virJSONValuePtr leases_array_new,
                             const char *ip_to_delete,
                             char **server_duid)
 {
-    char *lease_entries = NULL;
+    VIR_AUTOFREE(char *) lease_entries = NULL;
     virJSONValuePtr leases_array = NULL;
     long long expirytime;
     int custom_lease_file_len = 0;
@@ -146,7 +146,6 @@ virLeaseReadCustomLeaseFile(virJSONValuePtr leases_array_new,
 
  cleanup:
     virJSONValueFree(leases_array);
-    VIR_FREE(lease_entries);
     return ret;
 }
 
@@ -235,7 +234,7 @@ virLeaseNew(virJSONValuePtr *lease_ret,
     virJSONValuePtr lease_new = NULL;
     const char *exptime_tmp = virGetEnvAllowSUID("DNSMASQ_LEASE_EXPIRES");
     long long expirytime = 0;
-    char *exptime = NULL;
+    VIR_AUTOFREE(char *) exptime = NULL;
     int ret = -1;
 
     /* In case hostname is still unknown, use the last known one */
@@ -291,7 +290,6 @@ virLeaseNew(virJSONValuePtr *lease_ret,
     *lease_ret = lease_new;
     lease_new = NULL;
  cleanup:
-    VIR_FREE(exptime);
     virJSONValueFree(lease_new);
     return ret;
 }
-- 
1.8.3.1

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