[libvirt PATCH 02/12] conf: change virDomainVirtioNet*Format() to return void

Laine Stump posted 12 patches 6 years ago
[libvirt PATCH 02/12] conf: change virDomainVirtioNet*Format() to return void
Posted by Laine Stump 6 years ago
All three of these functions could only return 0 anyway, so just get
rid of all the extra red tape.

Signed-off-by: Laine Stump <laine@redhat.com>
---
 src/conf/domain_conf.c | 20 ++++++--------------
 1 file changed, 6 insertions(+), 14 deletions(-)

diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index 0208d330c3..69e3b7be9a 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -25317,7 +25317,7 @@ virDomainActualNetDefFormat(virBufferPtr buf,
 }
 
 
-static int
+static void
 virDomainVirtioNetGuestOptsFormat(char **outstr,
                                   virDomainNetDefPtr def)
 {
@@ -25345,11 +25345,10 @@ virDomainVirtioNetGuestOptsFormat(char **outstr,
     virBufferTrim(&buf, " ", -1);
 
     *outstr = virBufferContentAndReset(&buf);
-    return 0;
 }
 
 
-static int
+static void
 virDomainVirtioNetHostOptsFormat(char **outstr,
                                  virDomainNetDefPtr def)
 {
@@ -25385,11 +25384,10 @@ virDomainVirtioNetHostOptsFormat(char **outstr,
     virBufferTrim(&buf, " ", -1);
 
     *outstr = virBufferContentAndReset(&buf);
-    return 0;
 }
 
 
-static int
+static void
 virDomainVirtioNetDriverFormat(char **outstr,
                                virDomainNetDefPtr def)
 {
@@ -25422,7 +25420,6 @@ virDomainVirtioNetDriverFormat(char **outstr,
     virDomainVirtioOptionsFormat(&buf, def->virtio);
 
     *outstr = virBufferContentAndReset(&buf);
-    return 0;
 }
 
 
@@ -25696,15 +25693,13 @@ virDomainNetDefFormat(virBufferPtr buf,
         virBufferEscapeString(buf, "<model type='%s'/>\n",
                               virDomainNetGetModelString(def));
         if (virDomainNetIsVirtioModel(def)) {
-            int rc = 0;
             g_autofree char *str = NULL;
             g_autofree char *gueststr = NULL;
             g_autofree char *hoststr = NULL;
 
-            if (virDomainVirtioNetDriverFormat(&str, def) < 0 ||
-                virDomainVirtioNetGuestOptsFormat(&gueststr, def) < 0 ||
-                virDomainVirtioNetHostOptsFormat(&hoststr, def) < 0)
-                rc = -1;
+            virDomainVirtioNetDriverFormat(&str, def);
+            virDomainVirtioNetGuestOptsFormat(&gueststr, def);
+            virDomainVirtioNetHostOptsFormat(&hoststr, def);
 
             if (!gueststr && !hoststr) {
                 if (str)
@@ -25722,9 +25717,6 @@ virDomainNetDefFormat(virBufferPtr buf,
                 virBufferAdjustIndent(buf, -2);
                 virBufferAddLit(buf, "</driver>\n");
             }
-
-            if (rc < 0)
-                return -1;
         }
     }
     if (def->backend.tap || def->backend.vhost) {
-- 
2.24.1

Re: [libvirt PATCH 02/12] conf: change virDomainVirtioNet*Format() to return void
Posted by Daniel P. Berrangé 6 years ago
On Sun, Jan 19, 2020 at 10:24:09PM -0500, Laine Stump wrote:
> All three of these functions could only return 0 anyway, so just get
> rid of all the extra red tape.
> 
> Signed-off-by: Laine Stump <laine@redhat.com>
> ---
>  src/conf/domain_conf.c | 20 ++++++--------------
>  1 file changed, 6 insertions(+), 14 deletions(-)

Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>


Regards,
Daniel
-- 
|: https://berrange.com      -o-    https://www.flickr.com/photos/dberrange :|
|: https://libvirt.org         -o-            https://fstop138.berrange.com :|
|: https://entangle-photo.org    -o-    https://www.instagram.com/dberrange :|