diff --git a/src/openvz/openvz_conf.c b/src/openvz/openvz_conf.c index aa04bc4e07..ff321915b6 100644 --- a/src/openvz/openvz_conf.c +++ b/src/openvz/openvz_conf.c @@ -1058,8 +1058,7 @@ static int openvzAssignUUIDs(void) if (conf_dir == NULL) return -1; - dp = opendir(conf_dir); - if (dp == NULL) { + if (virDirOpenQuiet(&dp, conf_dir) < 0) { VIR_FREE(conf_dir); return 0; } diff --git a/src/qemu/qemu_hostdev.c b/src/qemu/qemu_hostdev.c index 0952767000..dd3a3cf8fa 100644 --- a/src/qemu/qemu_hostdev.c +++ b/src/qemu/qemu_hostdev.c @@ -111,7 +111,7 @@ qemuHostdevHostSupportsPassthroughVFIO(void) int direrr; /* condition 1 - /sys/kernel/iommu_groups/ contains entries */ - if (!(iommuDir = opendir("/sys/kernel/iommu_groups/"))) + if (virDirOpenQuiet(&iommuDir, "/sys/kernel/iommu_groups/") < 0) goto cleanup; while ((direrr = virDirRead(iommuDir, &iommuGroup, NULL)) > 0) { diff --git a/src/storage/storage_backend.c b/src/storage/storage_backend.c index 43f6ecc383..5adf1fd71b 100644 --- a/src/storage/storage_backend.c +++ b/src/storage/storage_backend.c @@ -1917,7 +1917,7 @@ virStorageBackendStablePath(virStoragePoolObjPtr pool, * get created. */ reopen: - if ((dh = opendir(pool->def->target.path)) == NULL) { + if (virDirOpenQuiet(&dh, pool->def->target.path) < 0) { opentries++; if (loop && errno == ENOENT && opentries < 50) { usleep(100 * 1000); diff --git a/src/util/vircgroup.c b/src/util/vircgroup.c index 4c6abd96ce..04f38181e5 100644 --- a/src/util/vircgroup.c +++ b/src/util/vircgroup.c @@ -3378,8 +3378,7 @@ virCgroupRemoveRecursively(char *grppath) int rc = 0; int direrr; - grpdir = opendir(grppath); - if (grpdir == NULL) { + if (virDirOpenQuiet(&grpdir, grppath) < 0) { if (errno == ENOENT) return 0; rc = -errno; diff --git a/src/util/virhostcpu.c b/src/util/virhostcpu.c index 087ce22584..f38fbec5f3 100644 --- a/src/util/virhostcpu.c +++ b/src/util/virhostcpu.c @@ -641,7 +641,7 @@ virHostCPUGetInfoPopulateLinux(FILE *cpuinfo, if (virAsprintf(&sysfs_nodedir, "%s/node", sysfs_system_path) < 0) goto cleanup; - if (!(nodedir = opendir(sysfs_nodedir))) { + if (virDirOpenQuiet(&nodedir, sysfs_nodedir) < 0) { /* the host isn't probably running a NUMA architecture */ goto fallback; } diff --git a/src/util/virpci.c b/src/util/virpci.c index 98951119d7..132948d32d 100644 --- a/src/util/virpci.c +++ b/src/util/virpci.c @@ -2011,7 +2011,7 @@ virPCIDeviceAddressIOMMUGroupIterate(virPCIDeviceAddressPtr orig, orig->domain, orig->bus, orig->slot, orig->function) < 0) goto cleanup; - if (!(groupDir = opendir(groupPath))) { + if (virDirOpenQuiet(&groupDir, groupPath) < 0) { /* just process the original device, nothing more */ ret = (actor)(orig, opaque); goto cleanup; @@ -2683,8 +2683,7 @@ virPCIGetNetName(char *device_link_sysfs_path, char **netname) return -1; } - dir = opendir(pcidev_sysfs_net_path); - if (dir == NULL) + if (virDirOpenQuiet(&dir, pcidev_sysfs_net_path) < 0) goto out; while (virDirRead(dir, &entry, pcidev_sysfs_net_path) > 0) { diff --git a/tools/nss/libvirt_nss.c b/tools/nss/libvirt_nss.c index d0b7217e97..54c4a2a133 100644 --- a/tools/nss/libvirt_nss.c +++ b/tools/nss/libvirt_nss.c @@ -125,7 +125,7 @@ findLease(const char *name, } - if (!(dir = opendir(leaseDir))) { + if (virDirOpenQuiet(&dir, leaseDir) < 0) { ERROR("Failed to open dir '%s'", leaseDir); goto cleanup; }