[libvirt] [PATCH 03/18] Do not check the return value of closedir

Ján Tomko jtomko at redhat.com
Tue Jun 21 16:05:26 UTC 2016


The only possible error is EBADFD.
Since we only use the directory stream returned by opendir,
this should never happen.
---
 src/util/virhostcpu.c | 15 ++++-----------
 1 file changed, 4 insertions(+), 11 deletions(-)

diff --git a/src/util/virhostcpu.c b/src/util/virhostcpu.c
index 4ed7b21..0cdba0a 100644
--- a/src/util/virhostcpu.c
+++ b/src/util/virhostcpu.c
@@ -477,11 +477,8 @@ virHostCPUParseNode(const char *node,
     ret = processors;
 
  cleanup:
-    /* don't shadow a more serious error */
-    if (cpudir && closedir(cpudir) < 0 && ret >= 0) {
-        virReportSystemError(errno, _("problem closing %s"), node);
-        ret = -1;
-    }
+    if (cpudir)
+        closedir(cpudir);
     if (cores_maps)
         for (i = 0; i < sock_max; i++)
             virBitmapFree(cores_maps[i]);
@@ -777,12 +774,8 @@ virHostCPUGetInfoPopulateLinux(FILE *cpuinfo,
     ret = 0;
 
  cleanup:
-    /* don't shadow a more serious error */
-    if (nodedir && closedir(nodedir) < 0 && ret >= 0) {
-        virReportSystemError(errno, _("problem closing %s"), sysfs_nodedir);
-        ret = -1;
-    }
-
+    if (nodedir)
+        closedir(nodedir);
     virBitmapFree(present_cpus_map);
     virBitmapFree(online_cpus_map);
     VIR_FREE(sysfs_nodedir);
-- 
2.7.3




More information about the libvir-list mailing list