[PATCH 10/18] Use virDirOpenQuiet

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Remove all the remaining usage of opendir.
---
 src/openvz/openvz_conf.c      | 3 +--
 src/qemu/qemu_hostdev.c       | 2 +-
 src/storage/storage_backend.c | 2 +-
 src/util/vircgroup.c          | 3 +--
 src/util/virhostcpu.c         | 2 +-
 src/util/virpci.c             | 2 +-
 6 files changed, 6 insertions(+), 8 deletions(-)

diff --git a/src/openvz/openvz_conf.c b/src/openvz/openvz_conf.c
index ff5e5b8..b678456 100644
--- a/src/openvz/openvz_conf.c
+++ b/src/openvz/openvz_conf.c
@@ -1057,8 +1057,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 84f3615..2fdfae9 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 955d983..31c2974 100644
--- a/src/storage/storage_backend.c
+++ b/src/storage/storage_backend.c
@@ -1928,7 +1928,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 634f659..da20ba5 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 087ce22..f38fbec 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 77ae9b4..c497f02 100644
--- a/src/util/virpci.c
+++ b/src/util/virpci.c
@@ -2015,7 +2015,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;
-- 
2.7.3

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list



[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]