[virt-tools-list] [virt-viewer: PATCH 1/4] Simplify virt_viewer_auth_libvirt_credentials() return value logic

Fabiano Fidêncio fidencio at redhat.com
Wed Sep 24 11:49:26 UTC 2014


As the function should return < 0 in error cases, let's explicitly
return/set the return value to -1 in error cases. Otherwise, the
function will return 0.

This patch also fixes a regression introduced by (a5ce2ed3).

https://bugzilla.redhat.com/show_bug.cgi?id=1142742
---
 src/virt-viewer.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/src/virt-viewer.c b/src/virt-viewer.c
index 3d7511a..3d5a363 100644
--- a/src/virt-viewer.c
+++ b/src/virt-viewer.c
@@ -618,7 +618,7 @@ virt_viewer_auth_libvirt_credentials(virConnectCredentialPtr cred,
     VirtViewer *app = cbdata;
     VirtViewerPrivate *priv = app->priv;
     int i;
-    int ret = -1;
+    int ret = 0;
 
     g_debug("Got libvirt credential request for %d credential(s)", ncred);
 
@@ -644,10 +644,10 @@ virt_viewer_auth_libvirt_credentials(virConnectCredentialPtr cred,
                                                                      "libvirt",
                                                                      app->priv->uri,
                                                                      username, password);
-        if (priv->auth_cancelled)
+        if (priv->auth_cancelled) {
+            ret = -1;
             goto cleanup;
-    } else {
-        ret = 0;
+        }
     }
 
     for (i = 0 ; i < ncred ; i++) {
-- 
1.9.3




More information about the virt-tools-list mailing list