[virt-tools-list] [virt-viewer PATCHv2] Fix building with older spice-gtk

Martin Kletzander mkletzan at redhat.com
Thu Mar 13 10:39:48 UTC 2014


Due to spice-gtk-0.23 missing SPICE_GTK_CHECK_VERSION macro, the
condition:

causes the following error:

virt-viewer-session-spice.c: In function 'virt_viewer_session_spice_main_channel_event':
virt-viewer-session-spice.c:525:64: error: missing binary operator before token "("
 #if defined(SPICE_GTK_CHECK_VERSION) && SPICE_GTK_CHECK_VERSION(0, 23, 21)
                                                                ^
Also one more warning is fixed in this patch:

virt-viewer-session-spice.c:476:19: warning: unused variable 'error'
[-Wunused-variable] const GError *error;
                                  ^

Signed-off-by: Martin Kletzander <mkletzan at redhat.com>
---
 src/virt-viewer-session-spice.c | 13 +++++++++----
 1 file changed, 9 insertions(+), 4 deletions(-)

diff --git a/src/virt-viewer-session-spice.c b/src/virt-viewer-session-spice.c
index 1740ba3..2712514 100644
--- a/src/virt-viewer-session-spice.c
+++ b/src/virt-viewer-session-spice.c
@@ -1,7 +1,7 @@
 /*
  * Virt Viewer: A virtual machine console viewer
  *
- * Copyright (C) 2007-2012 Red Hat, Inc.
+ * Copyright (C) 2007-2012, 2014 Red Hat, Inc.
  * Copyright (C) 2009-2012 Daniel P. Berrange
  * Copyright (C) 2010 Marc-André Lureau
  *
@@ -44,6 +44,10 @@
 #include "gbinding.c"
 #endif

+#ifndef SPICE_GTK_CHECK_VERSION
+#define SPICE_GTK_CHECK_VERSION(x, y, z) 0
+#endif
+
 G_DEFINE_TYPE (VirtViewerSessionSpice, virt_viewer_session_spice, VIRT_VIEWER_TYPE_SESSION)


@@ -473,7 +477,6 @@ virt_viewer_session_spice_main_channel_event(SpiceChannel *channel G_GNUC_UNUSED
                                              SpiceChannelEvent event,
                                              VirtViewerSession *session)
 {
-    const GError *error;
     VirtViewerSessionSpice *self = VIRT_VIEWER_SESSION_SPICE(session);
     gchar *password = NULL, *user = NULL;
     int ret;
@@ -522,8 +525,9 @@ virt_viewer_session_spice_main_channel_event(SpiceChannel *channel G_GNUC_UNUSED
         }
         break;
     case SPICE_CHANNEL_ERROR_CONNECT:
-#if defined(SPICE_GTK_CHECK_VERSION) && SPICE_GTK_CHECK_VERSION(0, 23, 21)
-        error = spice_channel_get_error(channel);
+#if SPICE_GTK_CHECK_VERSION(0, 23, 21)
+    {
+        const GError *error = spice_channel_get_error(channel);

         DEBUG_LOG("main channel: failed to connect %s", error ? error->message : "");

@@ -545,6 +549,7 @@ virt_viewer_session_spice_main_channel_event(SpiceChannel *channel G_GNUC_UNUSED
         } else {
             g_signal_emit_by_name(session, "session-disconnected");
         }
+    }
 #else
         DEBUG_LOG("main channel: failed to connect");
         g_signal_emit_by_name(session, "session-disconnected");
-- 
1.9.0




More information about the virt-tools-list mailing list