[PATCH v2 2/9] virsh: secret: Refactor cleanup in cmdSecretSetValue

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

 



Automatically clean the secret object and get rid of the cleanup label
and 'ret' valiable.

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

diff --git a/tools/virsh-secret.c b/tools/virsh-secret.c
index 7123b10860..58c9a54af6 100644
--- a/tools/virsh-secret.c
+++ b/tools/virsh-secret.c
@@ -188,18 +188,17 @@ static const vshCmdOptDef opts_secret_set_value[] = {
 static bool
 cmdSecretSetValue(vshControl *ctl, const vshCmd *cmd)
 {
-    virSecretPtr secret;
+    g_autoptr(virshSecret) secret = NULL;
     size_t value_size;
     const char *base64 = NULL;
     unsigned char *value;
     int res;
-    bool ret = false;

     if (!(secret = virshCommandOptSecret(ctl, cmd, NULL)))
         return false;

     if (vshCommandOptStringReq(ctl, cmd, "base64", &base64) < 0)
-        goto cleanup;
+        return false;

     value = g_base64_decode(base64, &value_size);

@@ -209,14 +208,10 @@ cmdSecretSetValue(vshControl *ctl, const vshCmd *cmd)

     if (res != 0) {
         vshError(ctl, "%s", _("Failed to set secret value"));
-        goto cleanup;
+        return false;
     }
     vshPrintExtra(ctl, "%s", _("Secret value set\n"));
-    ret = true;
-
- cleanup:
-    virshSecretFree(secret);
-    return ret;
+    return true;
 }

 /*
-- 
2.24.1





[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