diff --git a/src/bhyve/bhyve_driver.c b/src/bhyve/bhyve_driver.c index eb5fc9590d..6c0c8b1ba3 100644 --- a/src/bhyve/bhyve_driver.c +++ b/src/bhyve/bhyve_driver.c @@ -150,10 +150,8 @@ bhyveConnectGetCapabilities(virConnectPtr conn) goto cleanup; } - if (!(xml = virCapabilitiesFormatXML(caps))) { - virReportOOMError(); + if (!(xml = virCapabilitiesFormatXML(caps))) goto cleanup; - } cleanup: virObjectUnref(caps); diff --git a/src/conf/capabilities.c b/src/conf/capabilities.c index 19359a57c6..8504d3442a 100644 --- a/src/conf/capabilities.c +++ b/src/conf/capabilities.c @@ -1025,10 +1025,8 @@ virCapabilitiesFormatXML(virCapsPtr caps) virBufferAdjustIndent(&buf, -2); virBufferAddLit(&buf, "\n"); - if (virBufferError(&buf)) { - virBufferFreeAndReset(&buf); + if (virBufferCheckError(&buf) < 0) return NULL; - } return virBufferContentAndReset(&buf); } diff --git a/src/esx/esx_driver.c b/src/esx/esx_driver.c index 5dd0a63f1d..48e0cd9b53 100644 --- a/src/esx/esx_driver.c +++ b/src/esx/esx_driver.c @@ -1420,14 +1420,8 @@ static char * esxConnectGetCapabilities(virConnectPtr conn) { esxPrivate *priv = conn->privateData; - char *xml = virCapabilitiesFormatXML(priv->caps); - if (!xml) { - virReportOOMError(); - return NULL; - } - - return xml; + return virCapabilitiesFormatXML(priv->caps); } diff --git a/src/libxl/libxl_driver.c b/src/libxl/libxl_driver.c index 646c9b9dcc..08faa1928c 100644 --- a/src/libxl/libxl_driver.c +++ b/src/libxl/libxl_driver.c @@ -594,8 +594,7 @@ libxlConnectGetCapabilities(virConnectPtr conn) return NULL; cfg = libxlDriverConfigGet(driver); - if ((xml = virCapabilitiesFormatXML(cfg->caps)) == NULL) - virReportOOMError(); + xml = virCapabilitiesFormatXML(cfg->caps); virObjectUnref(cfg); return xml; diff --git a/src/lxc/lxc_driver.c b/src/lxc/lxc_driver.c index a9a87eab8e..24255fc585 100644 --- a/src/lxc/lxc_driver.c +++ b/src/lxc/lxc_driver.c @@ -232,8 +232,7 @@ static char *lxcConnectGetCapabilities(virConnectPtr conn) { if (!(caps = virLXCDriverGetCapabilities(driver, false))) return NULL; - if ((xml = virCapabilitiesFormatXML(caps)) == NULL) - virReportOOMError(); + xml = virCapabilitiesFormatXML(caps); virObjectUnref(caps); return xml; diff --git a/src/parallels/parallels_driver.c b/src/parallels/parallels_driver.c index 411527c03f..b388e2d77c 100644 --- a/src/parallels/parallels_driver.c +++ b/src/parallels/parallels_driver.c @@ -186,8 +186,7 @@ parallelsConnectGetCapabilities(virConnectPtr conn) char *xml; parallelsDriverLock(privconn); - if ((xml = virCapabilitiesFormatXML(privconn->caps)) == NULL) - virReportOOMError(); + xml = virCapabilitiesFormatXML(privconn->caps); parallelsDriverUnlock(privconn); return xml; } diff --git a/src/phyp/phyp_driver.c b/src/phyp/phyp_driver.c index 508e4c0d8c..659f8db3f4 100644 --- a/src/phyp/phyp_driver.c +++ b/src/phyp/phyp_driver.c @@ -3582,12 +3582,8 @@ static char * phypConnectGetCapabilities(virConnectPtr conn) { phyp_driverPtr phyp_driver = conn->privateData; - char *xml; - if ((xml = virCapabilitiesFormatXML(phyp_driver->caps)) == NULL) - virReportOOMError(); - - return xml; + return virCapabilitiesFormatXML(phyp_driver->caps); } static int diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index d45a16107a..fd91d15ec7 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -1245,8 +1245,7 @@ static char *qemuConnectGetCapabilities(virConnectPtr conn) { if (!(caps = virQEMUDriverGetCapabilities(driver, true))) goto cleanup; - if ((xml = virCapabilitiesFormatXML(caps)) == NULL) - virReportOOMError(); + xml = virCapabilitiesFormatXML(caps); virObjectUnref(caps); cleanup: diff --git a/src/test/test_driver.c b/src/test/test_driver.c index 0bf710a1ab..7bfc88d981 100644 --- a/src/test/test_driver.c +++ b/src/test/test_driver.c @@ -1677,8 +1677,7 @@ static char *testConnectGetCapabilities(virConnectPtr conn) testConnPtr privconn = conn->privateData; char *xml; testDriverLock(privconn); - if ((xml = virCapabilitiesFormatXML(privconn->caps)) == NULL) - virReportOOMError(); + xml = virCapabilitiesFormatXML(privconn->caps); testDriverUnlock(privconn); return xml; } diff --git a/src/uml/uml_driver.c b/src/uml/uml_driver.c index f14cfaa0aa..62d1afe2e2 100644 --- a/src/uml/uml_driver.c +++ b/src/uml/uml_driver.c @@ -1310,8 +1310,7 @@ static char *umlConnectGetCapabilities(virConnectPtr conn) { return NULL; umlDriverLock(driver); - if ((xml = virCapabilitiesFormatXML(driver->caps)) == NULL) - virReportOOMError(); + xml = virCapabilitiesFormatXML(driver->caps); umlDriverUnlock(driver); return xml; diff --git a/src/xen/xen_driver.c b/src/xen/xen_driver.c index 8c0050acb2..9355a4e185 100644 --- a/src/xen/xen_driver.c +++ b/src/xen/xen_driver.c @@ -720,17 +720,11 @@ static char * xenUnifiedConnectGetCapabilities(virConnectPtr conn) { xenUnifiedPrivatePtr priv = conn->privateData; - char *xml; if (virConnectGetCapabilitiesEnsureACL(conn) < 0) return NULL; - if (!(xml = virCapabilitiesFormatXML(priv->caps))) { - virReportOOMError(); - return NULL; - } - - return xml; + return virCapabilitiesFormatXML(priv->caps); } static int diff --git a/src/xen/xen_hypervisor.c b/src/xen/xen_hypervisor.c index 2e35edfa61..524b21f34a 100644 --- a/src/xen/xen_hypervisor.c +++ b/src/xen/xen_hypervisor.c @@ -2557,14 +2557,8 @@ char * xenHypervisorGetCapabilities(virConnectPtr conn) { xenUnifiedPrivatePtr priv = conn->privateData; - char *xml; - if (!(xml = virCapabilitiesFormatXML(priv->caps))) { - virReportOOMError(); - return NULL; - } - - return xml; + return virCapabilitiesFormatXML(priv->caps); } diff --git a/src/xenapi/xenapi_driver.c b/src/xenapi/xenapi_driver.c index 500b78a1a8..e3bb77e398 100644 --- a/src/xenapi/xenapi_driver.c +++ b/src/xenapi/xenapi_driver.c @@ -445,12 +445,8 @@ xenapiConnectGetCapabilities(virConnectPtr conn) { virCapsPtr caps = ((struct _xenapiPrivate *)(conn->privateData))->caps; - if (caps) { - char *xml = virCapabilitiesFormatXML(caps); - if (!xml) - goto cleanup; - return xml; - } + if (caps) + return virCapabilitiesFormatXML(caps); cleanup: xenapiSessionErrorHandler(conn, VIR_ERR_INTERNAL_ERROR, _("Capabilities not available")); diff --git a/tests/vircaps2xmltest.c b/tests/vircaps2xmltest.c index 7166c98e69..d8b61aa972 100644 --- a/tests/vircaps2xmltest.c +++ b/tests/vircaps2xmltest.c @@ -114,10 +114,8 @@ test_virCapabilitiesFormat(const void *opaque) data->max_mem_in_cell))) goto cleanup; - if (!(capsXML = virCapabilitiesFormatXML(caps))) { - fprintf(stderr, "Unable to format capabilities XML"); + if (!(capsXML = virCapabilitiesFormatXML(caps))) goto cleanup; - } if (virAsprintf(&path, "%s/vircaps2xmldata/vircaps-%s.xml", abs_srcdir, data->filename) < 0)