[PATCH 08/12] Use virBufferCheckError everywhere we report OOM error

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Replace:
if (virBufferError(&buf)) {
    virBufferFreeAndReset(&buf);
    virReportOOMError();
    ...
}

with:
if (virBufferCheckError(&buf) < 0)
    ...

This should not be a functional change (unless some callers
misused the virBuffer APIs - a different error would be reported
then)
---
 src/bhyve/bhyve_driver.c                  |   8 +-
 src/conf/cpu_conf.c                       |   6 +-
 src/conf/domain_conf.c                    |  17 ++--
 src/conf/interface_conf.c                 |   8 +-
 src/conf/network_conf.c                   |  12 +--
 src/conf/node_device_conf.c               |   9 +-
 src/conf/nwfilter_conf.c                  |  16 +---
 src/conf/secret_conf.c                    |   6 +-
 src/conf/snapshot_conf.c                  |   5 +-
 src/conf/storage_conf.c                   |  18 ++--
 src/cpu/cpu_map.c                         |  14 ++-
 src/cpu/cpu_x86.c                         |   5 +-
 src/esx/esx_driver.c                      |  12 +--
 src/esx/esx_util.c                        |  12 +--
 src/esx/esx_vi.c                          |  20 ++---
 src/esx/esx_vi_methods.c                  |   4 +-
 src/hyperv/hyperv_wmi.c                   |   4 +-
 src/libxl/libxl_driver.c                  |   4 +-
 src/locking/lock_driver_sanlock.c         |   5 +-
 src/lxc/lxc_controller.c                  |   8 +-
 src/lxc/lxc_driver.c                      |  44 +++------
 src/network/bridge_driver.c               |   8 +-
 src/node_device/node_device_udev.c        |   8 +-
 src/nwfilter/nwfilter_ebiptables_driver.c |  10 +--
 src/nwfilter/nwfilter_gentech_driver.c    |   5 +-
 src/phyp/phyp_driver.c                    |  10 +--
 src/qemu/qemu_command.c                   | 142 ++++++++----------------------
 src/qemu/qemu_driver.c                    |  44 +++------
 src/qemu/qemu_migration.c                 |   5 +-
 src/qemu/qemu_monitor.c                   |   5 +-
 src/qemu/qemu_monitor_text.c              |   9 +-
 src/rpc/virnetsocket.c                    |   4 +-
 src/rpc/virnetsshsession.c                |   8 +-
 src/storage/storage_backend.c             |   6 +-
 src/storage/storage_backend_rbd.c         |   6 +-
 src/uml/uml_conf.c                        |   4 +-
 src/util/vircommand.c                     |   5 +-
 src/util/virconf.c                        |  10 +--
 src/util/virnetdevopenvswitch.c           |   4 +-
 src/util/virstoragefile.c                 |   4 +-
 src/util/virstring.c                      |   8 +-
 src/util/virsysinfo.c                     |   4 +-
 src/util/virsystemd.c                     |   8 +-
 src/util/viruri.c                         |   5 +-
 src/vmx/vmx.c                             |   4 +-
 src/xen/xen_driver.c                      |   4 +-
 src/xen/xend_internal.c                   |   9 +-
 src/xenapi/xenapi_utils.c                 |   5 +-
 src/xenxs/xen_sxpr.c                      |  12 +--
 src/xenxs/xen_xm.c                        |  17 +---
 tests/domainsnapshotxml2xmltest.c         |   4 +-
 51 files changed, 158 insertions(+), 456 deletions(-)

diff --git a/src/bhyve/bhyve_driver.c b/src/bhyve/bhyve_driver.c
index 6c0c8b1..a3b043d 100644
--- a/src/bhyve/bhyve_driver.c
+++ b/src/bhyve/bhyve_driver.c
@@ -258,10 +258,8 @@ bhyveConnectGetSysinfo(virConnectPtr conn, unsigned int flags)
 
     if (virSysinfoFormat(&buf, privconn->hostsysinfo) < 0)
         return NULL;
-    if (virBufferError(&buf)) {
-        virReportOOMError();
+    if (virBufferCheckError(&buf) < 0)
         return NULL;
-    }
 
     return virBufferContentAndReset(&buf);
 }
