]> xenbits.xensource.com Git - libvirt.git/commitdiff
qemuSecurityChownCallback: Remove 'cleanup' section
authorPeter Krempa <pkrempa@redhat.com>
Thu, 26 Mar 2020 11:08:59 +0000 (12:08 +0100)
committerPeter Krempa <pkrempa@redhat.com>
Fri, 3 Apr 2020 07:32:45 +0000 (09:32 +0200)
Treat the shortcut for chowning local files as a stand-alone section
by returning success from it and refactor the rest so that the cleanup
section is inline.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Pavel Mores <pmores@redhat.com>
src/qemu/qemu_driver.c

index ff97f10f11fda46c49593f179e0a94f987272f21..3d944d27130b74bcdb64cd9ac5d7da6315a632ce 100644 (file)
@@ -268,24 +268,20 @@ qemuSecurityChownCallback(const virStorageSource *src,
         }
 
         if (chown(src->path, uid, gid) < 0)
-            goto cleanup;
-    } else {
-        if (!(cpy = virStorageSourceCopy(src, false)))
-            goto cleanup;
-
-        /* src file init reports errors, return -2 on failure */
-        if (virStorageFileInit(cpy) < 0) {
-            ret = -2;
-            goto cleanup;
-        }
+            return -1;
 
-        if (virStorageFileChown(cpy, uid, gid) < 0)
-            goto cleanup;
+        return 0;
     }
 
-    ret = 0;
+    if (!(cpy = virStorageSourceCopy(src, false)))
+        return -1;
+
+    /* src file init reports errors, return -2 on failure */
+    if (virStorageFileInit(cpy) < 0)
+        return -2;
+
+    ret = virStorageFileChown(cpy, uid, gid);
 
- cleanup:
     save_errno = errno;
     virStorageFileDeinit(cpy);
     errno = save_errno;