]> xenbits.xensource.com Git - libvirt.git/commitdiff
conf: Rewrite virNetDevVPortProfileCopy
authorMartin Kletzander <mkletzan@redhat.com>
Thu, 11 Aug 2022 12:59:09 +0000 (14:59 +0200)
committerMartin Kletzander <mkletzan@redhat.com>
Thu, 18 Aug 2022 06:34:30 +0000 (08:34 +0200)
This makes it nicer to use as since it cannot fail shortens the usage in all
callers.

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
Reviewed-by: Reviewed-by: Ján Tomko <jtomko@redhat.com>
src/conf/domain_conf.c
src/util/virnetdevvportprofile.c
src/util/virnetdevvportprofile.h

index 7764b1054d6fd43e51827376f9c7ca1cbb54dfed..0cfbe22dc09956519058205f690c5619bce7b82f 100644 (file)
@@ -29348,8 +29348,7 @@ virDomainNetDefToNetworkPort(virDomainDef *dom,
 
     memcpy(&port->mac, &iface->mac, VIR_MAC_BUFLEN);
 
-    if (virNetDevVPortProfileCopy(&port->virtPortProfile, iface->virtPortProfile) < 0)
-        return NULL;
+    port->virtPortProfile = virNetDevVPortProfileCopy(iface->virtPortProfile);
 
     if (virNetDevBandwidthCopy(&port->bandwidth, iface->bandwidth) < 0)
         return NULL;
@@ -29448,8 +29447,7 @@ virDomainNetDefActualFromNetworkPort(virDomainNetDef *iface,
         goto error;
     }
 
-    if (virNetDevVPortProfileCopy(&actual->virtPortProfile, port->virtPortProfile) < 0)
-        goto error;
+    actual->virtPortProfile = virNetDevVPortProfileCopy(port->virtPortProfile);
 
     if (virNetDevBandwidthCopy(&actual->bandwidth, port->bandwidth) < 0)
         goto error;
@@ -29589,8 +29587,7 @@ virDomainNetDefActualToNetworkPort(virDomainDef *dom,
         return NULL;
     }
 
-    if (virNetDevVPortProfileCopy(&port->virtPortProfile, actual->virtPortProfile) < 0)
-        return NULL;
+    port->virtPortProfile = virNetDevVPortProfileCopy(actual->virtPortProfile);
 
     if (virNetDevBandwidthCopy(&port->bandwidth, actual->bandwidth) < 0)
         return NULL;
index 88c34879525ea1cf40d65001a7c38f214c2fe0d1..ae23f795b25a28789d044de1681b6851808036d7 100644 (file)
@@ -122,16 +122,18 @@ virNetDevVPortProfileEqual(const virNetDevVPortProfile *a, const virNetDevVPortP
 }
 
 
-int virNetDevVPortProfileCopy(virNetDevVPortProfile **dst, const virNetDevVPortProfile *src)
+virNetDevVPortProfile *
+virNetDevVPortProfileCopy(const virNetDevVPortProfile *src)
 {
-    if (!src) {
-        *dst = NULL;
-        return 0;
-    }
+    virNetDevVPortProfile *ret = NULL;
 
-    *dst = g_new0(virNetDevVPortProfile, 1);
-    memcpy(*dst, src, sizeof(*src));
-    return 0;
+    if (!src)
+        return NULL;
+
+    ret = g_new0(virNetDevVPortProfile, 1);
+    memcpy(ret, src, sizeof(*ret));
+
+    return ret;
 }
 
 
index e7a93e23a4f5151b22c29bb999a0f8f15ec5e8f2..600b2093c507e273f30887bee6955eed623b5c3a 100644 (file)
@@ -77,8 +77,9 @@ struct _virNetDevVPortProfile {
 
 bool virNetDevVPortProfileEqual(const virNetDevVPortProfile *a,
                                 const virNetDevVPortProfile *b);
-int virNetDevVPortProfileCopy(virNetDevVPortProfile **dst,
-                              const virNetDevVPortProfile *src);
+
+virNetDevVPortProfile *
+virNetDevVPortProfileCopy(const virNetDevVPortProfile *src);
 
 int virNetDevVPortProfileCheckComplete(virNetDevVPortProfile *virtport,
                                        bool generateMissing);