[Spice-devel] [PATCH spice-gtk 03/15] Fix const-correctness of functions & add explicit casts

Daniel P. Berrange berrange at redhat.com
Tue Mar 13 06:40:01 PDT 2012


From: "Daniel P. Berrange" <berrange at redhat.com>

Some functions should be declared to take const char * instead
of plain char *. In other places we intentionally cast away
const-ness, so we should add explicit casts to stop compiler
warnings
---
 gtk/snappy.c         |    2 +-
 gtk/spice-channel.c  |    2 +-
 gtk/spicy.c          |   16 ++++++++--------
 gtk/usb-acl-helper.c |    2 +-
 4 files changed, 11 insertions(+), 11 deletions(-)

diff --git a/gtk/snappy.c b/gtk/snappy.c
index 32bd0fb..f7d0f04 100644
--- a/gtk/snappy.c
+++ b/gtk/snappy.c
@@ -25,7 +25,7 @@
 #include "spice-cmdline.h"
 
 /* config */
-static char *outf      = "snappy.ppm";
+static const char *outf      = "snappy.ppm";
 static gboolean version = FALSE;
 
 /* state */
diff --git a/gtk/spice-channel.c b/gtk/spice-channel.c
index a960d87..cdc86ba 100644
--- a/gtk/spice-channel.c
+++ b/gtk/spice-channel.c
@@ -530,7 +530,7 @@ void *spice_msg_in_raw(SpiceMsgIn *in, int *len)
     return in->data;
 }
 
-static void hexdump(char *prefix, unsigned char *data, int len)
+static void hexdump(const char *prefix, unsigned char *data, int len)
 {
     int i;
 
diff --git a/gtk/spicy.c b/gtk/spicy.c
index aa00582..8e9d051 100644
--- a/gtk/spicy.c
+++ b/gtk/spicy.c
@@ -79,8 +79,8 @@ struct spice_connection {
     SpiceGtkSession  *gtk_session;
     spice_window     *wins[4];
     SpiceAudio       *audio;
-    char             *mouse_state;
-    char             *agent_state;
+    const char       *mouse_state;
+    const char       *agent_state;
     gboolean         agent_connected;
     int              channels;
     int              disconnecting;
@@ -515,9 +515,9 @@ static void menu_cb_about(GtkAction *action, void *data)
 {
     char *comments = _("gtk test client app for the\n"
         "spice remote desktop protocol");
-    static char *copyright = "(c) 2010 Red Hat";
-    static char *website = "http://www.spice-space.org";
-    static char *authors[] = { "Gerd Hoffmann <kraxel at redhat.com>",
+    static const char *copyright = "(c) 2010 Red Hat";
+    static const char *website = "http://www.spice-space.org";
+    static const char *authors[] = { "Gerd Hoffmann <kraxel at redhat.com>",
                                "Marc-André Lureau <marcandre.lureau at redhat.com>",
                                NULL };
     struct spice_window *win = data;
@@ -1302,9 +1302,9 @@ static void recent_add(SpiceSession *session)
 {
     GtkRecentManager *recent;
     GtkRecentData meta = {
-        .mime_type    = "application/x-spice",
-        .app_name     = "spicy",
-        .app_exec     = "spicy --uri=%u",
+        .mime_type    = (char*)"application/x-spice",
+        .app_name     = (char*)"spicy",
+        .app_exec     = (char*)"spicy --uri=%u",
     };
     char *uri;
 
diff --git a/gtk/usb-acl-helper.c b/gtk/usb-acl-helper.c
index 6a459c5..12596d0 100644
--- a/gtk/usb-acl-helper.c
+++ b/gtk/usb-acl-helper.c
@@ -194,7 +194,7 @@ void spice_usb_acl_helper_open_acl(SpiceUsbAclHelper *self,
     GIOStatus status;
     GPid helper_pid;
     gsize bytes_written;
-    gchar *argv[] = { ACL_HELPER_PATH"/spice-client-glib-usb-acl-helper", NULL };
+    gchar *argv[] = { (char*) ACL_HELPER_PATH"/spice-client-glib-usb-acl-helper", NULL };
     gint in, out;
     gchar buf[128];
 
-- 
1.7.7.6



More information about the Spice-devel mailing list