[PATCH 2/5] conf: Rewrite virNetDevVPortProfileCopy

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



This makes it nicer to use as since it cannot fail shortens the usage in all
callers.

Signed-off-by: Martin Kletzander <mkletzan@xxxxxxxxxx>
---
 src/conf/domain_conf.c           |  9 +++------
 src/util/virnetdevvportprofile.c | 18 ++++++++++--------
 src/util/virnetdevvportprofile.h |  5 +++--
 3 files changed, 16 insertions(+), 16 deletions(-)

diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index 7764b1054d6f..0cfbe22dc099 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -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;
diff --git a/src/util/virnetdevvportprofile.c b/src/util/virnetdevvportprofile.c
index 88c34879525e..ae23f795b25a 100644
--- a/src/util/virnetdevvportprofile.c
+++ b/src/util/virnetdevvportprofile.c
@@ -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;
 }
 
 
diff --git a/src/util/virnetdevvportprofile.h b/src/util/virnetdevvportprofile.h
index e7a93e23a4f5..600b2093c507 100644
--- a/src/util/virnetdevvportprofile.h
+++ b/src/util/virnetdevvportprofile.h
@@ -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);
-- 
2.37.2




[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]

  Powered by Linux