1
0

storage: Refactor virStorageBackendFileSystemGetPoolSource

Refactor code to use standard return functioning with respect to setting
a ret value and going to cleanup.
This commit is contained in:
John Ferlan 2015-12-07 08:26:42 -05:00
parent 1d1330f37e
commit 61c29fe56f

View File

@ -418,6 +418,7 @@ virStorageBackendFileSystemGetPoolSource(virStoragePoolObjPtr pool)
static int static int
virStorageBackendFileSystemIsMounted(virStoragePoolObjPtr pool) virStorageBackendFileSystemIsMounted(virStoragePoolObjPtr pool)
{ {
int ret = -1;
FILE *mtab; FILE *mtab;
struct mntent ent; struct mntent ent;
char buf[1024]; char buf[1024];
@ -426,18 +427,21 @@ virStorageBackendFileSystemIsMounted(virStoragePoolObjPtr pool)
virReportSystemError(errno, virReportSystemError(errno,
_("cannot read mount list '%s'"), _("cannot read mount list '%s'"),
_PATH_MOUNTED); _PATH_MOUNTED);
return -1; goto cleanup;
} }
while ((getmntent_r(mtab, &ent, buf, sizeof(buf))) != NULL) { while ((getmntent_r(mtab, &ent, buf, sizeof(buf))) != NULL) {
if (STREQ(ent.mnt_dir, pool->def->target.path)) { if (STREQ(ent.mnt_dir, pool->def->target.path)) {
VIR_FORCE_FCLOSE(mtab); ret = 1;
return 1; goto cleanup;
} }
} }
ret = 0;
cleanup:
VIR_FORCE_FCLOSE(mtab); VIR_FORCE_FCLOSE(mtab);
return 0; return ret;
} }
/** /**