mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-12-25 15:15:25 +00:00
conf: interface: use g_new0
Signed-off-by: Ján Tomko <jtomko@redhat.com> Reviewed-by: Neal Gompa <ngompa13@gmail.com> Reviewed-by: Erik Skultety <eskultet@redhat.com>
This commit is contained in:
parent
ba6cc0fc7a
commit
6dc231438f
@ -337,16 +337,14 @@ virInterfaceDefParseProtoIPv4(virInterfaceProtocolDefPtr def,
|
|||||||
if (ipNodes == NULL)
|
if (ipNodes == NULL)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
if (VIR_ALLOC_N(def->ips, nipNodes) < 0)
|
def->ips = g_new0(virInterfaceIPDefPtr, nipNodes);
|
||||||
goto error;
|
|
||||||
|
|
||||||
def->nips = 0;
|
def->nips = 0;
|
||||||
for (i = 0; i < nipNodes; i++) {
|
for (i = 0; i < nipNodes; i++) {
|
||||||
|
|
||||||
virInterfaceIPDefPtr ip;
|
virInterfaceIPDefPtr ip;
|
||||||
|
|
||||||
if (VIR_ALLOC(ip) < 0)
|
ip = g_new0(virInterfaceIPDef, 1);
|
||||||
goto error;
|
|
||||||
|
|
||||||
ctxt->node = ipNodes[i];
|
ctxt->node = ipNodes[i];
|
||||||
if (virInterfaceDefParseIP(ip, ctxt) < 0) {
|
if (virInterfaceDefParseIP(ip, ctxt) < 0) {
|
||||||
@ -393,16 +391,14 @@ virInterfaceDefParseProtoIPv6(virInterfaceProtocolDefPtr def,
|
|||||||
if (ipNodes == NULL)
|
if (ipNodes == NULL)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
if (VIR_ALLOC_N(def->ips, nipNodes) < 0)
|
def->ips = g_new0(virInterfaceIPDefPtr, nipNodes);
|
||||||
goto error;
|
|
||||||
|
|
||||||
def->nips = 0;
|
def->nips = 0;
|
||||||
for (i = 0; i < nipNodes; i++) {
|
for (i = 0; i < nipNodes; i++) {
|
||||||
|
|
||||||
virInterfaceIPDefPtr ip;
|
virInterfaceIPDefPtr ip;
|
||||||
|
|
||||||
if (VIR_ALLOC(ip) < 0)
|
ip = g_new0(virInterfaceIPDef, 1);
|
||||||
goto error;
|
|
||||||
|
|
||||||
ctxt->node = ipNodes[i];
|
ctxt->node = ipNodes[i];
|
||||||
if (virInterfaceDefParseIP(ip, ctxt) < 0) {
|
if (virInterfaceDefParseIP(ip, ctxt) < 0) {
|
||||||
@ -438,16 +434,14 @@ virInterfaceDefParseIfAdressing(virInterfaceDefPtr def,
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (VIR_ALLOC_N(def->protos, nProtoNodes) < 0)
|
def->protos = g_new0(virInterfaceProtocolDefPtr, nProtoNodes);
|
||||||
goto error;
|
|
||||||
|
|
||||||
def->nprotos = 0;
|
def->nprotos = 0;
|
||||||
for (pp = 0; pp < nProtoNodes; pp++) {
|
for (pp = 0; pp < nProtoNodes; pp++) {
|
||||||
|
|
||||||
virInterfaceProtocolDefPtr proto;
|
virInterfaceProtocolDefPtr proto;
|
||||||
|
|
||||||
if (VIR_ALLOC(proto) < 0)
|
proto = g_new0(virInterfaceProtocolDef, 1);
|
||||||
goto error;
|
|
||||||
|
|
||||||
ctxt->node = protoNodes[pp];
|
ctxt->node = protoNodes[pp];
|
||||||
tmp = virXPathString("string(./@family)", ctxt);
|
tmp = virXPathString("string(./@family)", ctxt);
|
||||||
@ -522,10 +516,7 @@ virInterfaceDefParseBridge(virInterfaceDefPtr def,
|
|||||||
goto error;
|
goto error;
|
||||||
}
|
}
|
||||||
if (nbItf > 0) {
|
if (nbItf > 0) {
|
||||||
if (VIR_ALLOC_N(def->data.bridge.itf, nbItf) < 0) {
|
def->data.bridge.itf = g_new0(struct _virInterfaceDef *, nbItf);
|
||||||
ret = -1;
|
|
||||||
goto error;
|
|
||||||
}
|
|
||||||
def->data.bridge.nbItf = nbItf;
|
def->data.bridge.nbItf = nbItf;
|
||||||
|
|
||||||
for (i = 0; i < nbItf; i++) {
|
for (i = 0; i < nbItf; i++) {
|
||||||
@ -568,8 +559,7 @@ virInterfaceDefParseBondItfs(virInterfaceDefPtr def,
|
|||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (VIR_ALLOC_N(def->data.bond.itf, nbItf) < 0)
|
def->data.bond.itf = g_new0(struct _virInterfaceDef *, nbItf);
|
||||||
goto cleanup;
|
|
||||||
|
|
||||||
def->data.bond.nbItf = nbItf;
|
def->data.bond.nbItf = nbItf;
|
||||||
|
|
||||||
@ -712,8 +702,7 @@ virInterfaceDefParseXML(xmlXPathContextPtr ctxt,
|
|||||||
}
|
}
|
||||||
VIR_FREE(tmp);
|
VIR_FREE(tmp);
|
||||||
|
|
||||||
if (VIR_ALLOC(def) < 0)
|
def = g_new0(virInterfaceDef, 1);
|
||||||
return NULL;
|
|
||||||
|
|
||||||
if (((parentIfType == VIR_INTERFACE_TYPE_BOND)
|
if (((parentIfType == VIR_INTERFACE_TYPE_BOND)
|
||||||
&& (type != VIR_INTERFACE_TYPE_ETHERNET))
|
&& (type != VIR_INTERFACE_TYPE_ETHERNET))
|
||||||
|
Loading…
Reference in New Issue
Block a user