diff --git a/src/cpu/cpu_ppc64.c b/src/cpu/cpu_ppc64.c index 59a5e1fc1d..3236a9616e 100644 --- a/src/cpu/cpu_ppc64.c +++ b/src/cpu/cpu_ppc64.c @@ -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; diff --git a/src/cpu/cpu_x86.c b/src/cpu/cpu_x86.c index abe4865ec2..52d69901cf 100644 --- a/src/cpu/cpu_x86.c +++ b/src/cpu/cpu_x86.c @@ -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; }