]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
cpu: Use g_strdup_printf() instead of virAsprintf()
authorMichal Privoznik <mprivozn@redhat.com>
Tue, 22 Oct 2019 13:26:14 +0000 (15:26 +0200)
committerMichal Privoznik <mprivozn@redhat.com>
Tue, 12 Nov 2019 15:15:58 +0000 (16:15 +0100)
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
src/cpu/cpu_ppc64.c
src/cpu/cpu_x86.c

index 59a5e1fc1d57ce17513d4204143578cc39c133da..3236a9616e8350d074e066a56060363d28c6730b 100644 (file)
@@ -459,11 +459,9 @@ ppc64Compute(virCPUDefPtr host,
         if (!found) {
             VIR_DEBUG("CPU arch %s does not match host arch",
                       virArchToString(cpu->arch));
-            if (message &&
-                virAsprintf(message,
-                            _("CPU arch %s does not match host arch"),
-                            virArchToString(cpu->arch)) < 0)
-                goto cleanup;
+            if (message)
+                *message = g_strdup_printf(_("CPU arch %s does not match host arch"),
+                                           virArchToString(cpu->arch));
 
             ret = VIR_CPU_COMPARE_INCOMPATIBLE;
             goto cleanup;
@@ -477,12 +475,11 @@ 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 &&
-            virAsprintf(message,
-                        _("host CPU vendor does not match required "
-                        "CPU vendor %s"),
-                        cpu->vendor) < 0)
-            goto cleanup;
+        if (message) {
+            *message = g_strdup_printf(_("host CPU vendor does not match required "
+                                         "CPU vendor %s"),
+                                       cpu->vendor);
+        }
 
         ret = VIR_CPU_COMPARE_INCOMPATIBLE;
         goto cleanup;
@@ -532,12 +529,11 @@ 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 &&
-            virAsprintf(message,
-                        _("host CPU model does not match required "
-                        "CPU model %s"),
-                        guest_model->name) < 0)
-            goto cleanup;
+        if (message) {
+            *message = g_strdup_printf(_("host CPU model does not match required "
+                                         "CPU model %s"),
+                                       guest_model->name);
+        }
 
         ret = VIR_CPU_COMPARE_INCOMPATIBLE;
         goto cleanup;
index abe4865ec2f4dc43cf314903596e37307d8f793b..52d69901cf3f9920a5553699706408f3a40592e4 100644 (file)
@@ -1721,11 +1721,8 @@ virCPUx86DataParse(xmlXPathContextPtr ctxt)
                 virReportOOMError(); \
                 goto error; \
             } \
-            if (message && \
-                virAsprintf(message, "%s: %s", _(MSG), flagsStr) < 0) { \
-                VIR_FREE(flagsStr); \
-                goto error; \
-            } \
+            if (message) \
+                *message = g_strdup_printf("%s: %s", _(MSG), flagsStr); \
             VIR_DEBUG("%s: %s", MSG, flagsStr); \
             VIR_FREE(flagsStr); \
             ret = VIR_CPU_COMPARE_INCOMPATIBLE; \
@@ -1766,11 +1763,10 @@ x86Compute(virCPUDefPtr host,
         if (!found) {
             VIR_DEBUG("CPU arch %s does not match host arch",
                       virArchToString(cpu->arch));
-            if (message &&
-                virAsprintf(message,
-                            _("CPU arch %s does not match host arch"),
-                            virArchToString(cpu->arch)) < 0)
-                goto error;
+            if (message) {
+                *message = g_strdup_printf(_("CPU arch %s does not match host arch"),
+                                           virArchToString(cpu->arch));
+            }
             return VIR_CPU_COMPARE_INCOMPATIBLE;
         }
         arch = cpu->arch;
@@ -1782,12 +1778,11 @@ 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 &&
-            virAsprintf(message,
-                        _("host CPU vendor does not match required "
-                          "CPU vendor %s"),
-                        cpu->vendor) < 0)
-            goto error;
+        if (message) {
+            *message = g_strdup_printf(_("host CPU vendor does not match required "
+                                         "CPU vendor %s"),
+                                       cpu->vendor);
+        }
 
         return VIR_CPU_COMPARE_INCOMPATIBLE;
     }