mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-08-27 19:11:16 +00:00
storage/util: replace unnecessary while loop by if
These while loops exit directly due to break after entering. Use if instead of these while loops. Signed-off-by: Jiang Jiacheng <jiangjiacheng@huawei.com> Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
This commit is contained in:
parent
022dcf076b
commit
e128d337c9
@ -3784,12 +3784,10 @@ getNewStyleBlockDevice(const char *lun_path,
|
|||||||
if (virDirOpen(&block_dir, block_path) < 0)
|
if (virDirOpen(&block_dir, block_path) < 0)
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
while ((direrr = virDirRead(block_dir, &block_dirent, block_path)) > 0) {
|
if ((direrr = virDirRead(block_dir, &block_dirent, block_path)) > 0) {
|
||||||
*block_device = g_strdup(block_dirent->d_name);
|
*block_device = g_strdup(block_dirent->d_name);
|
||||||
|
|
||||||
VIR_DEBUG("Block device is '%s'", *block_device);
|
VIR_DEBUG("Block device is '%s'", *block_device);
|
||||||
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (direrr < 0)
|
if (direrr < 0)
|
||||||
|
@ -1432,15 +1432,11 @@ virHostHasIOMMU(void)
|
|||||||
{
|
{
|
||||||
g_autoptr(DIR) iommuDir = NULL;
|
g_autoptr(DIR) iommuDir = NULL;
|
||||||
struct dirent *iommuGroup = NULL;
|
struct dirent *iommuGroup = NULL;
|
||||||
int direrr;
|
|
||||||
|
|
||||||
if (virDirOpenQuiet(&iommuDir, "/sys/kernel/iommu_groups/") < 0)
|
if (virDirOpenQuiet(&iommuDir, "/sys/kernel/iommu_groups/") < 0)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
while ((direrr = virDirRead(iommuDir, &iommuGroup, NULL)) > 0)
|
if (virDirRead(iommuDir, &iommuGroup, NULL) < 0 || !iommuGroup)
|
||||||
break;
|
|
||||||
|
|
||||||
if (direrr < 0 || !iommuGroup)
|
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
Loading…
Reference in New Issue
Block a user