[libvirt] [PATCH 06/75] cpu: Drop virAsprintf() and virAsprintfQuiet() retval checking

Michal Privoznik mprivozn at redhat.com
Tue Oct 22 13:57:10 UTC 2019


These functions can't fail really. Drop checking of their retval
then.

Signed-off-by: Michal Privoznik <mprivozn at redhat.com>
---
 src/cpu/cpu_ppc64.c | 21 ++++++++++-----------
 src/cpu/cpu_x86.c   | 19 ++++++++-----------
 2 files changed, 18 insertions(+), 22 deletions(-)

diff --git a/src/cpu/cpu_ppc64.c b/src/cpu/cpu_ppc64.c
index 59a5e1fc1d..990bbbd45f 100644
--- a/src/cpu/cpu_ppc64.c
+++ b/src/cpu/cpu_ppc64.c
@@ -459,11 +459,10 @@ ppc64Compute(virCPUDefPtr host,
         if (!found) {
             VIR_DEBUG("CPU arch %s does not match host arch",
                       virArchToString(cpu->arch));
-            if (message &&
+            if (message)
                 virAsprintf(message,
                             _("CPU arch %s does not match host arch"),
-                            virArchToString(cpu->arch)) < 0)
-                goto cleanup;
+                            virArchToString(cpu->arch));
 
             ret = VIR_CPU_COMPARE_INCOMPATIBLE;
             goto cleanup;
@@ -477,12 +476,12 @@ ppc64Compute(virCPUDefPtr host,
         (!host->vendor || STRNEQ(cpu->vendor, host->vendor))) {
         VIR_DEBUG("host CPU vendor does not match required CPU vendor %s",
                   cpu->vendor);
-        if (message &&
+        if (message) {
             virAsprintf(message,
                         _("host CPU vendor does not match required "
-                        "CPU vendor %s"),
-                        cpu->vendor) < 0)
-            goto cleanup;
+                          "CPU vendor %s"),
+                        cpu->vendor);
+        }
 
         ret = VIR_CPU_COMPARE_INCOMPATIBLE;
         goto cleanup;
@@ -532,12 +531,12 @@ ppc64Compute(virCPUDefPtr host,
     if (STRNEQ(guest_model->name, host_model->name)) {
         VIR_DEBUG("host CPU model does not match required CPU model %s",
                   guest_model->name);
-        if (message &&
+        if (message) {
             virAsprintf(message,
                         _("host CPU model does not match required "
-                        "CPU model %s"),
-                        guest_model->name) < 0)
-            goto cleanup;
+                          "CPU model %s"),
+                        guest_model->name);
+        }
 
         ret = VIR_CPU_COMPARE_INCOMPATIBLE;
         goto cleanup;
diff --git a/src/cpu/cpu_x86.c b/src/cpu/cpu_x86.c
index d7fcb3b147..8418339d6f 100644
--- a/src/cpu/cpu_x86.c
+++ b/src/cpu/cpu_x86.c
@@ -1724,11 +1724,8 @@ virCPUx86DataParse(xmlXPathContextPtr ctxt)
                 virReportOOMError(); \
                 goto error; \
             } \
-            if (message && \
-                virAsprintf(message, "%s: %s", _(MSG), flagsStr) < 0) { \
-                VIR_FREE(flagsStr); \
-                goto error; \
-            } \
+            if (message) \
+                virAsprintf(message, "%s: %s", _(MSG), flagsStr); \
             VIR_DEBUG("%s: %s", MSG, flagsStr); \
             VIR_FREE(flagsStr); \
             ret = VIR_CPU_COMPARE_INCOMPATIBLE; \
@@ -1769,11 +1766,11 @@ x86Compute(virCPUDefPtr host,
         if (!found) {
             VIR_DEBUG("CPU arch %s does not match host arch",
                       virArchToString(cpu->arch));
-            if (message &&
+            if (message) {
                 virAsprintf(message,
                             _("CPU arch %s does not match host arch"),
-                            virArchToString(cpu->arch)) < 0)
-                goto error;
+                            virArchToString(cpu->arch));
+            }
             return VIR_CPU_COMPARE_INCOMPATIBLE;
         }
         arch = cpu->arch;
@@ -1785,12 +1782,12 @@ x86Compute(virCPUDefPtr host,
         (!host->vendor || STRNEQ(cpu->vendor, host->vendor))) {
         VIR_DEBUG("host CPU vendor does not match required CPU vendor %s",
                   cpu->vendor);
-        if (message &&
+        if (message) {
             virAsprintf(message,
                         _("host CPU vendor does not match required "
                           "CPU vendor %s"),
-                        cpu->vendor) < 0)
-            goto error;
+                        cpu->vendor);
+        }
 
         return VIR_CPU_COMPARE_INCOMPATIBLE;
     }
-- 
2.21.0




More information about the libvir-list mailing list