@@ -701,10 +699,8 @@ bhyveConnectDomainXMLToNative(virConnectPtr conn,
     virBufferAddChar(&buf, '\n');
     virBufferAdd(&buf, virCommandToString(cmd), -1);
 
-    if (virBufferError(&buf)) {
-        virReportOOMError();
+    if (virBufferCheckError(&buf) < 0)
         goto cleanup;
-    }
 
     ret = virBufferContentAndReset(&buf);
 
diff --git a/src/conf/cpu_conf.c b/src/conf/cpu_conf.c
index ebdaa19..811893d 100644
--- a/src/conf/cpu_conf.c
+++ b/src/conf/cpu_conf.c
@@ -494,13 +494,11 @@ virCPUDefFormat(virCPUDefPtr def,
     if (virCPUDefFormatBufFull(&buf, def, flags) < 0)
         goto cleanup;
 
-    if (virBufferError(&buf))
-        goto no_memory;
+    if (virBufferCheckError(&buf) < 0)
+        goto cleanup;
 
     return virBufferContentAndReset(&buf);
 
- no_memory:
-    virReportOOMError();
  cleanup:
     virBufferFreeAndReset(&buf);
     return NULL;
diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index f7fe64b..e1ce585 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -11335,11 +11335,8 @@ virDomainDefParseXML(xmlDocPtr xml,
                 }
             }
 
-            if (virBufferError(&buffer)) {
-                virReportOOMError();
-                virBufferFreeAndReset(&buffer);
+            if (virBufferCheckError(&buffer) < 0)
                 goto error;
-            }
 
             string = virBufferContentAndReset(&buffer);
 
@@ -17972,13 +17969,11 @@ virDomainDefFormatInternal(virDomainDefPtr def,
     virBufferAdjustIndent(buf, -2);
     virBufferAddLit(buf, "</domain>\n");
 
-    if (virBufferError(buf))
-        goto no_memory;
+    if (virBufferCheckError(buf) < 0)
+        goto error;
 
     return 0;
 
- no_memory:
-    virReportOOMError();
  error:
     virBufferFreeAndReset(buf);
     return -1;
@@ -18030,13 +18025,11 @@ virDomainObjFormat(virDomainXMLOptionPtr xmlopt,
     virBufferAdjustIndent(&buf, -2);
     virBufferAddLit(&buf, "</domstatus>\n");
 
-    if (virBufferError(&buf))
-        goto no_memory;
+    if (virBufferCheckError(&buf) < 0)
+        goto error;
 
     return virBufferContentAndReset(&buf);
 
- no_memory:
-    virReportOOMError();
  error:
     virBufferFreeAndReset(&buf);
     return NULL;
diff --git a/src/conf/interface_conf.c b/src/conf/interface_conf.c
index 141b4a2..103e878 100644
--- a/src/conf/interface_conf.c
+++ b/src/conf/interface_conf.c
@@ -1101,11 +1101,11 @@ virInterfaceDefDevFormat(virBufferPtr buf, const virInterfaceDef *def,
     virBufferAdjustIndent(buf, -2);
     virBufferAddLit(buf, "</interface>\n");
 
-    if (virBufferError(buf))
-        goto no_memory;
+    if (virBufferCheckError(buf) < 0)
+        goto cleanup;
+
     return 0;
- no_memory:
-    virReportOOMError();
+
  cleanup:
     return -1;
 }
diff --git a/src/conf/network_conf.c b/src/conf/network_conf.c
index f391056..909631b 100644
--- a/src/conf/network_conf.c
+++ b/src/conf/network_conf.c
@@ -2830,13 +2830,11 @@ virNetworkDefFormat(const virNetworkDef *def,
     if (virNetworkDefFormatBuf(&buf, def, flags) < 0)
         goto error;
 
-    if (virBufferError(&buf))
-        goto no_memory;
+    if (virBufferCheckError(&buf) < 0)
+        goto error;
 
     return virBufferContentAndReset(&buf);
 
- no_memory:
-    virReportOOMError();
  error:
     virBufferFreeAndReset(&buf);
     return NULL;
@@ -2871,13 +2869,11 @@ virNetworkObjFormat(virNetworkObjPtr net,
     virBufferAdjustIndent(&buf, -2);
     virBufferAddLit(&buf, "</networkstatus>");
 
-    if (virBufferError(&buf))
-        goto no_memory;
+    if (virBufferCheckError(&buf) < 0)
+        goto error;
 
     return virBufferContentAndReset(&buf);
 
- no_memory:
-    virReportOOMError();
  error:
     virBufferFreeAndReset(&buf);
     return NULL;
diff --git a/src/conf/node_device_conf.c b/src/conf/node_device_conf.c
index cb85914..30aa477 100644
--- a/src/conf/node_device_conf.c
+++ b/src/conf/node_device_conf.c
@@ -555,15 +555,10 @@ char *virNodeDeviceDefFormat(const virNodeDeviceDef *def)
     virBufferAdjustIndent(&buf, -2);
     virBufferAddLit(&buf, "</device>\n");
 
-    if (virBufferError(&buf))
-        goto no_memory;
+    if (virBufferCheckError(&buf) < 0)
+        return NULL;
 
     return virBufferContentAndReset(&buf);
-
- no_memory:
-    virReportOOMError();
-    virBufferFreeAndReset(&buf);
-    return NULL;
 }
 
 /**
diff --git a/src/conf/nwfilter_conf.c b/src/conf/nwfilter_conf.c
index c675967..0f633da 100644
--- a/src/conf/nwfilter_conf.c
+++ b/src/conf/nwfilter_conf.c
@@ -967,10 +967,8 @@ virNWFilterPrintTCPFlags(uint8_t flags)
 {
     virBuffer buf = VIR_BUFFER_INITIALIZER;
     printTCPFlags(&buf, flags);
-    if (virBufferError(&buf)) {
-        virReportOOMError();
+    if (virBufferCheckError(&buf) < 0)
         return NULL;
-    }
     return virBufferContentAndReset(&buf);
 }
 
@@ -2548,11 +2546,8 @@ virNWFilterIsAllowedChain(const char *chainname)
         printed = true;
     }
 
-    if (virBufferError(&buf)) {
-        virReportOOMError();
-        virBufferFreeAndReset(&buf);
+    if (virBufferCheckError(&buf) < 0)
         goto err_exit;
-    }
 
     msg = virBufferContentAndReset(&buf);
 
@@ -3484,14 +3479,11 @@ virNWFilterDefFormat(const virNWFilterDef *def)
     virBufferAdjustIndent(&buf, -2);
     virBufferAddLit(&buf, "</filter>\n");
 
-    if (virBufferError(&buf))
-        goto no_memory;
+    if (virBufferCheckError(&buf) < 0)
+        goto err_exit;
 
     return virBufferContentAndReset(&buf);
 
- no_memory:
-    virReportOOMError();
-
  err_exit:
     virBufferFreeAndReset(&buf);
     return NULL;
diff --git a/src/conf/secret_conf.c b/src/conf/secret_conf.c
index d85bb4e..f958240 100644
--- a/src/conf/secret_conf.c
+++ b/src/conf/secret_conf.c
@@ -318,13 +318,11 @@ virSecretDefFormat(const virSecretDef *def)
     virBufferAdjustIndent(&buf, -2);
     virBufferAddLit(&buf, "</secret>\n");
 
-    if (virBufferError(&buf))
-        goto no_memory;
+    if (virBufferCheckError(&buf) < 0)
+        goto error;
 
     return virBufferContentAndReset(&buf);
 
- no_memory:
-    virReportOOMError();
  error:
     virBufferFreeAndReset(&buf);
     return NULL;
diff --git a/src/conf/snapshot_conf.c b/src/conf/snapshot_conf.c
index 441162c..240ca90 100644
--- a/src/conf/snapshot_conf.c
+++ b/src/conf/snapshot_conf.c
@@ -705,11 +705,8 @@ char *virDomainSnapshotDefFormat(const char *domain_uuid,
     virBufferAdjustIndent(&buf, -2);
     virBufferAddLit(&buf, "</domainsnapshot>\n");
 
-    if (virBufferError(&buf)) {
-        virBufferFreeAndReset(&buf);
-        virReportOOMError();
+    if (virBufferCheckError(&buf) < 0)
         return NULL;
-    }
 
     return virBufferContentAndReset(&buf);
 }
diff --git a/src/conf/storage_conf.c b/src/conf/storage_conf.c
index c8df5b2..8cf470b 100644
--- a/src/conf/storage_conf.c
+++ b/src/conf/storage_conf.c
@@ -1239,13 +1239,11 @@ virStoragePoolDefFormat(virStoragePoolDefPtr def)
     virBufferAdjustIndent(&buf, -2);
     virBufferAddLit(&buf, "</pool>\n");
 
-    if (virBufferError(&buf))
-        goto no_memory;
+    if (virBufferCheckError(&buf) < 0)
+        goto cleanup;
 
     return virBufferContentAndReset(&buf);
 
- no_memory:
-    virReportOOMError();
  cleanup:
     virBufferFreeAndReset(&buf);
     return NULL;
@@ -1662,13 +1660,11 @@ virStorageVolDefFormat(virStoragePoolDefPtr pool,
     virBufferAdjustIndent(&buf, -2);
     virBufferAddLit(&buf, "</volume>\n");
 
-    if (virBufferError(&buf))
-        goto no_memory;
+    if (virBufferCheckError(&buf) < 0)
+        goto cleanup;
 
     return virBufferContentAndReset(&buf);
 
- no_memory:
-    virReportOOMError();
  cleanup:
     virBufferFreeAndReset(&buf);
     return NULL;
@@ -2013,13 +2009,11 @@ virStoragePoolSourceListFormat(virStoragePoolSourceListPtr def)
     virBufferAdjustIndent(&buf, -2);
     virBufferAddLit(&buf, "</sources>\n");
 
-    if (virBufferError(&buf))
-        goto no_memory;
+    if (virBufferCheckError(&buf) < 0)
+        goto cleanup;
 
     return virBufferContentAndReset(&buf);
 
- no_memory:
-    virReportOOMError();
  cleanup:
     virBufferFreeAndReset(&buf);
     return NULL;
diff --git a/src/cpu/cpu_map.c b/src/cpu/cpu_map.c
index 4706f67..b77f688 100644
--- a/src/cpu/cpu_map.c
+++ b/src/cpu/cpu_map.c
@@ -112,12 +112,14 @@ int cpuMapLoad(const char *arch,
         goto cleanup;
     }
 
-    if ((ctxt = xmlXPathNewContext(xml)) == NULL)
-        goto no_memory;
+    if ((ctxt = xmlXPathNewContext(xml)) == NULL) {
+        virReportOOMError();
+        goto cleanup;
+    }
 
     virBufferAsprintf(&buf, "./arch[@name='%s']", arch);
-    if (virBufferError(&buf))
-        goto no_memory;
+    if (virBufferCheckError(&buf) < 0)
+        goto cleanup;
 
     xpath = virBufferContentAndReset(&buf);
 
@@ -146,8 +148,4 @@ int cpuMapLoad(const char *arch,
     VIR_FREE(mapfile);
 
     return ret;
-
- no_memory:
-    virReportOOMError();
-    goto cleanup;
 }
diff --git a/src/cpu/cpu_x86.c b/src/cpu/cpu_x86.c
index 235fa49..fb89086 100644
--- a/src/cpu/cpu_x86.c
+++ b/src/cpu/cpu_x86.c
@@ -1221,11 +1221,8 @@ x86CPUDataFormat(const virCPUData *data)
     }
     virBufferAddLit(&buf, "</cpudata>\n");
 
-    if (virBufferError(&buf)) {
-        virBufferFreeAndReset(&buf);
-        virReportOOMError();
+    if (virBufferCheckError(&buf) < 0)
         return NULL;
-    }
 
     return virBufferContentAndReset(&buf);
 }
diff --git a/src/esx/esx_driver.c b/src/esx/esx_driver.c
index 48e0cd9..d2cc230 100644
--- a/src/esx/esx_driver.c
+++ b/src/esx/esx_driver.c
@@ -340,10 +340,8 @@ esxFormatVMXFileName(const char *fileName, void *opaque)
         virBufferAddChar(&buffer, separator);
         virBufferAdd(&buffer, directoryAndFileName, -1);
 
-        if (virBufferError(&buffer)) {
-            virReportOOMError();
+        if (virBufferCheckError(&buffer) < 0)
             goto cleanup;
-        }
 
         result = virBufferContentAndReset(&buffer);
     } else if (*fileName == '/') {
@@ -2701,10 +2699,8 @@ esxDomainGetXMLDesc(virDomainPtr domain, unsigned int flags)
     virBufferAddLit(&buffer, "&dsName=");
     virBufferURIEncodeString(&buffer, datastoreName);
 
-    if (virBufferError(&buffer)) {
-        virReportOOMError();
+    if (virBufferCheckError(&buffer) < 0)
         goto cleanup;
-    }
 
     url = virBufferContentAndReset(&buffer);
 
@@ -3169,10 +3165,8 @@ esxDomainDefineXML(virConnectPtr conn, const char *xml)
     virBufferAddLit(&buffer, "&dsName=");
     virBufferURIEncodeString(&buffer, datastoreName);
 
-    if (virBufferError(&buffer)) {
-        virReportOOMError();
+    if (virBufferCheckError(&buffer) < 0)
         goto cleanup;
-    }
 
     url = virBufferContentAndReset(&buffer);
 
diff --git a/src/esx/esx_util.c b/src/esx/esx_util.c
index f84ecd5..9a41241 100644
--- a/src/esx/esx_util.c
+++ b/src/esx/esx_util.c
@@ -425,12 +425,8 @@ esxUtil_EscapeBase64(const char *string)
         }
     }
 
-    if (virBufferError(&buffer)) {
-        virReportOOMError();
-        virBufferFreeAndReset(&buffer);
-
+    if (virBufferCheckError(&buffer) < 0)
         return NULL;
-    }
 
     return virBufferContentAndReset(&buffer);
 }
@@ -498,12 +494,8 @@ esxUtil_EscapeForXml(const char *string)
 
     virBufferEscapeString(&buffer, "%s", string);
 
-    if (virBufferError(&buffer)) {
-        virReportOOMError();
-        virBufferFreeAndReset(&buffer);
-
+    if (virBufferCheckError(&buffer) < 0)
         return NULL;
-    }
 
     return virBufferContentAndReset(&buffer);
 }
diff --git a/src/esx/esx_vi.c b/src/esx/esx_vi.c
index 6188139..3f5becb 100644
--- a/src/esx/esx_vi.c
+++ b/src/esx/esx_vi.c
@@ -426,10 +426,8 @@ esxVI_CURL_Download(esxVI_CURL *curl, const char *url, char **content,
         goto cleanup;
     }
 
-    if (virBufferError(&buffer)) {
-        virReportOOMError();
+    if (virBufferCheckError(&buffer) < 0)
         goto cleanup;
-    }
 
     if (length) {
         *length = virBufferUse(&buffer);
@@ -1046,10 +1044,8 @@ esxVI_Context_LookupManagedObjectsByPath(esxVI_Context *ctx, const char *path)
         goto cleanup;
     }
 
-    if (virBufferError(&buffer)) {
-        virReportOOMError();
+    if (virBufferCheckError(&buffer) < 0)
         goto cleanup;
-    }
 
     ctx->datacenterPath = virBufferContentAndReset(&buffer);
 
@@ -1116,10 +1112,8 @@ esxVI_Context_LookupManagedObjectsByPath(esxVI_Context *ctx, const char *path)
         goto cleanup;
     }
 
-    if (virBufferError(&buffer)) {
-        virReportOOMError();
+    if (virBufferCheckError(&buffer) < 0)
         goto cleanup;
-    }
 
     ctx->computeResourcePath = virBufferContentAndReset(&buffer);
 
@@ -1259,10 +1253,8 @@ esxVI_Context_Execute(esxVI_Context *ctx, const char *methodName,
         goto cleanup;
     }
 
-    if (virBufferError(&buffer)) {
-        virReportOOMError();
+    if (virBufferCheckError(&buffer) < 0)
         goto cleanup;
-    }
 
     (*response)->content = virBufferContentAndReset(&buffer);
 
@@ -4243,10 +4235,8 @@ esxVI_HandleVirtualMachineQuestion
             ++answerIndex;
         }
 
-        if (virBufferError(&buffer)) {
-            virReportOOMError();
+        if (virBufferCheckError(&buffer) < 0)
             goto cleanup;
-        }
 
         possibleAnswers = virBufferContentAndReset(&buffer);
     }
diff --git a/src/esx/esx_vi_methods.c b/src/esx/esx_vi_methods.c
index 0fdd0cd..184b01f 100644
--- a/src/esx/esx_vi_methods.c
+++ b/src/esx/esx_vi_methods.c
@@ -126,10 +126,8 @@
         virBufferAddLit(&buffer, "</"#_name">");                              \
         virBufferAddLit(&buffer, ESX_VI__SOAP__REQUEST_FOOTER);               \
                                                                               \
-        if (virBufferError(&buffer)) {                                        \
-            virReportOOMError();                                              \
+        if (virBufferCheckError(&buffer) < 0)                                 \
             goto cleanup;                                                     \
-        }                                                                     \
                                                                               \
         request = virBufferContentAndReset(&buffer);                          \
                                                                               \
diff --git a/src/hyperv/hyperv_wmi.c b/src/hyperv/hyperv_wmi.c
index 6e6f629..acb705c 100644
--- a/src/hyperv/hyperv_wmi.c
+++ b/src/hyperv/hyperv_wmi.c
@@ -128,10 +128,8 @@ hypervEnumAndPull(hypervPrivate *priv, virBufferPtr query, const char *root,
         return -1;
     }
 
-    if (virBufferError(query)) {
-        virReportOOMError();
+    if (virBufferCheckError(query) < 0)
         return -1;
-    }
 
     serializerContext = wsmc_get_serialization_context(priv->client);
 
diff --git a/src/libxl/libxl_driver.c b/src/libxl/libxl_driver.c
index 08faa19..f195b7e 100644
--- a/src/libxl/libxl_driver.c
+++ b/src/libxl/libxl_driver.c
@@ -544,10 +544,8 @@ libxlConnectGetSysinfo(virConnectPtr conn, unsigned int flags)
 
     if (virSysinfoFormat(&buf, driver->hostsysinfo) < 0)
         return NULL;
-    if (virBufferError(&buf)) {
-        virReportOOMError();
+    if (virBufferCheckError(&buf) < 0)
         return NULL;
-    }
     return virBufferContentAndReset(&buf);
 }
 
diff --git a/src/locking/lock_driver_sanlock.c b/src/locking/lock_driver_sanlock.c
index d0339a6..ea43051 100644
--- a/src/locking/lock_driver_sanlock.c
+++ b/src/locking/lock_driver_sanlock.c
@@ -819,11 +819,8 @@ virLockManagerSanlockRegisterKillscript(int sock,
     virBufferEscape(&buf, '\\', "\\ ", "%s",
                     virDomainLockFailureTypeToString(action));
 
-    if (virBufferError(&buf)) {
-        virBufferFreeAndReset(&buf);
-        virReportOOMError();
+    if (virBufferCheckError(&buf) < 0)
         goto cleanup;
-    }
 
     /* Unfortunately, sanlock_killpath() does not use const for either
      * path or args even though it will just copy them into its own
diff --git a/src/lxc/lxc_controller.c b/src/lxc/lxc_controller.c
index 38acdff..bc1b962 100644
--- a/src/lxc/lxc_controller.c
+++ b/src/lxc/lxc_controller.c
@@ -1181,8 +1181,8 @@ virLXCControllerSetupUsernsMap(virDomainIdMapEntryPtr map,
         virBufferAsprintf(&map_value, "%u %u %u\n",
                           map[i].start, map[i].target, map[i].count);
 
-    if (virBufferError(&map_value))
-        goto no_memory;
+    if (virBufferCheckError(&map_value) < 0)
+        goto cleanup;
 
     VIR_DEBUG("Set '%s' to '%s'", path, virBufferCurrentContent(&map_value));
 
@@ -1195,10 +1195,6 @@ virLXCControllerSetupUsernsMap(virDomainIdMapEntryPtr map,
  cleanup:
     virBufferFreeAndReset(&map_value);
     return ret;
-
- no_memory:
-    virReportOOMError();
-    goto cleanup;
 }
 
 /**
diff --git a/src/lxc/lxc_driver.c b/src/lxc/lxc_driver.c
index f2bbd5e..7f2655b 100644
--- a/src/lxc/lxc_driver.c
+++ b/src/lxc/lxc_driver.c
@@ -2738,10 +2738,8 @@ lxcDomainGetBlkioParameters(virDomainPtr dom,
                                           vm->def->blkio.devices[j].path,
                                           vm->def->blkio.devices[j].weight);
                     }
-                    if (virBufferError(&buf)) {
-                        virReportOOMError();
+                    if (virBufferCheckError(&buf) < 0)
                         goto cleanup;
-                    }
                     param->value.s = virBufferContentAndReset(&buf);
                 }
                 if (virTypedParameterAssign(param,
@@ -2767,10 +2765,8 @@ lxcDomainGetBlkioParameters(virDomainPtr dom,
                                           vm->def->blkio.devices[j].path,
                                           vm->def->blkio.devices[j].riops);
                     }
-                    if (virBufferError(&buf)) {
-                        virReportOOMError();
+                    if (virBufferCheckError(&buf) < 0)
                         goto cleanup;
-                    }
                     param->value.s = virBufferContentAndReset(&buf);
                 }
                 if (virTypedParameterAssign(param,
@@ -2796,10 +2792,8 @@ lxcDomainGetBlkioParameters(virDomainPtr dom,
                                           vm->def->blkio.devices[j].path,
                                           vm->def->blkio.devices[j].wiops);
                     }
-                    if (virBufferError(&buf)) {
-                        virReportOOMError();
+                    if (virBufferCheckError(&buf) < 0)
                         goto cleanup;
-                    }
                     param->value.s = virBufferContentAndReset(&buf);
                 }
                 if (virTypedParameterAssign(param,
@@ -2825,10 +2819,8 @@ lxcDomainGetBlkioParameters(virDomainPtr dom,
                                           vm->def->blkio.devices[j].path,
                                           vm->def->blkio.devices[j].rbps);
                     }
-                    if (virBufferError(&buf)) {
-                        virReportOOMError();
+                    if (virBufferCheckError(&buf) < 0)
                         goto cleanup;
-                    }
                     param->value.s = virBufferContentAndReset(&buf);
                 }
                 if (virTypedParameterAssign(param,
@@ -2854,10 +2846,8 @@ lxcDomainGetBlkioParameters(virDomainPtr dom,
                                           vm->def->blkio.devices[j].path,
                                           vm->def->blkio.devices[j].wbps);
                     }
-                    if (virBufferError(&buf)) {
-                        virReportOOMError();
+                    if (virBufferCheckError(&buf) < 0)
                         goto cleanup;
-                    }
                     param->value.s = virBufferContentAndReset(&buf);
                 }
                 if (virTypedParameterAssign(param,
@@ -2902,10 +2892,8 @@ lxcDomainGetBlkioParameters(virDomainPtr dom,
                                           persistentDef->blkio.devices[j].path,
                                           persistentDef->blkio.devices[j].weight);
                     }
-                    if (virBufferError(&buf)) {
-                        virReportOOMError();
+                    if (virBufferCheckError(&buf) < 0)
                         goto cleanup;
-                    }
                     param->value.s = virBufferContentAndReset(&buf);
                 }
                 if (!param->value.s && VIR_STRDUP(param->value.s, "") < 0)
@@ -2936,10 +2924,8 @@ lxcDomainGetBlkioParameters(virDomainPtr dom,
                                           persistentDef->blkio.devices[j].path,
                                           persistentDef->blkio.devices[j].riops);
                     }
-                    if (virBufferError(&buf)) {
-                        virReportOOMError();
+                    if (virBufferCheckError(&buf) < 0)
                         goto cleanup;
-                    }
                     param->value.s = virBufferContentAndReset(&buf);
                 }
                 if (!param->value.s && VIR_STRDUP(param->value.s, "") < 0)
@@ -2969,10 +2955,8 @@ lxcDomainGetBlkioParameters(virDomainPtr dom,
                                           persistentDef->blkio.devices[j].path,
                                           persistentDef->blkio.devices[j].wiops);
                     }
-                    if (virBufferError(&buf)) {
-                        virReportOOMError();
+                    if (virBufferCheckError(&buf) < 0)
                         goto cleanup;
-                    }
                     param->value.s = virBufferContentAndReset(&buf);
                 }
                 if (!param->value.s && VIR_STRDUP(param->value.s, "") < 0)
@@ -3002,10 +2986,8 @@ lxcDomainGetBlkioParameters(virDomainPtr dom,
                                           persistentDef->blkio.devices[j].path,
                                           persistentDef->blkio.devices[j].rbps);
                     }
-                    if (virBufferError(&buf)) {
-                        virReportOOMError();
+                    if (virBufferCheckError(&buf) < 0)
                         goto cleanup;
-                    }
                     param->value.s = virBufferContentAndReset(&buf);
                 }
                 if (!param->value.s && VIR_STRDUP(param->value.s, "") < 0)
@@ -3036,10 +3018,8 @@ lxcDomainGetBlkioParameters(virDomainPtr dom,
                                           persistentDef->blkio.devices[j].path,
                                           persistentDef->blkio.devices[j].wbps);
                     }
-                    if (virBufferError(&buf)) {
-                        virReportOOMError();
+                    if (virBufferCheckError(&buf) < 0)
                         goto cleanup;
-                    }
                     param->value.s = virBufferContentAndReset(&buf);
                 }
                 if (!param->value.s && VIR_STRDUP(param->value.s, "") < 0)
@@ -5363,10 +5343,8 @@ lxcConnectGetSysinfo(virConnectPtr conn, unsigned int flags)
 
     if (virSysinfoFormat(&buf, driver->hostsysinfo) < 0)
         return NULL;
-    if (virBufferError(&buf)) {
-        virReportOOMError();
+    if (virBufferCheckError(&buf) < 0)
         return NULL;
-    }
     return virBufferContentAndReset(&buf);
 }
 
diff --git a/src/network/bridge_driver.c b/src/network/bridge_driver.c
index 149a8fd..6a2e760 100644
--- a/src/network/bridge_driver.c
+++ b/src/network/bridge_driver.c
@@ -180,10 +180,10 @@ networkRunHook(virNetworkObjPtr network,
         virBufferAdjustIndent(&buf, -2);
         virBufferAddLit(&buf, "</hookData>");
 
-        if (virBufferError(&buf) ||
-            !(xml = virBufferContentAndReset(&buf)))
+        if (virBufferCheckError(&buf) < 0)
             goto cleanup;
 
+        xml = virBufferContentAndReset(&buf);
         hookret = virHookCall(VIR_HOOK_DRIVER_NETWORK, network->def->name,
                               op, sub_op, NULL, xml, NULL);
 
@@ -1537,10 +1537,8 @@ networkRadvdConfContents(virNetworkObjPtr network, char **configstr)
 
     virBufferAddLit(&configbuf, "};\n");
 
-    if (virBufferError(&configbuf)) {
-        virReportOOMError();
+    if (virBufferCheckError(&configbuf) < 0)
         goto cleanup;
-    }
 
     *configstr = virBufferContentAndReset(&configbuf);
 
diff --git a/src/node_device/node_device_udev.c b/src/node_device/node_device_udev.c
index 8a2e5ff..28d2953 100644
--- a/src/node_device/node_device_udev.c
+++ b/src/node_device/node_device_udev.c
@@ -333,12 +333,8 @@ static int udevGenerateDeviceName(struct udev_device *device,
         virBufferAsprintf(&buf, "_%s", s);
     }
 
-    if (virBufferError(&buf)) {
-        virBufferFreeAndReset(&buf);
-        VIR_ERROR(_("Buffer error when generating device name for device "
-                    "with sysname '%s'"), udev_device_get_sysname(device));
-        ret = -1;
-    }
+    if (virBufferCheckError(&buf) < 0)
+        return -1;
 
     def->name = virBufferContentAndReset(&buf);
 
diff --git a/src/nwfilter/nwfilter_ebiptables_driver.c b/src/nwfilter/nwfilter_ebiptables_driver.c
index 5cb0b74..1701d62 100644
--- a/src/nwfilter/nwfilter_ebiptables_driver.c
+++ b/src/nwfilter/nwfilter_ebiptables_driver.c
@@ -306,11 +306,8 @@ _printDataType(virNWFilterVarCombIterPtr vars,
             }
         }
 
-        if (virBufferError(&vb)) {
-            virReportOOMError();
-            virBufferFreeAndReset(&vb);
+        if (virBufferCheckError(&vb) < 0)
             return -1;
-        }
 
         flags = virBufferContentAndReset(&vb);
 
@@ -1560,11 +1557,8 @@ printStateMatchFlags(int32_t flags, char **bufptr)
                                     "",
                                     flags,
                                     false);
-    if (virBufferError(&buf)) {
-        virBufferFreeAndReset(&buf);
-        virReportOOMError();
+    if (virBufferCheckError(&buf) < 0)
         return -1;
-    }
     *bufptr = virBufferContentAndReset(&buf);
     return 0;
 }
diff --git a/src/nwfilter/nwfilter_gentech_driver.c b/src/nwfilter/nwfilter_gentech_driver.c
index 8226195..6c7f77b 100644
--- a/src/nwfilter/nwfilter_gentech_driver.c
+++ b/src/nwfilter/nwfilter_gentech_driver.c
@@ -259,11 +259,8 @@ virNWFilterPrintVars(virHashTablePtr vars,
 
     virHashForEach(vars, printString, &ps);
 
-    if (virBufferError(&ps.buf)) {
-        virBufferFreeAndReset(&ps.buf);
-        virReportOOMError();
+    if (virBufferCheckError(&ps.buf) < 0)
         return NULL;
-    }
     return virBufferContentAndReset(&ps.buf);
 }
 
diff --git a/src/phyp/phyp_driver.c b/src/phyp/phyp_driver.c
index 659f8db..056d289 100644
--- a/src/phyp/phyp_driver.c
+++ b/src/phyp/phyp_driver.c
@@ -186,11 +186,8 @@ phypExec(LIBSSH2_SESSION *session, const char *cmd, int *exit_status,
     channel = NULL;
     VIR_FREE(buffer);
 
-    if (virBufferError(&tex_ret)) {
-        virBufferFreeAndReset(&tex_ret);
-        virReportOOMError();
+    if (virBufferCheckError(&tex_ret) < 0)
         return NULL;
-    }
     return virBufferContentAndReset(&tex_ret);
 
  err:
@@ -211,11 +208,8 @@ phypExecBuffer(LIBSSH2_SESSION *session, virBufferPtr buf, int *exit_status,
     char *cmd;
     char *ret;
 
-    if (virBufferError(buf)) {
-        virBufferFreeAndReset(buf);
-        virReportOOMError();
+    if (virBufferCheckError(buf) < 0)
         return NULL;
-    }
     cmd = virBufferContentAndReset(buf);
     ret = phypExec(session, cmd, exit_status, conn);
     VIR_FREE(cmd);
diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c
index 4724382..0c1f0f1 100644
--- a/src/qemu/qemu_command.c
+++ b/src/qemu/qemu_command.c
@@ -2962,10 +2962,8 @@ qemuBuildNetworkDriveURI(int protocol,
                 if (src)
                     virBufferAsprintf(&buf, ":exportname=%s", src);
 
-                if (virBufferError(&buf) < 0) {
-                    virReportOOMError();
+                if (virBufferCheckError(&buf) < 0)
                     goto cleanup;
-                }
 
                 ret = virBufferContentAndReset(&buf);
                 goto cleanup;
@@ -3098,10 +3096,8 @@ qemuBuildNetworkDriveURI(int protocol,
                 }
             }
 
-            if (virBufferError(&buf) < 0) {
-                virReportOOMError();
+            if (virBufferCheckError(&buf) < 0)
                 goto cleanup;
-            }
 
             ret = virBufferContentAndReset(&buf);
             break;
@@ -3557,10 +3553,8 @@ qemuBuildDriveStr(virConnectPtr conn,
                           disk->blkdeviotune.write_iops_sec);
     }
 
-    if (virBufferError(&opt)) {
-        virReportOOMError();
+    if (virBufferCheckError(&opt) < 0)
         goto error;
-    }
 
     return virBufferContentAndReset(&opt);
 
@@ -3899,10 +3893,8 @@ qemuBuildDriveDevStr(virDomainDefPtr def,
         }
     }
 
-    if (virBufferError(&opt)) {
-        virReportOOMError();
+    if (virBufferCheckError(&opt) < 0)
         goto error;
-    }
 
     return virBufferContentAndReset(&opt);
 
@@ -3975,10 +3967,8 @@ char *qemuBuildFSStr(virDomainFSDefPtr fs,
         }
     }
 
-    if (virBufferError(&opt)) {
-        virReportOOMError();
+    if (virBufferCheckError(&opt) < 0)
         goto error;
-    }
 
     return virBufferContentAndReset(&opt);
 
@@ -4009,10 +3999,8 @@ qemuBuildFSDevStr(virDomainDefPtr def,
     if (qemuBuildDeviceAddressStr(&opt, def, &fs->info, qemuCaps) < 0)
         goto error;
 
-    if (virBufferError(&opt)) {
-        virReportOOMError();
+    if (virBufferCheckError(&opt) < 0)
         goto error;
-    }
 
     return virBufferContentAndReset(&opt);
 
@@ -4252,10 +4240,8 @@ qemuBuildControllerDevStr(virDomainDefPtr domainDef,
     if (qemuBuildDeviceAddressStr(&buf, domainDef, &def->info, qemuCaps) < 0)
         goto error;
 
-    if (virBufferError(&buf)) {
-        virReportOOMError();
+    if (virBufferCheckError(&buf) < 0)
         goto error;
-    }
 
     return virBufferContentAndReset(&buf);
 
@@ -4365,10 +4351,8 @@ qemuBuildNicDevStr(virDomainDefPtr def,
     if (bootindex && virQEMUCapsGet(qemuCaps, QEMU_CAPS_BOOTINDEX))
         virBufferAsprintf(&buf, ",bootindex=%d", bootindex);
 
-    if (virBufferError(&buf)) {
-        virReportOOMError();
+    if (virBufferCheckError(&buf) < 0)
         goto error;
-    }
 
     return virBufferContentAndReset(&buf);
 
@@ -4502,11 +4486,8 @@ qemuBuildHostNetStr(virDomainNetDefPtr net,
 
     virObjectUnref(cfg);
 
-    if (virBufferError(&buf)) {
-        virBufferFreeAndReset(&buf);
-        virReportOOMError();
+    if (virBufferCheckError(&buf) < 0)
         return NULL;
-    }
 
     return virBufferContentAndReset(&buf);
 }
@@ -4530,10 +4511,8 @@ qemuBuildWatchdogDevStr(virDomainDefPtr def,
     if (qemuBuildDeviceAddressStr(&buf, def, &dev->info, qemuCaps) < 0)
         goto error;
 
-    if (virBufferError(&buf)) {
-        virReportOOMError();
+    if (virBufferCheckError(&buf) < 0)
         goto error;
-    }
 
     return virBufferContentAndReset(&buf);
 
@@ -4571,10 +4550,8 @@ qemuBuildMemballoonDevStr(virDomainDefPtr def,
     if (qemuBuildDeviceAddressStr(&buf, def, &dev->info, qemuCaps) < 0)
         goto error;
 
-    if (virBufferError(&buf)) {
-        virReportOOMError();
+    if (virBufferCheckError(&buf) < 0)
         goto error;
-    }
 
     return virBufferContentAndReset(&buf);
 
@@ -4598,10 +4575,8 @@ qemuBuildNVRAMDevStr(virDomainNVRAMDefPtr dev)
         goto error;
     }
 
-    if (virBufferError(&buf)) {
-        virReportOOMError();
+    if (virBufferCheckError(&buf) < 0)
         goto error;
-    }
 
     return virBufferContentAndReset(&buf);
 
@@ -4634,10 +4609,8 @@ qemuBuildUSBInputDevStr(virDomainDefPtr def,
     if (qemuBuildDeviceAddressStr(&buf, def, &dev->info, qemuCaps) < 0)
         goto error;
 
-    if (virBufferError(&buf)) {
-        virReportOOMError();
+    if (virBufferCheckError(&buf) < 0)
         goto error;
-    }
 
     return virBufferContentAndReset(&buf);
 
@@ -4687,10 +4660,8 @@ qemuBuildSoundDevStr(virDomainDefPtr def,
     if (qemuBuildDeviceAddressStr(&buf, def, &sound->info, qemuCaps) < 0)
         goto error;
 
-    if (virBufferError(&buf)) {
-        virReportOOMError();
+    if (virBufferCheckError(&buf) < 0)
         goto error;
-    }
 
     return virBufferContentAndReset(&buf);
 
@@ -4802,10 +4773,8 @@ qemuBuildDeviceVideoStr(virDomainDefPtr def,
     if (qemuBuildDeviceAddressStr(&buf, def, &video->info, qemuCaps) < 0)
         goto error;
 
-    if (virBufferError(&buf)) {
-        virReportOOMError();
+    if (virBufferCheckError(&buf) < 0)
         goto error;
-    }
 
     return virBufferContentAndReset(&buf);
 
@@ -4889,10 +4858,8 @@ qemuBuildPCIHostdevDevStr(virDomainDefPtr def,
     if (qemuBuildRomStr(&buf, dev->info, qemuCaps) < 0)
        goto error;
 
-    if (virBufferError(&buf)) {
-        virReportOOMError();
+    if (virBufferCheckError(&buf) < 0)
         goto error;
-    }
 
     return virBufferContentAndReset(&buf);
 
@@ -5010,10 +4977,8 @@ qemuBuildRedirdevDevStr(virDomainDefPtr def,
     if (qemuBuildDeviceAddressStr(&buf, def, &dev->info, qemuCaps) < 0)
         goto error;
 
-    if (virBufferError(&buf)) {
-        virReportOOMError();
+    if (virBufferCheckError(&buf) < 0)
         goto error;
-    }
 
     return virBufferContentAndReset(&buf);
 
@@ -5050,10 +5015,8 @@ qemuBuildUSBHostdevDevStr(virDomainDefPtr def,
     if (qemuBuildDeviceAddressStr(&buf, def, dev->info, qemuCaps) < 0)
         goto error;
 
-    if (virBufferError(&buf)) {
-        virReportOOMError();
+    if (virBufferCheckError(&buf) < 0)
         goto error;
-    }
 
     return virBufferContentAndReset(&buf);
 
@@ -5088,10 +5051,8 @@ qemuBuildHubDevStr(virDomainDefPtr def,
     if (qemuBuildDeviceAddressStr(&buf, def, &dev->info, qemuCaps) < 0)
         goto error;
 
-    if (virBufferError(&buf)) {
-        virReportOOMError();
+    if (virBufferCheckError(&buf) < 0)
         goto error;
-    }
 
     return virBufferContentAndReset(&buf);
 
@@ -5157,10 +5118,8 @@ qemuBuildSCSIHostdevDrvStr(virDomainHostdevDefPtr dev,
         }
     }
 
-    if (virBufferError(&buf)) {
-        virReportOOMError();
+    if (virBufferCheckError(&buf) < 0)
         goto error;
-    }
 
     VIR_FREE(sg);
     return virBufferContentAndReset(&buf);
@@ -5222,10 +5181,8 @@ qemuBuildSCSIHostdevDevStr(virDomainDefPtr def,
     if (dev->info->bootIndex)
         virBufferAsprintf(&buf, ",bootindex=%d", dev->info->bootIndex);
 
-    if (virBufferError(&buf)) {
-        virReportOOMError();
+    if (virBufferCheckError(&buf) < 0)
         goto error;
-    }
 
     return virBufferContentAndReset(&buf);
  error:
@@ -5342,10 +5299,8 @@ qemuBuildChrChardevStr(virDomainChrSourceDefPtr dev, const char *alias,
         goto error;
     }
 
-    if (virBufferError(&buf)) {
-        virReportOOMError();
+    if (virBufferCheckError(&buf) < 0)
         goto error;
-    }
 
     return virBufferContentAndReset(&buf);
 
@@ -5438,10 +5393,8 @@ qemuBuildChrArgStr(virDomainChrSourceDefPtr dev, const char *prefix)
         break;
     }
 
-    if (virBufferError(&buf)) {
-        virReportOOMError();
+    if (virBufferCheckError(&buf) < 0)
         goto error;
-    }
 
     return virBufferContentAndReset(&buf);
 
@@ -5518,10 +5471,8 @@ qemuBuildVirtioSerialPortDevStr(virDomainChrDefPtr dev,
     } else {
         virBufferAsprintf(&buf, ",id=%s", dev->info.alias);
     }
-    if (virBufferError(&buf)) {
-        virReportOOMError();
+    if (virBufferCheckError(&buf) < 0)
         goto error;
-    }
 
     return virBufferContentAndReset(&buf);
 
@@ -5550,10 +5501,8 @@ qemuBuildSclpDevStr(virDomainChrDefPtr dev)
     }
     virBufferAsprintf(&buf, ",chardev=char%s,id=%s",
                       dev->info.alias, dev->info.alias);
-    if (virBufferError(&buf)) {
-        virReportOOMError();
+    if (virBufferCheckError(&buf) < 0)
         goto error;
-    }
 
     return virBufferContentAndReset(&buf);
 
@@ -5703,10 +5652,8 @@ static char *qemuBuildTPMBackendStr(const virDomainDef *def,
         goto error;
     }
 
-    if (virBufferError(&buf)) {
-        virReportOOMError();
+    if (virBufferCheckError(&buf) < 0)
         goto error;
-    }
 
     return virBufferContentAndReset(&buf);
 
@@ -5741,10 +5688,8 @@ static char *qemuBuildTPMDevStr(const virDomainDef *def,
     virBufferAsprintf(&buf, "%s,tpmdev=tpm-%s,id=%s",
                       model, tpm->info.alias, tpm->info.alias);
 
-    if (virBufferError(&buf)) {
-        virReportOOMError();
+    if (virBufferCheckError(&buf) < 0)
         goto error;
-    }
 
     return virBufferContentAndReset(&buf);
 
@@ -5777,10 +5722,8 @@ static char *qemuBuildSmbiosBiosStr(virSysinfoDefPtr def)
     if (def->bios_release)
         virBufferAsprintf(&buf, ",release=%s", def->bios_release);
 
-    if (virBufferError(&buf)) {
-        virReportOOMError();
+    if (virBufferCheckError(&buf) < 0)
         goto error;
-    }
 
     return virBufferContentAndReset(&buf);
 
@@ -5824,10 +5767,8 @@ static char *qemuBuildSmbiosSystemStr(virSysinfoDefPtr def, bool skip_uuid)
     if (def->system_family)
         virBufferAsprintf(&buf, ",family=%s", def->system_family);
 
-    if (virBufferError(&buf)) {
-        virReportOOMError();
+    if (virBufferCheckError(&buf) < 0)
         goto error;
-    }
 
     return virBufferContentAndReset(&buf);
 
@@ -5944,10 +5885,8 @@ qemuBuildClockArgStr(virDomainClockDefPtr def)
         }
     }
 
-    if (virBufferError(&buf)) {
-        virReportOOMError();
+    if (virBufferCheckError(&buf) < 0)
         goto error;
-    }
 
     return virBufferContentAndReset(&buf);
 
@@ -6185,10 +6124,8 @@ qemuBuildCpuArgStr(virQEMUDriverPtr driver,
         }
     }
 
-    if (virBufferError(&buf)) {
-        virReportOOMError();
+    if (virBufferCheckError(&buf) < 0)
         goto cleanup;
-    }
 
     *opt = virBufferContentAndReset(&buf);
 
@@ -6390,11 +6327,8 @@ qemuBuildSmpArgStr(const virDomainDef *def,
         return NULL;
     }
 
-    if (virBufferError(&buf)) {
-        virBufferFreeAndReset(&buf);
-        virReportOOMError();
+    if (virBufferCheckError(&buf) < 0)
         return NULL;
-    }
 
     return virBufferContentAndReset(&buf);
 }
@@ -6432,10 +6366,8 @@ qemuBuildNumaArgStr(const virDomainDef *def, virCommandPtr cmd)
                                             1024) * 1024;
         virBufferAsprintf(&buf, ",mem=%d", def->cpu->cells[i].mem / 1024);
 
-        if (virBufferError(&buf)) {
-            virReportOOMError();
+        if (virBufferCheckError(&buf) < 0)
             goto cleanup;
-        }
 
         virCommandAddArgBuffer(cmd, &buf);
     }
@@ -7690,10 +7622,8 @@ qemuBuildCommandLine(virConnectPtr conn,
         if (boot_nparams > 0) {
             virCommandAddArg(cmd, "-boot");
 
-            if (virBufferError(&boot_buf)) {
-                virReportOOMError();
+            if (virBufferCheckError(&boot_buf) < 0)
                 goto error;
-            }
 
             if (boot_nparams < 2 || emitBootindex) {
                 virCommandAddArgBuffer(cmd, &boot_buf);
@@ -9167,10 +9097,8 @@ qemuBuildSerialChrDeviceStr(char **deviceStr,
         }
     }
 
-    if (virBufferError(&cmd)) {
-        virReportOOMError();
+    if (virBufferCheckError(&cmd) < 0)
         goto error;
-    }
 
     *deviceStr = virBufferContentAndReset(&cmd);
     return 0;
diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
index fd91d15..2a01c9c 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -1203,10 +1203,8 @@ qemuConnectGetSysinfo(virConnectPtr conn, unsigned int flags)
 
     if (virSysinfoFormat(&buf, driver->hostsysinfo) < 0)
         return NULL;
-    if (virBufferError(&buf)) {
-        virReportOOMError();
+    if (virBufferCheckError(&buf) < 0)
         return NULL;
-    }
     return virBufferContentAndReset(&buf);
 }
 
@@ -8005,10 +8003,8 @@ qemuDomainGetBlkioParameters(virDomainPtr dom,
                                           vm->def->blkio.devices[j].path,
                                           vm->def->blkio.devices[j].weight);
                     }
-                    if (virBufferError(&buf)) {
-                        virReportOOMError();
+                    if (virBufferCheckError(&buf) < 0)
                         goto cleanup;
-                    }
                     param->value.s = virBufferContentAndReset(&buf);
                 }
                 if (virTypedParameterAssign(param,
@@ -8034,10 +8030,8 @@ qemuDomainGetBlkioParameters(virDomainPtr dom,
                                           vm->def->blkio.devices[j].path,
                                           vm->def->blkio.devices[j].riops);
                     }
-                    if (virBufferError(&buf)) {
-                        virReportOOMError();
+                    if (virBufferCheckError(&buf) < 0)
                         goto cleanup;
-                    }
                     param->value.s = virBufferContentAndReset(&buf);
                 }
                 if (virTypedParameterAssign(param,
@@ -8063,10 +8057,8 @@ qemuDomainGetBlkioParameters(virDomainPtr dom,
                                           vm->def->blkio.devices[j].path,
                                           vm->def->blkio.devices[j].wiops);
                     }
-                    if (virBufferError(&buf)) {
-                        virReportOOMError();
+                    if (virBufferCheckError(&buf) < 0)
                         goto cleanup;
-                    }
                     param->value.s = virBufferContentAndReset(&buf);
                 }
                 if (virTypedParameterAssign(param,
@@ -8092,10 +8084,8 @@ qemuDomainGetBlkioParameters(virDomainPtr dom,
                                           vm->def->blkio.devices[j].path,
                                           vm->def->blkio.devices[j].rbps);
                     }
-                    if (virBufferError(&buf)) {
-                        virReportOOMError();
+                    if (virBufferCheckError(&buf) < 0)
                         goto cleanup;
-                    }
                     param->value.s = virBufferContentAndReset(&buf);
                 }
                 if (virTypedParameterAssign(param,
@@ -8121,10 +8111,8 @@ qemuDomainGetBlkioParameters(virDomainPtr dom,
                                           vm->def->blkio.devices[j].path,
                                           vm->def->blkio.devices[j].wbps);
                     }
-                    if (virBufferError(&buf)) {
-                        virReportOOMError();
+                    if (virBufferCheckError(&buf) < 0)
                         goto cleanup;
-                    }
                     param->value.s = virBufferContentAndReset(&buf);
                 }
                 if (virTypedParameterAssign(param,
@@ -8173,10 +8161,8 @@ qemuDomainGetBlkioParameters(virDomainPtr dom,
                                           persistentDef->blkio.devices[j].path,
                                           persistentDef->blkio.devices[j].weight);
                     }
-                    if (virBufferError(&buf)) {
-                        virReportOOMError();
+                    if (virBufferCheckError(&buf) < 0)
                         goto cleanup;
-                    }
                     param->value.s = virBufferContentAndReset(&buf);
                 }
                 if (!param->value.s && VIR_STRDUP(param->value.s, "") < 0)
@@ -8207,10 +8193,8 @@ qemuDomainGetBlkioParameters(virDomainPtr dom,
                                           persistentDef->blkio.devices[j].path,
                                           persistentDef->blkio.devices[j].riops);
                     }
-                    if (virBufferError(&buf)) {
-                        virReportOOMError();
+                    if (virBufferCheckError(&buf) < 0)
                         goto cleanup;
-                    }
                     param->value.s = virBufferContentAndReset(&buf);
                 }
                 if (!param->value.s && VIR_STRDUP(param->value.s, "") < 0)
@@ -8240,10 +8224,8 @@ qemuDomainGetBlkioParameters(virDomainPtr dom,
                                           persistentDef->blkio.devices[j].path,
                                           persistentDef->blkio.devices[j].wiops);
                     }
-                    if (virBufferError(&buf)) {
-                        virReportOOMError();
+                    if (virBufferCheckError(&buf) < 0)
                         goto cleanup;
-                    }
                     param->value.s = virBufferContentAndReset(&buf);
                 }
                 if (!param->value.s && VIR_STRDUP(param->value.s, "") < 0)
@@ -8273,10 +8255,8 @@ qemuDomainGetBlkioParameters(virDomainPtr dom,
                                           persistentDef->blkio.devices[j].path,
                                           persistentDef->blkio.devices[j].rbps);
                     }
-                    if (virBufferError(&buf)) {
-                        virReportOOMError();
+                    if (virBufferCheckError(&buf) < 0)
                         goto cleanup;
-                    }
                     param->value.s = virBufferContentAndReset(&buf);
                 }
                 if (!param->value.s && VIR_STRDUP(param->value.s, "") < 0)
@@ -8307,10 +8287,8 @@ qemuDomainGetBlkioParameters(virDomainPtr dom,
                                           persistentDef->blkio.devices[j].path,
                                           persistentDef->blkio.devices[j].wbps);
                     }
-                    if (virBufferError(&buf)) {
-                        virReportOOMError();
+                    if (virBufferCheckError(&buf) < 0)
                         goto cleanup;
-                    }
                     param->value.s = virBufferContentAndReset(&buf);
                 }
                 if (!param->value.s && VIR_STRDUP(param->value.s, "") < 0)
diff --git a/src/qemu/qemu_migration.c b/src/qemu/qemu_migration.c
index 99d4c4a..dc25242 100644
--- a/src/qemu/qemu_migration.c
+++ b/src/qemu/qemu_migration.c
@@ -666,11 +666,8 @@ static char *qemuMigrationCookieXMLFormatStr(virQEMUDriverPtr driver,
         return NULL;
     }
 
-    if (virBufferError(&buf)) {
-        virReportOOMError();
-        virBufferFreeAndReset(&buf);
+    if (virBufferCheckError(&buf) < 0)
         return NULL;
-    }
 
     return virBufferContentAndReset(&buf);
 }
diff --git a/src/qemu/qemu_monitor.c b/src/qemu/qemu_monitor.c
index 80d7b9d..739fe61 100644
--- a/src/qemu/qemu_monitor.c
+++ b/src/qemu/qemu_monitor.c
@@ -2297,11 +2297,8 @@ int qemuMonitorMigrateToFile(qemuMonitorPtr mon,
 
     /* Migrate to file */
     virBufferEscapeShell(&buf, target);
-    if (virBufferError(&buf)) {
-        virReportOOMError();
-        virBufferFreeAndReset(&buf);
+    if (virBufferCheckError(&buf) < 0)
         goto cleanup;
-    }
     safe_target = virBufferContentAndReset(&buf);
 
     /* Two dd processes, sharing the same stdout, are necessary to
diff --git a/src/qemu/qemu_monitor_text.c b/src/qemu/qemu_monitor_text.c
index fea484d..fc54a11 100644
--- a/src/qemu/qemu_monitor_text.c
+++ b/src/qemu/qemu_monitor_text.c
@@ -1576,11 +1576,8 @@ int qemuMonitorTextMigrate(qemuMonitorPtr mon,
         virBufferAddLit(&extra, " -b");
     if (flags & QEMU_MONITOR_MIGRATE_NON_SHARED_INC)
         virBufferAddLit(&extra, " -i");
-    if (virBufferError(&extra)) {
-        virBufferFreeAndReset(&extra);
-        virReportOOMError();
+    if (virBufferCheckError(&extra) < 0)
         goto cleanup;
-    }
 
     extrastr = virBufferContentAndReset(&extra);
     if (virAsprintf(&cmd, "migrate %s\"%s\"", extrastr ? extrastr : "",
@@ -2911,10 +2908,8 @@ int qemuMonitorTextSendKey(qemuMonitorPtr mon,
     if (holdtime)
         virBufferAsprintf(&buf, " %u", holdtime);
 
-    if (virBufferError(&buf)) {
-        virReportOOMError();
+    if (virBufferCheckError(&buf) < 0)
         return -1;
-    }
 
     cmd = virBufferContentAndReset(&buf);
     if (qemuMonitorHMPCommand(mon, cmd, &reply) < 0)
diff --git a/src/rpc/virnetsocket.c b/src/rpc/virnetsocket.c
index bdf2929..a94b2bc 100644
--- a/src/rpc/virnetsocket.c
+++ b/src/rpc/virnetsocket.c
@@ -728,10 +728,8 @@ int virNetSocketNewConnectSSH(const char *nodename,
     virCommandAddArgList(cmd, nodename, "sh", "-c", NULL);
 
     virBufferEscapeShell(&buf, netcat);
-    if (virBufferError(&buf)) {
+    if (virBufferCheckError(&buf) < 0) {
         virCommandFree(cmd);
-        virBufferFreeAndReset(&buf);
-        virReportOOMError();
         return -1;
     }
     quoted = virBufferContentAndReset(&buf);
diff --git a/src/rpc/virnetsshsession.c b/src/rpc/virnetsshsession.c
index 9d09699..7f47b29 100644
--- a/src/rpc/virnetsshsession.c
+++ b/src/rpc/virnetsshsession.c
@@ -372,10 +372,8 @@ virNetSSHCheckHostKey(virNetSSHSessionPtr sess)
                 virBufferAsprintf(&buff, "%02hhX:", keyhash[i]);
             virBufferTrim(&buff, ":", 1);
 
-            if (virBufferError(&buff) != 0) {
-                virReportOOMError();
+            if (virBufferCheckError(&buff) < 0)
                 return -1;
-            }
 
             keyhashstr = virBufferContentAndReset(&buff);
 
@@ -439,10 +437,8 @@ virNetSSHCheckHostKey(virNetSSHSessionPtr sess)
          * to port number */
         virBufferAsprintf(&buff, "[%s]:%d", sess->hostname, sess->port);
 
-        if (virBufferError(&buff) != 0) {
-            virReportOOMError();
+        if (virBufferCheckError(&buff) < 0)
             return -1;
-        }
 
         hostnameStr = virBufferContentAndReset(&buff);
 
diff --git a/src/storage/storage_backend.c b/src/storage/storage_backend.c
index b38af52..e83a108 100644
--- a/src/storage/storage_backend.c
+++ b/src/storage/storage_backend.c
@@ -760,14 +760,12 @@ virStorageBackendCreateQemuImgOpts(char **opts,
 
     virBufferTrim(&buf, ",", -1);
 
-    if (virBufferError(&buf))
-        goto no_memory;
+    if (virBufferCheckError(&buf) < 0)
+        goto error;
 
     *opts = virBufferContentAndReset(&buf);
     return 0;
 
- no_memory:
-    virReportOOMError();
  error:
     virBufferFreeAndReset(&buf);
     return -1;
diff --git a/src/storage/storage_backend_rbd.c b/src/storage/storage_backend_rbd.c
index 0e78f68..c456e65 100644
--- a/src/storage/storage_backend_rbd.c
+++ b/src/storage/storage_backend_rbd.c
@@ -188,10 +188,8 @@ static int virStorageBackendRBDOpenRADOSConn(virStorageBackendRBDStatePtr ptr,
         }
     }
 
-    if (virBufferError(&mon_host)) {
-       virReportOOMError();
-       goto cleanup;
-    }
+    if (virBufferCheckError(&mon_host) < 0)
+        goto cleanup;
 
     mon_buff = virBufferContentAndReset(&mon_host);
     VIR_DEBUG("RADOS mon_host has been set to: %s", mon_buff);
diff --git a/src/uml/uml_conf.c b/src/uml/uml_conf.c
index 464d56d..7a206d2 100644
--- a/src/uml/uml_conf.c
+++ b/src/uml/uml_conf.c
@@ -266,10 +266,8 @@ umlBuildCommandLineNet(virConnectPtr conn,
                           def->data.socket.port);
     }
 
-    if (virBufferError(&buf)) {
-        virReportOOMError();
+    if (virBufferCheckError(&buf) < 0)
         return NULL;
-    }
 
     return virBufferContentAndReset(&buf);
 
diff --git a/src/util/vircommand.c b/src/util/vircommand.c
index 448f6d3..e775ba6 100644
--- a/src/util/vircommand.c
+++ b/src/util/vircommand.c
@@ -1843,11 +1843,8 @@ virCommandToString(virCommandPtr cmd)
         virBufferEscapeShell(&buf, cmd->args[i]);
     }
 
-    if (virBufferError(&buf)) {
-        virBufferFreeAndReset(&buf);
-        virReportOOMError();
+    if (virBufferCheckError(&buf) < 0)
         return NULL;
-    }
 
     return virBufferContentAndReset(&buf);
 }
diff --git a/src/util/virconf.c b/src/util/virconf.c
index 55de0e9..e221fb5 100644
--- a/src/util/virconf.c
+++ b/src/util/virconf.c
@@ -979,11 +979,8 @@ virConfWriteFile(const char *filename, virConfPtr conf)
         cur = cur->next;
     }
 
