qemuSecurityChownCallback: Remove 'cleanup' section

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>
This commit is contained in:
Peter Krempa 2020-03-26 12:08:59 +01:00
parent 6046046e3d
commit b62b176be2
1 changed files with 10 additions and 14 deletions

View 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;
return -1;
/* src file init reports errors, return -2 on failure */
if (virStorageFileInit(cpy) < 0) {
ret = -2;
goto cleanup;
}
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;