]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
storage: Refactor virStorageBackendFileSystemGetPoolSource
authorJohn Ferlan <jferlan@redhat.com>
Mon, 7 Dec 2015 13:26:42 +0000 (08:26 -0500)
committerJohn Ferlan <jferlan@redhat.com>
Tue, 15 Dec 2015 19:33:04 +0000 (14:33 -0500)
Refactor code to use standard return functioning with respect to setting
a ret value and going to cleanup.

src/storage/storage_backend_fs.c

index fed0b779e1e129a9ec66848383d6f4bfdc4e326c..3a6f130cc0357bb63a90350858c231f95c98d672 100644 (file)
@@ -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;
 }
 
 /**