mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-02-22 11:22:23 +00:00
vz: use g_new0 instead of VIR_ALLOC
Signed-off-by: Ján Tomko <jtomko@redhat.com> Reviewed-by: Erik Skultety <eskultet@redhat.com>
This commit is contained in:
parent
6b675a4651
commit
4d36554716
@ -380,8 +380,7 @@ vzConnectOpen(virConnectPtr conn,
|
|||||||
if (!(driver = vzGetDriverConnection()))
|
if (!(driver = vzGetDriverConnection()))
|
||||||
return VIR_DRV_OPEN_ERROR;
|
return VIR_DRV_OPEN_ERROR;
|
||||||
|
|
||||||
if (VIR_ALLOC(privconn) < 0)
|
privconn = g_new0(vzConn, 1);
|
||||||
goto error;
|
|
||||||
|
|
||||||
conn->privateData = privconn;
|
conn->privateData = privconn;
|
||||||
privconn->driver = driver;
|
privconn->driver = driver;
|
||||||
@ -2792,8 +2791,7 @@ vzEatCookie(const char *cookiein, int cookieinlen, unsigned int flags)
|
|||||||
xmlXPathContextPtr ctx = NULL;
|
xmlXPathContextPtr ctx = NULL;
|
||||||
vzMigrationCookiePtr mig = NULL;
|
vzMigrationCookiePtr mig = NULL;
|
||||||
|
|
||||||
if (VIR_ALLOC(mig) < 0)
|
mig = g_new0(vzMigrationCookie, 1);
|
||||||
return NULL;
|
|
||||||
|
|
||||||
if (!cookiein || cookieinlen <= 0 || cookiein[cookieinlen - 1] != '\0') {
|
if (!cookiein || cookieinlen <= 0 || cookiein[cookieinlen - 1] != '\0') {
|
||||||
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
|
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
|
||||||
@ -3717,8 +3715,7 @@ vzDomainGetAllStats(virConnectPtr conn,
|
|||||||
virDomainStatsRecordPtr stat;
|
virDomainStatsRecordPtr stat;
|
||||||
int maxparams = 0;
|
int maxparams = 0;
|
||||||
|
|
||||||
if (VIR_ALLOC(stat) < 0)
|
stat = g_new0(virDomainStatsRecord, 1);
|
||||||
return NULL;
|
|
||||||
|
|
||||||
if (vzDomainGetStateStats(dom, stat, &maxparams) < 0)
|
if (vzDomainGetStateStats(dom, stat, &maxparams) < 0)
|
||||||
goto error;
|
goto error;
|
||||||
@ -3802,8 +3799,7 @@ vzConnectGetAllDomainStats(virConnectPtr conn,
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (VIR_ALLOC_N(tmpstats, ndoms + 1) < 0)
|
tmpstats = g_new0(virDomainStatsRecordPtr, ndoms + 1);
|
||||||
goto cleanup;
|
|
||||||
|
|
||||||
for (i = 0; i < ndoms; i++) {
|
for (i = 0; i < ndoms; i++) {
|
||||||
virDomainStatsRecordPtr tmp;
|
virDomainStatsRecordPtr tmp;
|
||||||
|
@ -70,16 +70,14 @@ logPrlErrorHelper(PRL_RESULT err, const char *filename,
|
|||||||
/* Get required buffer length */
|
/* Get required buffer length */
|
||||||
PrlApi_GetResultDescription(err, PRL_TRUE, PRL_FALSE, NULL, &len);
|
PrlApi_GetResultDescription(err, PRL_TRUE, PRL_FALSE, NULL, &len);
|
||||||
|
|
||||||
if (VIR_ALLOC_N(msg1, len) < 0)
|
msg1 = g_new0(char, len);
|
||||||
goto cleanup;
|
|
||||||
|
|
||||||
/* get short error description */
|
/* get short error description */
|
||||||
PrlApi_GetResultDescription(err, PRL_TRUE, PRL_FALSE, msg1, &len);
|
PrlApi_GetResultDescription(err, PRL_TRUE, PRL_FALSE, msg1, &len);
|
||||||
|
|
||||||
PrlApi_GetResultDescription(err, PRL_FALSE, PRL_FALSE, NULL, &len);
|
PrlApi_GetResultDescription(err, PRL_FALSE, PRL_FALSE, NULL, &len);
|
||||||
|
|
||||||
if (VIR_ALLOC_N(msg2, len) < 0)
|
msg2 = g_new0(char, len);
|
||||||
goto cleanup;
|
|
||||||
|
|
||||||
/* get long error description */
|
/* get long error description */
|
||||||
PrlApi_GetResultDescription(err, PRL_FALSE, PRL_FALSE, msg2, &len);
|
PrlApi_GetResultDescription(err, PRL_FALSE, PRL_FALSE, msg2, &len);
|
||||||
@ -88,7 +86,6 @@ logPrlErrorHelper(PRL_RESULT err, const char *filename,
|
|||||||
filename, funcname, linenr,
|
filename, funcname, linenr,
|
||||||
_("%s %s"), msg1, msg2);
|
_("%s %s"), msg1, msg2);
|
||||||
|
|
||||||
cleanup:
|
|
||||||
VIR_FREE(msg1);
|
VIR_FREE(msg1);
|
||||||
VIR_FREE(msg2);
|
VIR_FREE(msg2);
|
||||||
}
|
}
|
||||||
@ -122,22 +119,19 @@ logPrlEventErrorHelper(PRL_HANDLE event, const char *filename,
|
|||||||
|
|
||||||
PrlEvent_GetErrString(event, PRL_TRUE, PRL_FALSE, NULL, &len);
|
PrlEvent_GetErrString(event, PRL_TRUE, PRL_FALSE, NULL, &len);
|
||||||
|
|
||||||
if (VIR_ALLOC_N(msg1, len) < 0)
|
msg1 = g_new0(char, len);
|
||||||
goto cleanup;
|
|
||||||
|
|
||||||
PrlEvent_GetErrString(event, PRL_TRUE, PRL_FALSE, msg1, &len);
|
PrlEvent_GetErrString(event, PRL_TRUE, PRL_FALSE, msg1, &len);
|
||||||
|
|
||||||
PrlEvent_GetErrString(event, PRL_FALSE, PRL_FALSE, NULL, &len);
|
PrlEvent_GetErrString(event, PRL_FALSE, PRL_FALSE, NULL, &len);
|
||||||
|
|
||||||
if (VIR_ALLOC_N(msg2, len) < 0)
|
msg2 = g_new0(char, len);
|
||||||
goto cleanup;
|
|
||||||
|
|
||||||
PrlEvent_GetErrString(event, PRL_FALSE, PRL_FALSE, msg2, &len);
|
PrlEvent_GetErrString(event, PRL_FALSE, PRL_FALSE, msg2, &len);
|
||||||
|
|
||||||
virReportErrorHelper(VIR_FROM_THIS, VIR_ERR_INTERNAL_ERROR,
|
virReportErrorHelper(VIR_FROM_THIS, VIR_ERR_INTERNAL_ERROR,
|
||||||
filename, funcname, linenr,
|
filename, funcname, linenr,
|
||||||
_("%s %s"), msg1, msg2);
|
_("%s %s"), msg1, msg2);
|
||||||
cleanup:
|
|
||||||
VIR_FREE(msg1);
|
VIR_FREE(msg1);
|
||||||
VIR_FREE(msg2);
|
VIR_FREE(msg2);
|
||||||
}
|
}
|
||||||
@ -306,8 +300,7 @@ prlsdkGetStringParamVar(prlsdkParamGetterType getter, PRL_HANDLE handle)
|
|||||||
pret = getter(handle, NULL, &buflen);
|
pret = getter(handle, NULL, &buflen);
|
||||||
prlsdkCheckRetGoto(pret, error);
|
prlsdkCheckRetGoto(pret, error);
|
||||||
|
|
||||||
if (VIR_ALLOC_N(str, buflen) < 0)
|
str = g_new0(char, buflen);
|
||||||
goto error;
|
|
||||||
|
|
||||||
pret = getter(handle, str, &buflen);
|
pret = getter(handle, str, &buflen);
|
||||||
prlsdkCheckRetGoto(pret, error);
|
prlsdkCheckRetGoto(pret, error);
|
||||||
@ -582,11 +575,8 @@ prlsdkAddDomainVideoInfoVm(PRL_HANDLE sdkdom, virDomainDefPtr def)
|
|||||||
ret = PrlVmCfg_GetVideoRamSize(sdkdom, &videoRam);
|
ret = PrlVmCfg_GetVideoRamSize(sdkdom, &videoRam);
|
||||||
prlsdkCheckRetGoto(ret, error);
|
prlsdkCheckRetGoto(ret, error);
|
||||||
|
|
||||||
if (VIR_ALLOC(video) < 0)
|
video = g_new0(virDomainVideoDef, 1);
|
||||||
goto error;
|
accel = g_new0(virDomainVideoAccelDef, 1);
|
||||||
|
|
||||||
if (VIR_ALLOC(accel) < 0)
|
|
||||||
goto error;
|
|
||||||
|
|
||||||
if (VIR_APPEND_ELEMENT_COPY(def->videos, def->nvideos, video) < 0)
|
if (VIR_APPEND_ELEMENT_COPY(def->videos, def->nvideos, video) < 0)
|
||||||
goto error;
|
goto error;
|
||||||
@ -773,8 +763,7 @@ prlsdkGetFSInfo(PRL_HANDLE prldisk,
|
|||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
fs->type = VIR_DOMAIN_FS_TYPE_VOLUME;
|
fs->type = VIR_DOMAIN_FS_TYPE_VOLUME;
|
||||||
if (VIR_ALLOC(fs->src->srcpool) < 0)
|
fs->src->srcpool = g_new0(virStorageSourcePoolDef, 1);
|
||||||
goto cleanup;
|
|
||||||
fs->src->srcpool->pool = g_strdup(matches[1]);
|
fs->src->srcpool->pool = g_strdup(matches[1]);
|
||||||
fs->src->srcpool->volume = g_strdup(matches[2]);
|
fs->src->srcpool->volume = g_strdup(matches[2]);
|
||||||
VIR_FREE(buf);
|
VIR_FREE(buf);
|
||||||
@ -914,8 +903,7 @@ prlsdkParseNetAddress(char *addr)
|
|||||||
*maskstr = '\0';
|
*maskstr = '\0';
|
||||||
++maskstr;
|
++maskstr;
|
||||||
|
|
||||||
if (VIR_ALLOC(ip) < 0)
|
ip = g_new0(virNetDevIPAddr, 1);
|
||||||
goto cleanup;
|
|
||||||
|
|
||||||
if (virSocketAddrParse(&ip->address, addr, AF_UNSPEC) < 0)
|
if (virSocketAddrParse(&ip->address, addr, AF_UNSPEC) < 0)
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
@ -962,8 +950,7 @@ prlsdkGetNetAddresses(PRL_HANDLE sdknet, virDomainNetDefPtr net)
|
|||||||
pret = PrlStrList_GetItem(addrlist, i, NULL, &buflen);
|
pret = PrlStrList_GetItem(addrlist, i, NULL, &buflen);
|
||||||
prlsdkCheckRetGoto(pret, cleanup);
|
prlsdkCheckRetGoto(pret, cleanup);
|
||||||
|
|
||||||
if (VIR_ALLOC_N(addr, buflen) < 0)
|
addr = g_new0(char, buflen);
|
||||||
goto cleanup;
|
|
||||||
|
|
||||||
pret = PrlStrList_GetItem(addrlist, i, addr, &buflen);
|
pret = PrlStrList_GetItem(addrlist, i, addr, &buflen);
|
||||||
prlsdkCheckRetGoto(pret, cleanup);
|
prlsdkCheckRetGoto(pret, cleanup);
|
||||||
@ -1145,8 +1132,7 @@ prlsdkAddDomainNetInfo(PRL_HANDLE sdkdom, virDomainDefPtr def)
|
|||||||
ret = PrlVmCfg_GetNetAdapter(sdkdom, i, &netAdapter);
|
ret = PrlVmCfg_GetNetAdapter(sdkdom, i, &netAdapter);
|
||||||
prlsdkCheckRetGoto(ret, error);
|
prlsdkCheckRetGoto(ret, error);
|
||||||
|
|
||||||
if (VIR_ALLOC(net) < 0)
|
net = g_new0(virDomainNetDef, 1);
|
||||||
goto error;
|
|
||||||
|
|
||||||
if (prlsdkGetNetInfo(netAdapter, net, IS_CT(def)) < 0)
|
if (prlsdkGetNetInfo(netAdapter, net, IS_CT(def)) < 0)
|
||||||
goto error;
|
goto error;
|
||||||
@ -1333,8 +1319,7 @@ prlsdkAddVNCInfo(PRL_HANDLE sdkdom, virDomainDefPtr def)
|
|||||||
if (vncMode == PRD_DISABLED)
|
if (vncMode == PRD_DISABLED)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
if (VIR_ALLOC(gr) < 0)
|
gr = g_new0(virDomainGraphicsDef, 1);
|
||||||
goto error;
|
|
||||||
|
|
||||||
if (!(passwd = prlsdkGetStringParamVar(PrlVmCfg_GetVNCPassword, sdkdom)))
|
if (!(passwd = prlsdkGetStringParamVar(PrlVmCfg_GetVNCPassword, sdkdom)))
|
||||||
goto error;
|
goto error;
|
||||||
@ -1351,9 +1336,7 @@ prlsdkAddVNCInfo(PRL_HANDLE sdkdom, virDomainDefPtr def)
|
|||||||
gr->type = VIR_DOMAIN_GRAPHICS_TYPE_VNC;
|
gr->type = VIR_DOMAIN_GRAPHICS_TYPE_VNC;
|
||||||
gr->data.vnc.port = port;
|
gr->data.vnc.port = port;
|
||||||
|
|
||||||
if (VIR_ALLOC(gr->listens) < 0)
|
gr->listens = g_new0(virDomainGraphicsListenDef, 1);
|
||||||
goto error;
|
|
||||||
|
|
||||||
gr->nListens = 1;
|
gr->nListens = 1;
|
||||||
|
|
||||||
if (!(gr->listens[0].address = prlsdkGetStringParamVar(PrlVmCfg_GetVNCHostName,
|
if (!(gr->listens[0].address = prlsdkGetStringParamVar(PrlVmCfg_GetVNCHostName,
|
||||||
@ -4652,8 +4635,7 @@ prlsdkParseSnapshotTree(const char *treexml)
|
|||||||
if (nodes[i]->parent == root)
|
if (nodes[i]->parent == root)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
if (VIR_ALLOC(def) < 0)
|
def = g_new0(virDomainSnapshotDef, 1);
|
||||||
goto cleanup;
|
|
||||||
|
|
||||||
ctxt->node = nodes[i];
|
ctxt->node = nodes[i];
|
||||||
|
|
||||||
|
@ -556,8 +556,7 @@ vzDomObjAlloc(void *opaque G_GNUC_UNUSED)
|
|||||||
{
|
{
|
||||||
vzDomObjPtr pdom = NULL;
|
vzDomObjPtr pdom = NULL;
|
||||||
|
|
||||||
if (VIR_ALLOC(pdom) < 0)
|
pdom = g_new0(struct vzDomObj, 1);
|
||||||
return NULL;
|
|
||||||
|
|
||||||
if (virCondInit(&pdom->job.cond) < 0)
|
if (virCondInit(&pdom->job.cond) < 0)
|
||||||
goto error;
|
goto error;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user