[PATCH 28/39] virResctrlAllocNewFromInfo: Use g_autoptr for 'ret'

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

 



Remove 'cleanup' and 'error' labels by switching 'ret' to automatic
pointer and stealing it in the return statement.

Signed-off-by: Peter Krempa <pkrempa@xxxxxxxxxx>
---
 src/util/virresctrl.c | 11 +++--------
 1 file changed, 3 insertions(+), 8 deletions(-)

diff --git a/src/util/virresctrl.c b/src/util/virresctrl.c
index 5e7c391524..c66cf4b087 100644
--- a/src/util/virresctrl.c
+++ b/src/util/virresctrl.c
@@ -1811,7 +1811,7 @@ static virResctrlAllocPtr
 virResctrlAllocNewFromInfo(virResctrlInfoPtr info)
 {
     size_t i = 0;
-    virResctrlAllocPtr ret = virResctrlAllocNew();
+    g_autoptr(virResctrlAlloc) ret = virResctrlAllocNew();

     if (!ret)
         return NULL;
@@ -1836,7 +1836,7 @@ virResctrlAllocNewFromInfo(virResctrlInfoPtr info)

             for (k = 0; k <= i_type->max_cache_id; k++) {
                 if (virResctrlAllocUpdateMask(ret, i, j, k, mask) < 0)
-                    goto error;
+                    return NULL;
             }
         }
     }
@@ -1854,12 +1854,7 @@ virResctrlAllocNewFromInfo(virResctrlInfoPtr info)
         }
     }

- cleanup:
-    return ret;
- error:
-    virObjectUnref(ret);
-    ret = NULL;
-    goto cleanup;
+    return g_steal_pointer(&ret);
 }

 /*
-- 
2.29.2




[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