-    if (virBufferError(&buf)) {
-        virBufferFreeAndReset(&buf);
-        virReportOOMError();
+    if (virBufferCheckError(&buf) < 0)
         return -1;
-    }
 
     fd = open(filename, O_WRONLY | O_CREAT | O_TRUNC, S_IRUSR | S_IWUSR);
     if (fd < 0) {
@@ -1035,11 +1032,8 @@ virConfWriteMem(char *memory, int *len, virConfPtr conf)
         cur = cur->next;
     }
 
-    if (virBufferError(&buf)) {
-        virBufferFreeAndReset(&buf);
-        virReportOOMError();
+    if (virBufferCheckError(&buf) < 0)
         return -1;
-    }
 
     use = virBufferUse(&buf);
     content = virBufferContentAndReset(&buf);
diff --git a/src/util/virnetdevopenvswitch.c b/src/util/virnetdevopenvswitch.c
index d6a16c6..9bcbfb1 100644
--- a/src/util/virnetdevopenvswitch.c
+++ b/src/util/virnetdevopenvswitch.c
@@ -119,10 +119,8 @@ int virNetDevOpenvswitchAddPort(const char *brname, const char *ifname,
                 virBufferAsprintf(&buf, "%d", virtVlan->tag[i]);
             }
 
-            if (virBufferError(&buf)) {
-                virReportOOMError();
+            if (virBufferCheckError(&buf) < 0)
                 goto cleanup;
-            }
             virCommandAddArg(cmd, virBufferCurrentContent(&buf));
         } else if (virtVlan->nTags) {
             virCommandAddArgFormat(cmd, "tag=%d", virtVlan->tag[0]);
diff --git a/src/util/virstoragefile.c b/src/util/virstoragefile.c
index 0c50de1..cd3c4c3 100644
--- a/src/util/virstoragefile.c
+++ b/src/util/virstoragefile.c
@@ -1946,10 +1946,8 @@ virStorageFileCanonicalizeFormatPath(char **components,
         virBufferAdd(&buf, components[i], -1);
     }
 
-    if (virBufferError(&buf) != 0) {
-        virReportOOMError();
+    if (virBufferCheckError(&buf) < 0)
         return NULL;
-    }
 
     /* if the output string is empty just return an empty string */
     if (!(ret = virBufferContentAndReset(&buf)))
diff --git a/src/util/virstring.c b/src/util/virstring.c
index 35b99a5..b14f785 100644
--- a/src/util/virstring.c
+++ b/src/util/virstring.c
@@ -158,10 +158,8 @@ char *virStringJoin(const char **strings,
             virBufferAdd(&buf, delim, -1);
         strings++;
     }
-    if (virBufferError(&buf)) {
-        virReportOOMError();
+    if (virBufferCheckError(&buf) < 0)
         return NULL;
-    }
     ret = virBufferContentAndReset(&buf);
     if (!ret)
         ignore_value(VIR_STRDUP(ret, ""));
@@ -909,10 +907,8 @@ virStringReplace(const char *haystack,
         tmp1 = tmp2;
     }
 
-    if (virBufferError(&buf)) {
-        virReportOOMError();
+    if (virBufferCheckError(&buf) < 0)
         return NULL;
-    }
 
     return virBufferContentAndReset(&buf);
 }
