[virt-tools-list] [virt-viewer] Be more consistent in #if/#ifdef use

Hans de Goede hdegoede at redhat.com
Thu Feb 21 17:31:00 UTC 2013


ACK.

On 02/21/2013 06:24 PM, Christophe Fergeau wrote:
> Some of the code is checking for spice-gtk/oVirt availability
> by using #ifdef HAVE_XXX, and some of the code is using #if HAVE_XXX.
> As configure.ac only AC_DEFINE() HAVE_XXX when XXX could be found,
> let's use the #ifdef HAVE_XXX form everywhere
> ---
>   src/remote-viewer-main.c | 10 +++++-----
>   src/remote-viewer.c      | 30 +++++++++++++++---------------
>   2 files changed, 20 insertions(+), 20 deletions(-)
>
> diff --git a/src/remote-viewer-main.c b/src/remote-viewer-main.c
> index 048f6b4..1d92172 100644
> --- a/src/remote-viewer-main.c
> +++ b/src/remote-viewer-main.c
> @@ -202,7 +202,7 @@ main(int argc, char **argv)
>       gboolean debug = FALSE;
>       gboolean direct = FALSE;
>       RemoteViewer *viewer = NULL;
> -#if HAVE_SPICE_GTK
> +#ifdef HAVE_SPICE_GTK
>       gboolean controller = FALSE;
>   #endif
>       VirtViewerApp *app;
> @@ -221,7 +221,7 @@ main(int argc, char **argv)
>             N_("Display debugging information"), NULL },
>           { "full-screen", 'f', G_OPTION_FLAG_OPTIONAL_ARG, G_OPTION_ARG_CALLBACK, option_fullscreen,
>             N_("Open in full screen mode (auto-conf adjusts guest resolution to fit the client's)."), N_("<auto-conf>") },
> -#if HAVE_SPICE_GTK
> +#ifdef HAVE_SPICE_GTK
>           { "spice-controller", '\0', 0, G_OPTION_ARG_NONE, &controller,
>             N_("Open connection using Spice controller communication"), NULL },
>   #endif
> @@ -257,7 +257,7 @@ main(int argc, char **argv)
>
>       g_option_context_free(context);
>
> -#if HAVE_SPICE_GTK
> +#ifdef HAVE_SPICE_GTK
>       if (controller) {
>           if (args) {
>               g_printerr(_("Error: extra arguments given while using Spice controller\n"));
> @@ -284,7 +284,7 @@ main(int argc, char **argv)
>
>       virt_viewer_app_set_debug(debug);
>
> -#if HAVE_SPICE_GTK
> +#ifdef HAVE_SPICE_GTK
>       if (controller) {
>           viewer = remote_viewer_new_with_controller(verbose);
>           g_object_set(viewer, "guest-name", "defined by Spice controller", NULL);
> @@ -292,7 +292,7 @@ main(int argc, char **argv)
>   #endif
>           viewer = remote_viewer_new(uri, title, verbose);
>           g_object_set(viewer, "guest-name", uri, NULL);
> -#if HAVE_SPICE_GTK
> +#ifdef HAVE_SPICE_GTK
>       }
>   #endif
>       if (viewer == NULL)
> diff --git a/src/remote-viewer.c b/src/remote-viewer.c
> index 7a80b8a..53470ef 100644
> --- a/src/remote-viewer.c
> +++ b/src/remote-viewer.c
> @@ -62,7 +62,7 @@ G_DEFINE_TYPE (RemoteViewer, remote_viewer, VIRT_VIEWER_TYPE_APP)
>   #define GET_PRIVATE(o)                                                        \
>       (G_TYPE_INSTANCE_GET_PRIVATE ((o), REMOTE_VIEWER_TYPE, RemoteViewerPrivate))
>
> -#if HAVE_SPICE_GTK
> +#ifdef HAVE_SPICE_GTK
>   enum {
>       PROP_0,
>       PROP_CONTROLLER,
> @@ -71,13 +71,13 @@ enum {
>   #endif
>
>   static gboolean remote_viewer_start(VirtViewerApp *self);
> -#if HAVE_SPICE_GTK
> +#ifdef HAVE_SPICE_GTK
>   static int remote_viewer_activate(VirtViewerApp *self);
>   static void remote_viewer_window_added(VirtViewerApp *self, VirtViewerWindow *win);
>   static void spice_foreign_menu_updated(RemoteViewer *self);
>   #endif
>
> -#if HAVE_SPICE_GTK
> +#ifdef HAVE_SPICE_GTK
>   static void
>   remote_viewer_get_property (GObject *object, guint property_id,
>                               GValue *value, GParamSpec *pspec)
> @@ -141,26 +141,26 @@ remote_viewer_dispose (GObject *object)
>   static void
>   remote_viewer_class_init (RemoteViewerClass *klass)
>   {
> -#if HAVE_SPICE_GTK
> +#ifdef HAVE_SPICE_GTK
>       GObjectClass *object_class = G_OBJECT_CLASS (klass);
>   #endif
>       VirtViewerAppClass *app_class = VIRT_VIEWER_APP_CLASS (klass);
>
>       g_type_class_add_private (klass, sizeof (RemoteViewerPrivate));
>
> -#if HAVE_SPICE_GTK
> +#ifdef HAVE_SPICE_GTK
>       object_class->get_property = remote_viewer_get_property;
>       object_class->set_property = remote_viewer_set_property;
>       object_class->dispose = remote_viewer_dispose;
>   #endif
>
>       app_class->start = remote_viewer_start;
> -#if HAVE_SPICE_GTK
> +#ifdef HAVE_SPICE_GTK
>       app_class->activate = remote_viewer_activate;
>       app_class->window_added = remote_viewer_window_added;
>   #endif
>
> -#if HAVE_SPICE_GTK
> +#ifdef HAVE_SPICE_GTK
>       g_object_class_install_property(object_class,
>                                       PROP_CONTROLLER,
>                                       g_param_spec_object("controller",
> @@ -198,7 +198,7 @@ remote_viewer_new(const gchar *uri, const gchar *title, gboolean verbose)
>                           NULL);
>   }
>
> -#if HAVE_SPICE_GTK
> +#ifdef HAVE_SPICE_GTK
>   static void
>   foreign_menu_title_changed(SpiceCtrlForeignMenu *menu G_GNUC_UNUSED,
>                              GParamSpec *pspec G_GNUC_UNUSED,
> @@ -750,14 +750,14 @@ create_ovirt_session(VirtViewerApp *app, const char *uri)
>       gtlsport = g_strdup_printf("%d", secure_port);
>
>       if (type == OVIRT_VM_DISPLAY_SPICE) {
> -#if HAVE_SPICE_GTK
> +#ifdef HAVE_SPICE_GTK
>           session_type = "spice";
>   #else
>           g_debug("This binary was compiled without SPICE support");
>           goto error;
>   #endif
>       } else if (type == OVIRT_VM_DISPLAY_VNC) {
> -#if HAVE_GTK_VNC
> +#ifdef HAVE_GTK_VNC
>           session_type = "vnc";
>   #else
>           g_debug("This binary was compiled without VNC support");
> @@ -774,7 +774,7 @@ create_ovirt_session(VirtViewerApp *app, const char *uri)
>       if (virt_viewer_app_create_session(app, session_type) < 0)
>           goto error;
>
> -#if HAVE_SPICE_GTK
> +#ifdef HAVE_SPICE_GTK
>       if (type == OVIRT_VM_DISPLAY_SPICE) {
>           SpiceSession *session;
>           GByteArray *ca_cert;
> @@ -818,7 +818,7 @@ remote_viewer_start(VirtViewerApp *app)
>   {
>       g_return_val_if_fail(REMOTE_VIEWER_IS(app), FALSE);
>
> -#if HAVE_SPICE_GTK
> +#ifdef HAVE_SPICE_GTK
>       RemoteViewer *self = REMOTE_VIEWER(app);
>       RemoteViewerPrivate *priv = self->priv;
>   #endif
> @@ -828,7 +828,7 @@ remote_viewer_start(VirtViewerApp *app)
>       gchar *guri = NULL;
>       gchar *type = NULL;
>
> -#if HAVE_SPICE_GTK
> +#ifdef HAVE_SPICE_GTK
>       g_signal_connect(app, "notify", G_CALLBACK(app_notified), self);
>
>       if (priv->controller) {
> @@ -874,7 +874,7 @@ remote_viewer_start(VirtViewerApp *app)
>               virt_viewer_app_simple_message_dialog(app, _("Cannot determine the connection type from URI"));
>               goto cleanup;
>           }
> -#if HAVE_OVIRT
> +#ifdef HAVE_OVIRT
>           if (g_strcmp0(type, "ovirt") == 0) {
>               if (!create_ovirt_session(app, guri)) {
>                   virt_viewer_app_simple_message_dialog(app, _("Couldn't open oVirt session"));
> @@ -895,7 +895,7 @@ remote_viewer_start(VirtViewerApp *app)
>               virt_viewer_app_simple_message_dialog(app, _("Failed to initiate connection"));
>               goto cleanup;
>           }
> -#if HAVE_SPICE_GTK
> +#ifdef HAVE_SPICE_GTK
>       }
>   #endif
>
>




More information about the virt-tools-list mailing list