提交 b62b176b 编写于 作者: P Peter Krempa

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: NPeter Krempa <pkrempa@redhat.com>
Reviewed-by: NPavel Mores <pmores@redhat.com>
上级 6046046e
...@@ -268,24 +268,20 @@ qemuSecurityChownCallback(const virStorageSource *src, ...@@ -268,24 +268,20 @@ qemuSecurityChownCallback(const virStorageSource *src,
} }
if (chown(src->path, uid, gid) < 0) if (chown(src->path, uid, gid) < 0)
goto cleanup; return -1;
} 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;
}
if (virStorageFileChown(cpy, uid, gid) < 0) return 0;
goto cleanup;
} }
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; save_errno = errno;
virStorageFileDeinit(cpy); virStorageFileDeinit(cpy);
errno = save_errno; errno = save_errno;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册