diff --git a/src/util/virsysinfo.c b/src/util/virsysinfo.c
index 40c78ca..1bb6392 100644
--- a/src/util/virsysinfo.c
+++ b/src/util/virsysinfo.c
@@ -1064,10 +1064,8 @@ virSysinfoFormat(virBufferPtr buf, virSysinfoDefPtr def)
     virBufferAdjustIndent(buf, -2);
     virBufferAddLit(buf, "</sysinfo>\n");
 
-    if (virBufferError(buf)) {
-        virReportOOMError();
+    if (virBufferCheckError(buf) < 0)
         return -1;
-    }
 
     return 0;
 }
diff --git a/src/util/virsystemd.c b/src/util/virsystemd.c
index ad15a18..ddfc047 100644
--- a/src/util/virsystemd.c
+++ b/src/util/virsystemd.c
@@ -94,10 +94,8 @@ char *virSystemdMakeScopeName(const char *name,
     virSystemdEscapeName(&buf, name);
     virBufferAddLit(&buf, ".scope");
 
-    if (virBufferError(&buf)) {
-        virReportOOMError();
+    if (virBufferCheckError(&buf) < 0)
         return NULL;
-    }
 
     return virBufferContentAndReset(&buf);
 }
@@ -113,10 +111,8 @@ char *virSystemdMakeSliceName(const char *partition)
     virSystemdEscapeName(&buf, partition);
     virBufferAddLit(&buf, ".slice");
 
