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>
This commit is contained in:
parent
0e448a0544
commit
0375003df4
@ -970,7 +970,7 @@ static int qemu_gluster_create(const char *filename,
|
|||||||
{
|
{
|
||||||
BlockdevOptionsGluster *gconf;
|
BlockdevOptionsGluster *gconf;
|
||||||
struct glfs *glfs;
|
struct glfs *glfs;
|
||||||
struct glfs_fd *fd;
|
struct glfs_fd *fd = NULL;
|
||||||
int ret = 0;
|
int ret = 0;
|
||||||
PreallocMode prealloc;
|
PreallocMode prealloc;
|
||||||
int64_t total_size = 0;
|
int64_t total_size = 0;
|
||||||
@ -1054,10 +1054,12 @@ static int qemu_gluster_create(const char *filename,
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (glfs_close(fd) != 0) {
|
out:
|
||||||
|
if (fd) {
|
||||||
|
if (glfs_close(fd) != 0 && ret == 0) {
|
||||||
ret = -errno;
|
ret = -errno;
|
||||||
}
|
}
|
||||||
out:
|
}
|
||||||
qapi_free_BlockdevOptionsGluster(gconf);
|
qapi_free_BlockdevOptionsGluster(gconf);
|
||||||
glfs_clear_preopened(glfs);
|
glfs_clear_preopened(glfs);
|
||||||
return ret;
|
return ret;
|
||||||
|
Loading…
Reference in New Issue
Block a user