storage: improve the while loop virStorageBackendFileSystemIsMounted

Move virStorageBackendFileSystemGetPoolSource outside of the while loop

Signed-off-by: Yi Li <yili@winhong.com>
Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
This commit is contained in:
Yi Li 2019-10-31 11:55:26 +08:00 committed by Ján Tomko
parent f62f729b42
commit 94af82b936

View File

@ -258,10 +258,10 @@ virStorageBackendFileSystemIsMounted(virStoragePoolObjPtr pool)
goto cleanup;
}
while ((getmntent_r(mtab, &ent, buf, sizeof(buf))) != NULL) {
if (!(src = virStorageBackendFileSystemGetPoolSource(pool)))
goto cleanup;
if ((src = virStorageBackendFileSystemGetPoolSource(pool)) == NULL)
goto cleanup;
while ((getmntent_r(mtab, &ent, buf, sizeof(buf))) != NULL) {
/* compare both mount destinations and sources to be sure the mounted
* FS pool is really the one we're looking for
*/
@ -273,8 +273,6 @@ virStorageBackendFileSystemIsMounted(virStoragePoolObjPtr pool)
ret = 1;
goto cleanup;
}
VIR_FREE(src);
}
ret = 0;