-    if (virBufferError(&buf)) {
-        virReportOOMError();
+    if (virBufferCheckError(&buf) < 0)
         return NULL;
-    }
 
     return virBufferContentAndReset(&buf);
 }
diff --git a/src/util/viruri.c b/src/util/viruri.c
index 661ba76..eb47bbe 100644
--- a/src/util/viruri.c
+++ b/src/util/viruri.c
@@ -286,11 +286,8 @@ char *virURIFormatParams(virURIPtr uri)
         }
     }
 
-    if (virBufferError(&buf)) {
-        virBufferFreeAndReset(&buf);
-        virReportOOMError();
+    if (virBufferCheckError(&buf) < 0)
         return NULL;
-    }
 
     return virBufferContentAndReset(&buf);
 }
diff --git a/src/vmx/vmx.c b/src/vmx/vmx.c
index 30ee384..cd6c51e 100644
--- a/src/vmx/vmx.c
+++ b/src/vmx/vmx.c
@@ -3344,10 +3344,8 @@ virVMXFormatConfig(virVMXContext *ctx, virDomainXMLOptionPtr xmlopt, virDomainDe
     }
 
     /* Get final VMX output */
-    if (virBufferError(&buffer)) {
-        virReportOOMError();
+    if (virBufferCheckError(&buffer) < 0)
         goto cleanup;
-    }
 
     vmx = virBufferContentAndReset(&buffer);
 
