On 07.12.2015 21:47, John Ferlan wrote:
Refactor code to use standard return functioning with respect to
setting
a ret value and going to cleanup.
Signed-off-by: John Ferlan <jferlan(a)redhat.com>
---
src/storage/storage_backend_fs.c | 12 ++++++++----
1 file changed, 8 insertions(+), 4 deletions(-)
diff --git a/src/storage/storage_backend_fs.c b/src/storage/storage_backend_fs.c
index ef1a7d0..1dd5727 100644
--- a/src/storage/storage_backend_fs.c
+++ b/src/storage/storage_backend_fs.c
@@ -418,6 +418,7 @@ virStorageBackendFileSystemGetPoolSource(virStoragePoolObjPtr pool)
static int
virStorageBackendFileSystemIsMounted(virStoragePoolObjPtr pool)
{
+ int ret = -1;
FILE *mtab;
struct mntent ent;
char buf[1024];
@@ -426,18 +427,21 @@ virStorageBackendFileSystemIsMounted(virStoragePoolObjPtr pool)
virReportSystemError(errno,
_("cannot read mount list '%s'"),
_PATH_MOUNTED);
- return -1;
+ goto cleanup;
}
while ((getmntent_r(mtab, &ent, buf, sizeof(buf))) != NULL) {
if (STREQ(ent.mnt_dir, pool->def->target.path)) {
- VIR_FORCE_FCLOSE(mtab);
- return 1;
+ ret = 1;
+ goto cleanup;
}
}
+ ret = 0;
+
+ cleanup:
VIR_FORCE_FCLOSE(mtab);
- return 0;
+ return ret;
}
/**
ACK
Michal