diff options
author | Max Reitz <mreitz@redhat.com> | 2018-02-13 14:03:50 +0100 |
---|---|---|
committer | Kevin Wolf <kwolf@redhat.com> | 2018-02-13 16:18:25 +0100 |
commit | 0375003df4153dce7f3ece9285b27427f00f9e01 (patch) | |
tree | a7437e9831badad711b0ed3640ca0ad377c00f34 /block/gluster.c | |
parent | 0e448a05444ddc602d2857a17f31042631a75946 (diff) |
gluster: Move glfs_close() to create's clean-up
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 <mreitz@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
Diffstat (limited to 'block/gluster.c')
-rw-r--r-- | block/gluster.c | 10 |
1 files 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; |