1
0
mirror of https://gitlab.com/libvirt/libvirt.git synced 2025-03-07 17:28:15 +00:00

bhyve: use g_new0 instead of VIR_ALLOC*

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Roman Bogorodskiy <bogorodskiy@gmail.com>
This commit is contained in:
Ján Tomko 2020-09-23 20:43:58 +02:00
parent 157b17f706
commit 9dceef831a
4 changed files with 8 additions and 14 deletions

View File

@ -150,8 +150,7 @@ virBhyveDomainCapsBuild(bhyveConnPtr conn,
goto cleanup; goto cleanup;
} }
if (VIR_ALLOC(firmwares) < 0) firmwares = g_new0(virDomainCapsStringValues, 1);
goto cleanup;
if (virDirOpenIfExists(&dir, firmware_dir) > 0) { if (virDirOpenIfExists(&dir, firmware_dir) > 0) {
while ((virDirRead(dir, &entry, firmware_dir)) > 0) { while ((virDirRead(dir, &entry, firmware_dir)) > 0) {

View File

@ -38,8 +38,7 @@ bhyveDomainObjPrivateAlloc(void *opaque G_GNUC_UNUSED)
{ {
bhyveDomainObjPrivatePtr priv; bhyveDomainObjPrivatePtr priv;
if (VIR_ALLOC(priv) < 0) priv = g_new0(bhyveDomainObjPrivate, 1);
return NULL;
return priv; return priv;
} }
@ -236,8 +235,7 @@ bhyveDomainDefNamespaceParse(xmlXPathContextPtr ctxt,
size_t i; size_t i;
int ret = -1; int ret = -1;
if (VIR_ALLOC(cmd) < 0) cmd = g_new0(bhyveDomainCmdlineDef, 1);
return -1;
n = virXPathNodeSet("./bhyve:commandline/bhyve:arg", ctxt, &nodes); n = virXPathNodeSet("./bhyve:commandline/bhyve:arg", ctxt, &nodes);
if (n == 0) if (n == 0)
@ -245,8 +243,7 @@ bhyveDomainDefNamespaceParse(xmlXPathContextPtr ctxt,
if (n <= 0) if (n <= 0)
goto cleanup; goto cleanup;
if (VIR_ALLOC_N(cmd->args, n) < 0) cmd->args = g_new0(char *, n);
goto cleanup;
for (i = 0; i < n; i++) { for (i = 0; i < n; i++) {
cmd->args[cmd->num_args] = virXMLPropString(nodes[i], "value"); cmd->args[cmd->num_args] = virXMLPropString(nodes[i], "value");

View File

@ -1224,8 +1224,7 @@ bhyveStateInitialize(bool privileged,
return VIR_DRV_STATE_INIT_SKIPPED; return VIR_DRV_STATE_INIT_SKIPPED;
} }
if (VIR_ALLOC(bhyve_driver) < 0) bhyve_driver = g_new0(bhyveConn, 1);
return VIR_DRV_STATE_INIT_ERROR;
bhyve_driver->lockFD = -1; bhyve_driver->lockFD = -1;
if (virMutexInit(&bhyve_driver->lock) < 0) { if (virMutexInit(&bhyve_driver->lock) < 0) {

View File

@ -53,8 +53,7 @@ bhyveParseCommandLineUnescape(const char *command)
/* Since we are only removing characters, allocating a buffer of the same /* Since we are only removing characters, allocating a buffer of the same
* size as command shouldn't be a problem here */ * size as command shouldn't be a problem here */
if (VIR_ALLOC_N(unescaped, len+1) < 0) unescaped = g_new0(char, len + 1);
return NULL;
/* Iterate over characters in the command, skipping "\\\n", "\\\r" as well /* Iterate over characters in the command, skipping "\\\n", "\\\r" as well
* as "\\\r\n". */ * as "\\\r\n". */
@ -590,8 +589,8 @@ bhyveParsePCIFbuf(virDomainDefPtr def,
for (i = 0; i < nparams; i++) { for (i = 0; i < nparams; i++) {
param = params[i]; param = params[i];
if (!video->driver && VIR_ALLOC(video->driver) < 0) if (!video->driver)
goto error; video->driver = g_new0(virDomainVideoDriverDef, 1);
if (STREQ(param, "vga=on")) if (STREQ(param, "vga=on"))
video->driver->vgaconf = VIR_DOMAIN_VIDEO_VGACONF_ON; video->driver->vgaconf = VIR_DOMAIN_VIDEO_VGACONF_ON;