[PATCH 4/9] remote: use g_autofree and remove unnecessary label

Jiang Jiacheng jiangjiacheng at huawei.com
Thu Jan 5 12:26:50 UTC 2023


Signed-off-by: Jiang Jiacheng <jiangjiacheng at huawei.com>
---
 src/remote/remote_driver.c | 22 +++++++---------------
 1 file changed, 7 insertions(+), 15 deletions(-)

diff --git a/src/remote/remote_driver.c b/src/remote/remote_driver.c
index b0dba9057b..316a11b10f 100644
--- a/src/remote/remote_driver.c
+++ b/src/remote/remote_driver.c
@@ -3833,23 +3833,19 @@ struct remoteAuthInteractState {
 static int remoteAuthFillFromConfig(virConnectPtr conn,
                                     struct remoteAuthInteractState *state)
 {
-    int ret = -1;
     int ninteract;
     const char *credname;
-    char *path = NULL;
+    g_autofree char *path = NULL;
 
     VIR_DEBUG("Trying to fill auth parameters from config file");
 
     if (!state->config) {
         if (virAuthGetConfigFilePath(conn, &path) < 0)
-            goto cleanup;
-        if (path == NULL) {
-            ret = 0;
-            goto cleanup;
-        }
-
+            return -1;
+        if (path == NULL)
+            return 0;
         if (!(state->config = virAuthConfigNew(path)))
-            goto cleanup;
+            return -1;
     }
 
     for (ninteract = 0; state->interact[ninteract].id != 0; ninteract++) {
@@ -3879,7 +3875,7 @@ static int remoteAuthFillFromConfig(virConnectPtr conn,
                                 VIR_URI_SERVER(conn->uri),
                                 credname,
                                 &value) < 0)
-            goto cleanup;
+            return -1;
 
         if (value) {
             state->interact[ninteract].result = value;
@@ -3887,11 +3883,7 @@ static int remoteAuthFillFromConfig(virConnectPtr conn,
         }
     }
 
-    ret = 0;
-
- cleanup:
-    VIR_FREE(path);
-    return ret;
+    return 0;
 }
 
 
-- 
2.33.0



More information about the libvir-list mailing list