[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PULL 09/55] gluster: Move glfs_close() to create's clean-u
From: |
Kevin Wolf |
Subject: |
[Qemu-devel] [PULL 09/55] gluster: Move glfs_close() to create's clean-up |
Date: |
Tue, 13 Feb 2018 18:04:43 +0100 |
From: Max Reitz <address@hidden>
glfs_close() is a classical clean-up operation, as can be seen by the
fact that it is executed even if the truncation before it failed.
Also, moving it to clean-up makes it more clear that if it fails, we do
not want it to overwrite the current ret value if that signifies an
error already.
Signed-off-by: Max Reitz <address@hidden>
Reviewed-by: Eric Blake <address@hidden>
Signed-off-by: Kevin Wolf <address@hidden>
---
block/gluster.c | 10 ++++++----
1 file changed, 6 insertions(+), 4 deletions(-)
diff --git a/block/gluster.c b/block/gluster.c
index d8decc41ad..7fab2dfa12 100644
--- a/block/gluster.c
+++ b/block/gluster.c
@@ -970,7 +970,7 @@ static int qemu_gluster_create(const char *filename,
{
BlockdevOptionsGluster *gconf;
struct glfs *glfs;
- struct glfs_fd *fd;
+ struct glfs_fd *fd = NULL;
int ret = 0;
PreallocMode prealloc;
int64_t total_size = 0;
@@ -1054,10 +1054,12 @@ static int qemu_gluster_create(const char *filename,
break;
}
- if (glfs_close(fd) != 0) {
- ret = -errno;
- }
out:
+ if (fd) {
+ if (glfs_close(fd) != 0 && ret == 0) {
+ ret = -errno;
+ }
+ }
qapi_free_BlockdevOptionsGluster(gconf);
glfs_clear_preopened(glfs);
return ret;
--
2.13.6
- [Qemu-devel] [PULL 00/55] Block layer patches, Kevin Wolf, 2018/02/13
- [Qemu-devel] [PULL 01/55] iotests: Fix CID for VMDK afl image, Kevin Wolf, 2018/02/13
- [Qemu-devel] [PULL 03/55] qemu-img: Document --force-share / -U, Kevin Wolf, 2018/02/13
- [Qemu-devel] [PULL 06/55] block: early check for blockers on drive-mirror, Kevin Wolf, 2018/02/13
- [Qemu-devel] [PULL 02/55] qemu-img.texi: Clean up parameter list, Kevin Wolf, 2018/02/13
- [Qemu-devel] [PULL 04/55] docs: Document share-rw property more thoroughly, Kevin Wolf, 2018/02/13
- [Qemu-devel] [PULL 08/55] qemu-io: fix EOF Ctrl-D handling in qemu-io readline code, Kevin Wolf, 2018/02/13
- [Qemu-devel] [PULL 10/55] gluster: Pull truncation from qemu_gluster_create, Kevin Wolf, 2018/02/13
- [Qemu-devel] [PULL 05/55] qcow2: Use g_try_realloc() in qcow2_expand_zero_clusters(), Kevin Wolf, 2018/02/13
- [Qemu-devel] [PULL 09/55] gluster: Move glfs_close() to create's clean-up,
Kevin Wolf <=
- [Qemu-devel] [PULL 11/55] gluster: Query current size in do_truncate(), Kevin Wolf, 2018/02/13
- [Qemu-devel] [PULL 07/55] iotests: Use virtio-blk in 155, Kevin Wolf, 2018/02/13
- [Qemu-devel] [PULL 14/55] sheepdog: Pass old and new size to sd_prealloc(), Kevin Wolf, 2018/02/13
- [Qemu-devel] [PULL 15/55] sheepdog: Allow fully preallocated truncation, Kevin Wolf, 2018/02/13
- [Qemu-devel] [PULL 13/55] sheepdog: Make sd_prealloc() take a BDS, Kevin Wolf, 2018/02/13
- [Qemu-devel] [PULL 17/55] qcow2: Fix documentation of get_cluster_table(), Kevin Wolf, 2018/02/13
- [Qemu-devel] [PULL 20/55] qcow2: Remove BDS parameter from qcow2_cache_get_table_idx(), Kevin Wolf, 2018/02/13
- [Qemu-devel] [PULL 22/55] qcow2: Remove BDS parameter from qcow2_cache_entry_mark_dirty(), Kevin Wolf, 2018/02/13
- [Qemu-devel] [PULL 21/55] qcow2: Remove BDS parameter from qcow2_cache_table_release(), Kevin Wolf, 2018/02/13
- [Qemu-devel] [PULL 12/55] gluster: Add preallocated truncation, Kevin Wolf, 2018/02/13