From: Peter Krempa <pkre...@redhat.com>

As the cleanup section is empty; the code can now return directly on
errors.

Signed-off-by: Peter Krempa <pkre...@redhat.com>
---
 src/util/virhostcpu.c | 31 +++++++++++++------------------
 1 file changed, 13 insertions(+), 18 deletions(-)

diff --git a/src/util/virhostcpu.c b/src/util/virhostcpu.c
index c4138076d9..2c4c75731c 100644
--- a/src/util/virhostcpu.c
+++ b/src/util/virhostcpu.c
@@ -643,7 +643,6 @@ virHostCPUGetInfoPopulateLinux(FILE *cpuinfo,
     int nodecpus, nodecores, nodesockets, nodethreads, offline = 0;
     int threads_per_subcore = 0;
     unsigned int node;
-    int ret = -1;
     g_autofree char *sysfs_nodedir = NULL;
     g_autofree char *sysfs_cpudir_fallback = NULL;
     int direrr;
@@ -659,12 +658,11 @@ virHostCPUGetInfoPopulateLinux(FILE *cpuinfo,

     /* Get information about what CPUs are present in the host and what
      * CPUs are online, so that we don't have to so for each node */
-    present_cpus_map = virHostCPUGetPresentBitmap();
-    if (!present_cpus_map)
-        goto cleanup;
-    online_cpus_map = virHostCPUGetOnlineBitmap();
-    if (!online_cpus_map)
-        goto cleanup;
+    if (!(present_cpus_map = virHostCPUGetPresentBitmap()))
+        return -1;
+
+    if (!(online_cpus_map = virHostCPUGetOnlineBitmap()))
+        return -1;

     /* OK, we've parsed clock speed out of /proc/cpuinfo. Get the
      * core, node, socket, thread and topology information from /sys
@@ -699,7 +697,7 @@ virHostCPUGetInfoPopulateLinux(FILE *cpuinfo,
      * On hosts other than POWER this will be 0, in which case a simpler
      * thread-counting logic will be used  */
     if ((threads_per_subcore = virHostCPUGetThreadsPerSubcore(arch)) < 0)
-        goto cleanup;
+        return -1;

     /* If the subcore configuration is not valid, just pretend subcores
      * are not in use and count threads one by one */
@@ -723,7 +721,7 @@ virHostCPUGetInfoPopulateLinux(FILE *cpuinfo,
                                             threads_per_subcore,
                                             &nodesockets, &nodecores,
                                             &nodethreads, &offline)) < 0)
-            goto cleanup;
+            return -1;

         *cpus += nodecpus;

@@ -738,7 +736,7 @@ virHostCPUGetInfoPopulateLinux(FILE *cpuinfo,
     }

     if (direrr < 0)
-        goto cleanup;
+        return -1;

     if (*cpus && *nodes)
         goto done;
@@ -752,7 +750,7 @@ virHostCPUGetInfoPopulateLinux(FILE *cpuinfo,
                                         threads_per_subcore,
                                         &nodesockets, &nodecores,
                                         &nodethreads, &offline)) < 0)
-        goto cleanup;
+        return -1;

     *nodes = 1;
     *cpus = nodecpus;
@@ -764,17 +762,17 @@ virHostCPUGetInfoPopulateLinux(FILE *cpuinfo,
     /* There should always be at least one cpu, socket, node, and thread. */
     if (*cpus == 0) {
         virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("no CPUs found"));
-        goto cleanup;
+        return -1;
     }

     if (*sockets == 0) {
         virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("no sockets found"));
-        goto cleanup;
+        return -1;
     }

     if (*threads == 0) {
         virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("no threads found"));
-        goto cleanup;
+        return -1;
     }

     /* Now check if the topology makes sense. There are machines that don't
@@ -794,10 +792,7 @@ virHostCPUGetInfoPopulateLinux(FILE *cpuinfo,
         *threads = 1;
     }

-    ret = 0;
-
- cleanup:
-    return ret;
+    return 0;
 }

 # define TICK_TO_NSEC (1000ull * 1000ull * 1000ull / sysconf(_SC_CLK_TCK))
-- 
2.49.0

Reply via email to