]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
bhyve: use g_new0 instead of VIR_ALLOC*
authorJán Tomko <jtomko@redhat.com>
Wed, 23 Sep 2020 18:43:58 +0000 (20:43 +0200)
committerJán Tomko <jtomko@redhat.com>
Thu, 1 Oct 2020 10:34:13 +0000 (12:34 +0200)
Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Roman Bogorodskiy <bogorodskiy@gmail.com>
src/bhyve/bhyve_capabilities.c
src/bhyve/bhyve_domain.c
src/bhyve/bhyve_driver.c
src/bhyve/bhyve_parse_command.c

index 523a31e2870952675de6c86cb5488bb79f7cec47..96cfe8357a195d160f8c94c8ca9056f13ac87437 100644 (file)
@@ -150,8 +150,7 @@ virBhyveDomainCapsBuild(bhyveConnPtr conn,
         goto cleanup;
     }
 
-    if (VIR_ALLOC(firmwares) < 0)
-        goto cleanup;
+    firmwares = g_new0(virDomainCapsStringValues, 1);
 
     if (virDirOpenIfExists(&dir, firmware_dir) > 0) {
         while ((virDirRead(dir, &entry, firmware_dir)) > 0) {
index 91994c3da52143a13c79c3a8c6a36dc2e9e8f2be..6935609b96d33ac799724b39d96404401bcb9bc3 100644 (file)
@@ -38,8 +38,7 @@ bhyveDomainObjPrivateAlloc(void *opaque G_GNUC_UNUSED)
 {
     bhyveDomainObjPrivatePtr priv;
 
-    if (VIR_ALLOC(priv) < 0)
-        return NULL;
+    priv = g_new0(bhyveDomainObjPrivate, 1);
 
     return priv;
 }
@@ -236,8 +235,7 @@ bhyveDomainDefNamespaceParse(xmlXPathContextPtr ctxt,
     size_t i;
     int ret = -1;
 
-    if (VIR_ALLOC(cmd) < 0)
-        return -1;
+    cmd = g_new0(bhyveDomainCmdlineDef, 1);
 
     n = virXPathNodeSet("./bhyve:commandline/bhyve:arg", ctxt, &nodes);
     if (n == 0)
@@ -245,8 +243,7 @@ bhyveDomainDefNamespaceParse(xmlXPathContextPtr ctxt,
     if (n <= 0)
         goto cleanup;
 
-    if (VIR_ALLOC_N(cmd->args, n) < 0)
-        goto cleanup;
+    cmd->args = g_new0(char *, n);
 
     for (i = 0; i < n; i++) {
         cmd->args[cmd->num_args] = virXMLPropString(nodes[i], "value");
index daa20bad4057be34f784c47002f9d0a4391e32af..91f41aa238d045f5bca216c814f5c627b907a18c 100644 (file)
@@ -1224,8 +1224,7 @@ bhyveStateInitialize(bool privileged,
         return VIR_DRV_STATE_INIT_SKIPPED;
     }
 
-    if (VIR_ALLOC(bhyve_driver) < 0)
-        return VIR_DRV_STATE_INIT_ERROR;
+    bhyve_driver = g_new0(bhyveConn, 1);
 
     bhyve_driver->lockFD = -1;
     if (virMutexInit(&bhyve_driver->lock) < 0) {
index cf063da289caafe52cd8a143399c7d4422dd5477..969e782b273ca026a40d83cfa202dd37c025ec64 100644 (file)
@@ -53,8 +53,7 @@ bhyveParseCommandLineUnescape(const char *command)
 
     /* Since we are only removing characters, allocating a buffer of the same
      * size as command shouldn't be a problem here */
-    if (VIR_ALLOC_N(unescaped, len+1) < 0)
-        return NULL;
+    unescaped = g_new0(char, len + 1);
 
     /* Iterate over characters in the command, skipping "\\\n", "\\\r" as well
      * as "\\\r\n". */
@@ -590,8 +589,8 @@ bhyveParsePCIFbuf(virDomainDefPtr def,
 
     for (i = 0; i < nparams; i++) {
         param = params[i];
-        if (!video->driver && VIR_ALLOC(video->driver) < 0)
-            goto error;
+        if (!video->driver)
+            video->driver = g_new0(virDomainVideoDriverDef, 1);
 
         if (STREQ(param, "vga=on"))
             video->driver->vgaconf = VIR_DOMAIN_VIDEO_VGACONF_ON;