]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
virCgroupKillRecursive: Refactor cleanup
authorPeter Krempa <pkrempa@redhat.com>
Thu, 22 Oct 2020 07:59:52 +0000 (09:59 +0200)
committerPeter Krempa <pkrempa@redhat.com>
Thu, 22 Oct 2020 13:02:46 +0000 (15:02 +0200)
Remove 'cleanup' label and simplify remembering of the returned value
from the callback.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
src/util/vircgroup.c

index b74ec1a8fae3d1df8a34e5e61355b4ca8460e112..b1caf11f47e4ace32a8f9228e416f441dcfdcc72 100644 (file)
@@ -2532,8 +2532,8 @@ virCgroupKillRecursiveInternal(virCgroupPtr group,
 int
 virCgroupKillRecursive(virCgroupPtr group, int signum)
 {
-    int ret = 0;
     int rc;
+    bool success = false;
     size_t i;
     bool backendAvailable = false;
     virCgroupBackendPtr *backends = virCgroupBackendGetAll();
@@ -2544,25 +2544,24 @@ virCgroupKillRecursive(virCgroupPtr group, int signum)
     for (i = 0; i < VIR_CGROUP_BACKEND_TYPE_LAST; i++) {
         if (backends && backends[i] && backends[i]->available()) {
             backendAvailable = true;
-            rc = backends[i]->killRecursive(group, signum, pids);
-            if (rc < 0) {
-                ret = -1;
-                goto cleanup;
-            }
+            if ((rc = backends[i]->killRecursive(group, signum, pids)) < 0)
+                return -1;
+
             if (rc > 0)
-                ret = rc;
+                success = true;
         }
     }
 
+    if (success)
+        return 1;
+
     if (!backends || !backendAvailable) {
         virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
                        _("no cgroup backend available"));
-        ret = -1;
-        goto cleanup;
+        return -1;
     }
 
- cleanup:
-    return ret;
+    return 0;
 }