[virt-tools-list] [virt-viewer 3/3] Fix virt_viewer_app_activate return value

Daniel P. Berrange berrange at redhat.com
Wed Jun 13 10:01:42 UTC 2012


On Wed, Jun 13, 2012 at 11:57:51AM +0200, Christophe Fergeau wrote:
> 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;
>      }

ACK


Daniel
-- 
|: http://berrange.com      -o-    http://www.flickr.com/photos/dberrange/ :|
|: http://libvirt.org              -o-             http://virt-manager.org :|
|: http://autobuild.org       -o-         http://search.cpan.org/~danberr/ :|
|: http://entangle-photo.org       -o-       http://live.gnome.org/gtk-vnc :|




More information about the virt-tools-list mailing list