]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
conf: interface: use g_new0
authorJán Tomko <jtomko@redhat.com>
Wed, 7 Oct 2020 19:13:54 +0000 (21:13 +0200)
committerJán Tomko <jtomko@redhat.com>
Thu, 8 Oct 2020 09:09:27 +0000 (11:09 +0200)
Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Neal Gompa <ngompa13@gmail.com>
Reviewed-by: Erik Skultety <eskultet@redhat.com>
src/conf/interface_conf.c

index 1e478ac075e858c36b0529b8ad924abec2c1f6bf..7bb5ec4debe6380c2d0b66a08e7e118c48d41d32 100644 (file)
@@ -337,16 +337,14 @@ virInterfaceDefParseProtoIPv4(virInterfaceProtocolDefPtr def,
     if (ipNodes == NULL)
         return 0;
 
-    if (VIR_ALLOC_N(def->ips, nipNodes) < 0)
-        goto error;
+    def->ips = g_new0(virInterfaceIPDefPtr, nipNodes);
 
     def->nips = 0;
     for (i = 0; i < nipNodes; i++) {
 
         virInterfaceIPDefPtr ip;
 
-        if (VIR_ALLOC(ip) < 0)
-            goto error;
+        ip = g_new0(virInterfaceIPDef, 1);
 
         ctxt->node = ipNodes[i];
         if (virInterfaceDefParseIP(ip, ctxt) < 0) {
@@ -393,16 +391,14 @@ virInterfaceDefParseProtoIPv6(virInterfaceProtocolDefPtr def,
     if (ipNodes == NULL)
         return 0;
 
-    if (VIR_ALLOC_N(def->ips, nipNodes) < 0)
-        goto error;
+    def->ips = g_new0(virInterfaceIPDefPtr, nipNodes);
 
     def->nips = 0;
     for (i = 0; i < nipNodes; i++) {
 
         virInterfaceIPDefPtr ip;
 
-        if (VIR_ALLOC(ip) < 0)
-            goto error;
+        ip = g_new0(virInterfaceIPDef, 1);
 
         ctxt->node = ipNodes[i];
         if (virInterfaceDefParseIP(ip, ctxt) < 0) {
@@ -438,16 +434,14 @@ virInterfaceDefParseIfAdressing(virInterfaceDefPtr def,
         return 0;
     }
 
-    if (VIR_ALLOC_N(def->protos, nProtoNodes) < 0)
-        goto error;
+    def->protos = g_new0(virInterfaceProtocolDefPtr, nProtoNodes);
 
     def->nprotos = 0;
     for (pp = 0; pp < nProtoNodes; pp++) {
 
         virInterfaceProtocolDefPtr proto;
 
-        if (VIR_ALLOC(proto) < 0)
-            goto error;
+        proto = g_new0(virInterfaceProtocolDef, 1);
 
         ctxt->node = protoNodes[pp];
         tmp = virXPathString("string(./@family)", ctxt);
@@ -522,10 +516,7 @@ virInterfaceDefParseBridge(virInterfaceDefPtr def,
         goto error;
     }
     if (nbItf > 0) {
-        if (VIR_ALLOC_N(def->data.bridge.itf, nbItf) < 0) {
-            ret = -1;
-            goto error;
-        }
+        def->data.bridge.itf = g_new0(struct _virInterfaceDef *, nbItf);
         def->data.bridge.nbItf = nbItf;
 
         for (i = 0; i < nbItf; i++) {
@@ -568,8 +559,7 @@ virInterfaceDefParseBondItfs(virInterfaceDefPtr def,
         goto cleanup;
     }
 
-    if (VIR_ALLOC_N(def->data.bond.itf, nbItf) < 0)
-        goto cleanup;
+    def->data.bond.itf = g_new0(struct _virInterfaceDef *, nbItf);
 
     def->data.bond.nbItf = nbItf;
 
@@ -712,8 +702,7 @@ virInterfaceDefParseXML(xmlXPathContextPtr ctxt,
     }
     VIR_FREE(tmp);
 
-    if (VIR_ALLOC(def) < 0)
-        return NULL;
+    def = g_new0(virInterfaceDef, 1);
 
     if (((parentIfType == VIR_INTERFACE_TYPE_BOND)
          && (type != VIR_INTERFACE_TYPE_ETHERNET))