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

[libvirt PATCH 1/7] bhyve: use g_new0 instead of VIR_ALLOC*



Signed-off-by: Ján Tomko <jtomko redhat com>
---
 src/bhyve/bhyve_capabilities.c  | 3 +--
 src/bhyve/bhyve_domain.c        | 9 +++------
 src/bhyve/bhyve_driver.c        | 3 +--
 src/bhyve/bhyve_parse_command.c | 7 +++----
 4 files changed, 8 insertions(+), 14 deletions(-)

diff --git a/src/bhyve/bhyve_capabilities.c b/src/bhyve/bhyve_capabilities.c
index 523a31e287..96cfe8357a 100644
--- a/src/bhyve/bhyve_capabilities.c
+++ b/src/bhyve/bhyve_capabilities.c
@@ -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) {
diff --git a/src/bhyve/bhyve_domain.c b/src/bhyve/bhyve_domain.c
index 91994c3da5..6935609b96 100644
--- a/src/bhyve/bhyve_domain.c
+++ b/src/bhyve/bhyve_domain.c
@@ -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");
diff --git a/src/bhyve/bhyve_driver.c b/src/bhyve/bhyve_driver.c
index daa20bad40..91f41aa238 100644
--- a/src/bhyve/bhyve_driver.c
+++ b/src/bhyve/bhyve_driver.c
@@ -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) {
diff --git a/src/bhyve/bhyve_parse_command.c b/src/bhyve/bhyve_parse_command.c
index cf063da289..969e782b27 100644
--- a/src/bhyve/bhyve_parse_command.c
+++ b/src/bhyve/bhyve_parse_command.c
@@ -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;
-- 
2.26.2


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