[PATCH v2 38/41] util: kmod: 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/virkmod.c | 16 ++++++----------
 1 file changed, 6 insertions(+), 10 deletions(-)

diff --git a/src/util/virkmod.c b/src/util/virkmod.c
index 219fad6..d981cd4 100644
--- a/src/util/virkmod.c
+++ b/src/util/virkmod.c
@@ -155,13 +155,12 @@ virKModUnload(const char *module)
 bool
 virKModIsBlacklisted(const char *module)
 {
-    bool retval = false;
     size_t i;
-    char *drvblklst = NULL;
-    char *outbuf = NULL;
+    VIR_AUTOFREE(char *) drvblklst = NULL;
+    VIR_AUTOFREE(char *) outbuf = NULL;
 
     if (virAsprintfQuiet(&drvblklst, "blacklist %s\n", module) < 0)
-        goto cleanup;
+        return false;
 
     /* modprobe will convert all '-' into '_', so we need to as well */
     for (i = 0; i < drvblklst[i]; i++)
@@ -169,13 +168,10 @@ virKModIsBlacklisted(const char *module)
             drvblklst[i] = '_';
 
     if (doModprobe("-c", NULL, &outbuf, NULL) < 0)
-        goto cleanup;
+        return false;
 
     if (strstr(outbuf, drvblklst))
-        retval = true;
+        return true;
 
- cleanup:
-    VIR_FREE(drvblklst);
-    VIR_FREE(outbuf);
-    return retval;
+    return false;
 }
-- 
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