]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
Use virDirOpenQuiet
authorJán Tomko <jtomko@redhat.com>
Tue, 21 Jun 2016 14:52:37 +0000 (16:52 +0200)
committerJán Tomko <jtomko@redhat.com>
Fri, 24 Jun 2016 12:20:57 +0000 (14:20 +0200)
Remove all the remaining usage of opendir.

src/openvz/openvz_conf.c
src/qemu/qemu_hostdev.c
src/storage/storage_backend.c
src/util/vircgroup.c
src/util/virhostcpu.c
src/util/virpci.c
tools/nss/libvirt_nss.c

index aa04bc4e0766d7b3bce33b58d59d08b15f36495f..ff321915b63a10a894f5f345d11b2602a01fa965 100644 (file)
@@ -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;
     }
index 0952767000f8703e544b61ed6f0d520472d04019..dd3a3cf8faf713be40319afe5cecd9dfbfaca1bb 100644 (file)
@@ -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) {
index 43f6ecc383d33984997a3c31130d546d93b9168a..5adf1fd71b69fa8a6503e8f024e6424b745215ef 100644 (file)
@@ -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);
index 4c6abd96ce461c39ef9537bed00b5141929f2980..04f38181e56a956f2830b4ae12340d921f5cc844 100644 (file)
@@ -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;
index 087ce225847d7c64681c01196bd7791e5c6966f5..f38fbec5f389d1bdb1d6beb656ee4589b02bc703 100644 (file)
@@ -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;
     }
index 98951119d759960b0b6397654430e4eec452b05b..132948d32dbd5b44ad46aa4b3dae535571c88727 100644 (file)
@@ -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) {
index d0b7217e97ea23e68ed42007c412f6add074d329..54c4a2a133ebd6a8a71d3371c160e2835d9f478b 100644 (file)
@@ -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;
     }