[virt-tools-list] [virt-viewer 3/3] Fix virt_viewer_app_activate return value
Christophe Fergeau
cfergeau at redhat.com
Wed Jun 13 09:57:51 UTC 2012
VirtViewerApp::activate is expected to return -1 on errors.
It calls the VirtViewerSession::open_* methods, which return FALSE
on error. However, VirtViewerApp::activate directly returns these
boolean instead of testing the returned value and properly returning
-1 on errors. This caused errors in these open methodes to be ignored.
---
src/virt-viewer-app.c | 11 +++++++----
1 file changed, 7 insertions(+), 4 deletions(-)
diff --git a/src/virt-viewer-app.c b/src/virt-viewer-app.c
index 40d1ff7..2275d1c 100644
--- a/src/virt-viewer-app.c
+++ b/src/virt-viewer-app.c
@@ -846,15 +846,18 @@ virt_viewer_app_default_activate(VirtViewerApp *self)
#endif
if (fd >= 0) {
- return virt_viewer_session_open_fd(VIRT_VIEWER_SESSION(priv->session), fd);
+ if (virt_viewer_session_open_fd(VIRT_VIEWER_SESSION(priv->session), fd))
+ return 0;
} else if (priv->guri) {
virt_viewer_app_trace(self, "Opening connection to display at %s\n", priv->guri);
- return virt_viewer_session_open_uri(VIRT_VIEWER_SESSION(priv->session), priv->guri);
+ if (virt_viewer_session_open_uri(VIRT_VIEWER_SESSION(priv->session), priv->guri))
+ return 0;
} else {
virt_viewer_app_trace(self, "Opening direct TCP connection to display at %s:%s:%s\n",
priv->ghost, priv->gport, priv->gtlsport ? priv->gtlsport : "-1");
- return virt_viewer_session_open_host(VIRT_VIEWER_SESSION(priv->session),
- priv->ghost, priv->gport, priv->gtlsport);
+ if (virt_viewer_session_open_host(VIRT_VIEWER_SESSION(priv->session),
+ priv->ghost, priv->gport, priv->gtlsport))
+ return 0;
}
return -1;
--
1.7.10.2
More information about the virt-tools-list
mailing list