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;
}
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) {

View 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");

View 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) {

View 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;