[PATCH 20/39] virshParseRateStr: Refactor cleanup

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

 



Use g_auto for the string list and remove 'ret' and 'cleanup:'.

Signed-off-by: Peter Krempa <pkrempa@xxxxxxxxxx>
---
 tools/virsh-domain.c | 12 ++++--------
 1 file changed, 4 insertions(+), 8 deletions(-)

diff --git a/tools/virsh-domain.c b/tools/virsh-domain.c
index 86de4255fa..37be298809 100644
--- a/tools/virsh-domain.c
+++ b/tools/virsh-domain.c
@@ -848,7 +848,7 @@ static const vshCmdOptDef opts_attach_interface[] = {
             *tok[index] != '\0' && \
             virStrToLong_ullp(tok[index], NULL, 10, &rate->name) < 0) { \
             vshError(ctl, _("field '%s' is malformed"), #name); \
-            goto cleanup; \
+            return -1; \
         } \
     } while (0)

@@ -857,16 +857,15 @@ virshParseRateStr(vshControl *ctl,
                   const char *rateStr,
                   virNetDevBandwidthRatePtr rate)
 {
-    char **tok = NULL;
+    g_auto(GStrv) tok = NULL;
     size_t ntok;
-    int ret = -1;

     if (!(tok = virStringSplitCount(rateStr, ",", 0, &ntok)))
         return -1;

     if (ntok > 4) {
         vshError(ctl, _("Rate string '%s' has too many fields"), rateStr);
-        goto cleanup;
+        return -1;
     }

     VIRSH_PARSE_RATE_FIELD(0, average);
@@ -874,10 +873,7 @@ virshParseRateStr(vshControl *ctl,
     VIRSH_PARSE_RATE_FIELD(2, burst);
     VIRSH_PARSE_RATE_FIELD(3, floor);

-    ret = 0;
- cleanup:
-    g_strfreev(tok);
-    return ret;
+    return 0;
 }

 #undef VIRSH_PARSE_RATE_FIELD
-- 
2.29.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