It already reports an error if STRDUP fails.
---
src/conf/capabilities.c | 4 +---
src/conf/domain_conf.c | 19 ++++---------------
src/conf/network_conf.c | 2 +-
src/lxc/lxc_cgroup.c | 11 ++---------
src/qemu/qemu_cgroup.c | 16 +++-------------
src/qemu/qemu_driver.c | 10 ++--------
src/util/virbitmap.c | 1 +
7 files changed, 14 insertions(+), 49 deletions(-)
diff --git a/src/conf/capabilities.c b/src/conf/capabilities.c
index 408fab3..954456b 100644
--- a/src/conf/capabilities.c
+++ b/src/conf/capabilities.c
@@ -791,10 +791,8 @@ virCapabilitiesFormatNUMATopology(virBufferPtr buf,
virBufferAsprintf(buf, "<cpu id='%d'",
cells[i]->cpus[j].id);
if (cells[i]->cpus[j].siblings) {
- if (!(siblings = virBitmapFormat(cells[i]->cpus[j].siblings))) {
- virReportOOMError();
+ if (!(siblings = virBitmapFormat(cells[i]->cpus[j].siblings)))
return -1;
- }
virBufferAsprintf(buf,
" socket_id='%d' core_id='%d'
siblings='%s'",
diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index fe06921..ee59312 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -17363,11 +17363,8 @@ virDomainDefFormatInternal(virDomainDefPtr def,
virBufferAsprintf(buf, "<vcpupin vcpu='%u' ",
def->cputune.vcpupin[i]->vcpuid);
- if (!(cpumask = virBitmapFormat(def->cputune.vcpupin[i]->cpumask))) {
- virReportError(VIR_ERR_INTERNAL_ERROR,
- "%s", _("failed to format cpuset for
vcpupin"));
+ if (!(cpumask = virBitmapFormat(def->cputune.vcpupin[i]->cpumask)))
goto error;
- }
virBufferAsprintf(buf, "cpuset='%s'/>\n", cpumask);
VIR_FREE(cpumask);
@@ -17377,11 +17374,8 @@ virDomainDefFormatInternal(virDomainDefPtr def,
char *cpumask;
virBufferAddLit(buf, "<emulatorpin ");
- if (!(cpumask = virBitmapFormat(def->cputune.emulatorpin->cpumask))) {
- virReportError(VIR_ERR_INTERNAL_ERROR,
- "%s", _("failed to format cpuset for
emulator"));
- goto error;
- }
+ if (!(cpumask = virBitmapFormat(def->cputune.emulatorpin->cpumask)))
+ goto error;
virBufferAsprintf(buf, "cpuset='%s'/>\n", cpumask);
VIR_FREE(cpumask);
@@ -17407,13 +17401,8 @@ virDomainDefFormatInternal(virDomainDefPtr def,
if (def->numatune.memory.placement_mode ==
VIR_NUMA_TUNE_MEM_PLACEMENT_MODE_STATIC) {
- nodemask = virBitmapFormat(def->numatune.memory.nodemask);
- if (nodemask == NULL) {
- virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
- _("failed to format nodeset for "
- "NUMA memory tuning"));
+ if (!(nodemask = virBitmapFormat(def->numatune.memory.nodemask)))
goto error;
- }
virBufferAsprintf(buf, "nodeset='%s'/>\n", nodemask);
VIR_FREE(nodemask);
} else if (def->numatune.memory.placement_mode) {
diff --git a/src/conf/network_conf.c b/src/conf/network_conf.c
index 847bf11..f391056 100644
--- a/src/conf/network_conf.c
+++ b/src/conf/network_conf.c
@@ -2851,7 +2851,7 @@ virNetworkObjFormat(virNetworkObjPtr net,
size_t i;
if (!class_id)
- goto no_memory;
+ goto error;
virBufferAddLit(&buf, "<networkstatus>\n");
virBufferAdjustIndent(&buf, 2);
diff --git a/src/lxc/lxc_cgroup.c b/src/lxc/lxc_cgroup.c
index c641132..8dfdc60 100644
--- a/src/lxc/lxc_cgroup.c
+++ b/src/lxc/lxc_cgroup.c
@@ -72,12 +72,8 @@ static int virLXCCgroupSetupCpusetTune(virDomainDefPtr def,
if (def->placement_mode != VIR_DOMAIN_CPU_PLACEMENT_MODE_AUTO &&
def->cpumask) {
- mask = virBitmapFormat(def->cpumask);
- if (!mask) {
- virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
- _("failed to convert cpumask"));
+ if (!(mask = virBitmapFormat(def->cpumask)))
return -1;
- }
if (virCgroupSetCpusetCpus(cgroup, mask) < 0)
goto cleanup;
@@ -93,11 +89,8 @@ static int virLXCCgroupSetupCpusetTune(virDomainDefPtr def,
else
mask = virBitmapFormat(def->numatune.memory.nodemask);
- if (!mask) {
- virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
- _("failed to convert memory nodemask"));
+ if (!mask)
return -1;
- }
if (virCgroupSetCpusetMems(cgroup, mask) < 0)
goto cleanup;
diff --git a/src/qemu/qemu_cgroup.c b/src/qemu/qemu_cgroup.c
index b1bfb5a..a31558f 100644
--- a/src/qemu/qemu_cgroup.c
+++ b/src/qemu/qemu_cgroup.c
@@ -599,11 +599,8 @@ qemuSetupCpusetCgroup(virDomainObjPtr vm,
else
mem_mask = virBitmapFormat(vm->def->numatune.memory.nodemask);
- if (!mem_mask) {
- virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
- _("failed to convert memory nodemask"));
+ if (!mem_mask)
goto cleanup;
- }
if (virCgroupSetCpusetMems(priv->cgroup, mem_mask) < 0)
goto cleanup;
@@ -622,11 +619,8 @@ qemuSetupCpusetCgroup(virDomainObjPtr vm,
cpu_mask = virBitmapFormat(vm->def->cpumask);
}
- if (!cpu_mask) {
- virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
- _("failed to convert cpu mask"));
+ if (!cpu_mask)
goto cleanup;
- }
if (virCgroupSetCpusetCpus(priv->cgroup, cpu_mask) < 0)
goto cleanup;
@@ -870,12 +864,8 @@ qemuSetupCgroupEmulatorPin(virCgroupPtr cgroup,
int ret = -1;
char *new_cpus = NULL;
- new_cpus = virBitmapFormat(cpumask);
- if (!new_cpus) {
- virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
- _("failed to convert cpu mask"));
+ if (!(new_cpus = virBitmapFormat(cpumask)))
goto cleanup;
- }
if (virCgroupSetCpusetCpus(cgroup, new_cpus) < 0)
goto cleanup;
diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
index 578c223..f9a243f 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -8679,22 +8679,16 @@ qemuDomainSetNumaParamsLive(virDomainObjPtr vm,
}
}
- if (!(nodeset_str = virBitmapFormat(temp_nodeset))) {
- virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
- _("Failed to format nodeset"));
+ if (!(nodeset_str = virBitmapFormat(temp_nodeset)))
goto cleanup;
- }
if (virCgroupSetCpusetMems(priv->cgroup, nodeset_str) < 0)
goto cleanup;
VIR_FREE(nodeset_str);
/* Ensure the cpuset string is formatted before passing to cgroup */
- if (!(nodeset_str = virBitmapFormat(nodeset))) {
- virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
- _("Failed to format nodeset"));
+ if (!(nodeset_str = virBitmapFormat(nodeset)))
goto cleanup;
- }
for (i = 0; i < priv->nvcpupids; i++) {
if (virCgroupNewVcpu(priv->cgroup, i, false, &cgroup_temp) < 0 ||
diff --git a/src/util/virbitmap.c b/src/util/virbitmap.c
index 1dc74cb..81aaa80 100644
--- a/src/util/virbitmap.c
+++ b/src/util/virbitmap.c
@@ -259,6 +259,7 @@ char *virBitmapFormat(virBitmapPtr bitmap)
if (virBufferError(&buf)) {
virBufferFreeAndReset(&buf);
+ virReportOOMError();
return NULL;
}
--
1.8.3.2