diff --git a/src/xen/xen_driver.c b/src/xen/xen_driver.c
index 9355a4e..79df3ee 100644
--- a/src/xen/xen_driver.c
+++ b/src/xen/xen_driver.c
@@ -659,10 +659,8 @@ xenUnifiedConnectGetSysinfo(virConnectPtr conn ATTRIBUTE_UNUSED,
 
     if (virSysinfoFormat(&buf, hostsysinfo) < 0)
         return NULL;
-    if (virBufferError(&buf)) {
-        virReportOOMError();
+    if (virBufferCheckError(&buf) < 0)
         return NULL;
-    }
     return virBufferContentAndReset(&buf);
 }
 
diff --git a/src/xen/xend_internal.c b/src/xen/xend_internal.c
index 03fdde1..b2797b6 100644
--- a/src/xen/xend_internal.c
+++ b/src/xen/xend_internal.c
@@ -505,11 +505,8 @@ xend_op_ext(virConnectPtr xend, const char *path, const char *key, va_list ap)
             virBufferAddChar(&buf, '&');
     }
 
-    if (virBufferError(&buf)) {
-        virBufferFreeAndReset(&buf);
-        virReportOOMError();
+    if (virBufferCheckError(&buf) < 0)
         return -1;
-    }
 
     content = virBufferContentAndReset(&buf);
     VIR_DEBUG("xend op: %s\n", content);
