[PATCH 29/33] virVBoxSnapshotConfSaveVboxFile: abort() on failure to allocate xmlDoc and comment

Peter Krempa pkrempa at redhat.com
Wed Feb 24 16:17:04 UTC 2021


'xmlNewDoc' and 'xmlNewDocComment' return NULL only on allocation
failure. Attempting to raise an error is pointless.

Signed-off-by: Peter Krempa <pkrempa at redhat.com>
---
 src/vbox/vbox_snapshot_conf.c | 12 ++++--------
 1 file changed, 4 insertions(+), 8 deletions(-)

diff --git a/src/vbox/vbox_snapshot_conf.c b/src/vbox/vbox_snapshot_conf.c
index 5792d3175e..4f12d2ebfa 100644
--- a/src/vbox/vbox_snapshot_conf.c
+++ b/src/vbox/vbox_snapshot_conf.c
@@ -996,10 +996,8 @@ virVBoxSnapshotConfSaveVboxFile(virVBoxSnapshotConfMachinePtr machine,
         goto cleanup;
     }
     xml = xmlNewDoc(BAD_CAST "1.0");
-    if (!xml) {
-        virReportOOMError();
-        goto cleanup;
-    }
+    if (!xml)
+        abort();

     cur = virXMLNewNode(NULL, "VirtualBox");

@@ -1023,10 +1021,8 @@ virVBoxSnapshotConfSaveVboxFile(virVBoxSnapshotConfMachinePtr machine,
                            "OVERWRITTEN AND LOST.\n"
                            "Changes to this xml configuration should be made using Virtualbox\n"
                            "or other application using the libvirt API");
-    if (!cur) {
-        virReportOOMError();
-        goto cleanup;
-    }
+    if (!cur)
+        abort();

     if (!xmlAddPrevSibling(xmlDocGetRootElement(xml), cur)) {
         virReportError(VIR_ERR_XML_ERROR, "%s",
-- 
2.29.2




More information about the libvir-list mailing list