@@ -2611,10 +2608,8 @@ xenDaemonDomainSetAutostart(virConnectPtr conn,
             goto error;
         }
 
-        if (virBufferError(&buffer)) {
-            virReportOOMError();
+        if (virBufferCheckError(&buffer) < 0)
             goto error;
-        }
 
         content = virBufferContentAndReset(&buffer);
 
diff --git a/src/xenapi/xenapi_utils.c b/src/xenapi/xenapi_utils.c
index 156e0c8..8b28914 100644
--- a/src/xenapi/xenapi_utils.c
+++ b/src/xenapi/xenapi_utils.c
@@ -284,11 +284,8 @@ mapDomainPinVcpu(unsigned char *cpumap, int maplen)
             }
         }
     }
-    if (virBufferError(&buf)) {
-        virReportOOMError();
-        virBufferFreeAndReset(&buf);
+    if (virBufferCheckError(&buf) < 0)
         return NULL;
-    }
     ret = virBufferContentAndReset(&buf);
     len = strlen(ret);
     if (len > 0 && ret[len - 1] == ',')
diff --git a/src/xenxs/xen_sxpr.c b/src/xenxs/xen_sxpr.c
index aacf74c..38b8423 100644
--- a/src/xenxs/xen_sxpr.c
+++ b/src/xenxs/xen_sxpr.c
@@ -1693,10 +1693,8 @@ xenFormatSxprChr(virDomainChrDefPtr def,
         return -1;
     }
 
-    if (virBufferError(buf)) {
-        virReportOOMError();
+    if (virBufferCheckError(buf) < 0)
         return -1;
-    }
 
     return 0;
 }
@@ -2118,10 +2116,8 @@ xenFormatSxprSound(virDomainDefPtr def,
         virBufferEscapeSexpr(buf, "%s", str);
     }
 
-    if (virBufferError(buf)) {
-        virReportOOMError();
+    if (virBufferCheckError(buf) < 0)
         return -1;
-    }
 
     return 0;
 }
@@ -2551,10 +2547,8 @@ xenFormatSxpr(virConnectPtr conn,
 
     virBufferAddLit(&buf, ")"); /* closes (vm */
 
-    if (virBufferError(&buf)) {
-        virReportOOMError();
+    if (virBufferCheckError(&buf) < 0)
         goto error;
-    }
 
     bufout = virBufferContentAndReset(&buf);
     VIR_DEBUG("Formatted sexpr: \n%s", bufout);
diff --git a/src/xenxs/xen_xm.c b/src/xenxs/xen_xm.c
index 2cd6d4c..2b28150 100644
--- a/src/xenxs/xen_xm.c
+++ b/src/xenxs/xen_xm.c
@@ -1261,10 +1261,8 @@ xenFormatXMDisk(virConfValuePtr list,
         return -1;
     }
 
-    if (virBufferError(&buf)) {
-        virReportOOMError();
+    if (virBufferCheckError(&buf) < 0)
         goto cleanup;
-    }
 
     if (VIR_ALLOC(val) < 0)
         goto cleanup;
@@ -1300,10 +1298,8 @@ static int xenFormatXMSerial(virConfValuePtr list,
     } else {
         virBufferAddLit(&buf, "none");
     }
-    if (virBufferError(&buf)) {
-        virReportOOMError();
+    if (virBufferCheckError(&buf) < 0)
         goto cleanup;
-    }
 
     if (VIR_ALLOC(val) < 0)
         goto cleanup;
@@ -1406,10 +1402,8 @@ static int xenFormatXMNet(virConnectPtr conn,
         virBufferAsprintf(&buf, ",vifname=%s",
                           net->ifname);
 
-    if (virBufferError(&buf)) {
-        virReportOOMError();
+    if (virBufferCheckError(&buf) < 0)
         goto cleanup;
-    }
 
     if (VIR_ALLOC(val) < 0)
         goto cleanup;
@@ -1861,11 +1855,8 @@ virConfPtr xenFormatXM(virConnectPtr conn,
                     virBufferAsprintf(&buf, ",keymap=%s",
                                       def->graphics[0]->data.vnc.keymap);
             }
-            if (virBufferError(&buf)) {
-                virBufferFreeAndReset(&buf);
-                virReportOOMError();
+            if (virBufferCheckError(&buf) < 0)
                 goto cleanup;
-            }
 
             vfbstr = virBufferContentAndReset(&buf);
 
diff --git a/tests/domainsnapshotxml2xmltest.c b/tests/domainsnapshotxml2xmltest.c
index 6d20181..1b3a28f 100644
--- a/tests/domainsnapshotxml2xmltest.c
+++ b/tests/domainsnapshotxml2xmltest.c
@@ -58,10 +58,8 @@ testFilterXML(char *xml)
         virBufferStrcat(&buf, *xmlLine, "\n", NULL);
     }
 
-    if (virBufferError(&buf)) {
-        virReportOOMError();
+    if (virBufferCheckError(&buf) < 0)
         goto cleanup;
-    }
 
     ret = virBufferContentAndReset(&buf);
 
-- 
1.8.5.5

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list




[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]