[gtk+] Fix various warnings



commit a0faf5a51ced242985e993abc2bc6684863564e0
Author: Руслан Ижбулатов <lrn1986 gmail com>
Date:   Wed Aug 13 18:43:51 2014 +0000

    Fix various warnings
    
    https://bugzilla.gnome.org/show_bug.cgi?id=734737

 gdk/win32/gdkkeys-win32.c      |   24 +++++++++++++-----------
 gdk/win32/gdkproperty-win32.c  |    2 +-
 gdk/win32/gdkselection-win32.c |    6 +++---
 gtk/gtkprint-win32.c           |    4 ++++
 gtk/gtkprintoperation-win32.c  |   10 +++++++---
 gtk/gtkwin32embedwidget.c      |    4 ++--
 gtk/inspector/visual.c         |    2 +-
 7 files changed, 31 insertions(+), 21 deletions(-)
---
diff --git a/gdk/win32/gdkkeys-win32.c b/gdk/win32/gdkkeys-win32.c
index ca2e922..fe9c05c 100644
--- a/gdk/win32/gdkkeys-win32.c
+++ b/gdk/win32/gdkkeys-win32.c
@@ -65,6 +65,8 @@ static GdkKeymap *default_keymap = NULL;
 
 static guint *keysym_tab = NULL;
 
+#define KEY_STATE_SIZE 256
+
 #ifdef G_ENABLE_DEBUG
 static void
 print_keysym_tab (void)
@@ -74,7 +76,7 @@ print_keysym_tab (void)
   g_print ("keymap:%s%s\n",
           _gdk_keyboard_has_altgr ? " (uses AltGr)" : "",
           (gdk_shift_modifiers & GDK_LOCK_MASK) ? " (has ShiftLock)" : "");
-  for (vk = 0; vk < 256; vk++)
+  for (vk = 0; vk < KEY_STATE_SIZE; vk++)
     {
       gint state;
       
@@ -279,12 +281,12 @@ set_shift_vks (guchar *key_state,
 }
 
 static void
-reset_after_dead (guchar key_state[256])
+reset_after_dead (guchar key_state[KEY_STATE_SIZE])
 {
-  guchar temp_key_state[256];
+  guchar temp_key_state[KEY_STATE_SIZE];
   wchar_t wcs[2];
 
-  memmove (temp_key_state, key_state, sizeof (key_state));
+  memmove (temp_key_state, key_state, KEY_STATE_SIZE);
 
   temp_key_state[VK_SHIFT] =
     temp_key_state[VK_CONTROL] =
@@ -348,7 +350,7 @@ static void
 update_keymap (void)
 {
   static guint current_serial = 0;
-  guchar key_state[256];
+  guchar key_state[KEY_STATE_SIZE];
   guint scancode;
   guint vk;
   gboolean capslock_tested = FALSE;
@@ -359,14 +361,14 @@ update_keymap (void)
   current_serial = _gdk_keymap_serial;
 
   if (keysym_tab == NULL)
-    keysym_tab = g_new (guint, 4*256);
+    keysym_tab = g_new (guint, 4*KEY_STATE_SIZE);
 
   memset (key_state, 0, sizeof (key_state));
 
   _gdk_keyboard_has_altgr = FALSE;
   gdk_shift_modifiers = GDK_SHIFT_MASK;
 
-  for (vk = 0; vk < 256; vk++)
+  for (vk = 0; vk < KEY_STATE_SIZE; vk++)
     {
       if ((scancode = MapVirtualKey (vk, 0)) == 0 &&
          vk != VK_DIVIDE)
@@ -583,7 +585,7 @@ gdk_win32_keymap_get_entries_for_keyval (GdkKeymap     *keymap,
       
       update_keymap ();
 
-      for (vk = 0; vk < 256; vk++)
+      for (vk = 0; vk < KEY_STATE_SIZE; vk++)
        {
          gint i;
 
@@ -651,7 +653,7 @@ gdk_win32_keymap_get_entries_for_keycode (GdkKeymap     *keymap,
   g_return_val_if_fail (n_entries != NULL, FALSE);
 
   if (hardware_keycode <= 0 ||
-      hardware_keycode >= 256)
+      hardware_keycode >= KEY_STATE_SIZE)
     {
       if (keys)
         *keys = NULL;
@@ -747,7 +749,7 @@ gdk_win32_keymap_lookup_key (GdkKeymap          *keymap,
 
   update_keymap ();
   
-  if (key->keycode >= 256 ||
+  if (key->keycode >= KEY_STATE_SIZE ||
       key->group < 0 || key->group >= 2 ||
       key->level < 0 || key->level >= 2)
     return 0;
@@ -796,7 +798,7 @@ gdk_win32_keymap_translate_keyboard_state (GdkKeymap       *keymap,
   if (keymap != NULL && keymap != gdk_keymap_get_default ())
     return FALSE;
 
-  if (hardware_keycode >= 256)
+  if (hardware_keycode >= KEY_STATE_SIZE)
     return FALSE;
 
   if (group < 0 || group >= 2)
diff --git a/gdk/win32/gdkproperty-win32.c b/gdk/win32/gdkproperty-win32.c
index a447c06..700fd85 100644
--- a/gdk/win32/gdkproperty-win32.c
+++ b/gdk/win32/gdkproperty-win32.c
@@ -415,7 +415,7 @@ _gdk_win32_screen_get_setting (GdkScreen   *screen,
        */
       if (!GetVersionEx (&info) ||
           info.dwMajorVersion > 6 ||
-          info.dwMajorVersion == 6 && info.dwMinorVersion >= 2)
+          (info.dwMajorVersion == 6 && info.dwMinorVersion >= 2))
         return FALSE;
 
       /* check whether the system default ANSI codepage matches the
diff --git a/gdk/win32/gdkselection-win32.c b/gdk/win32/gdkselection-win32.c
index 2bb7ffd..6903943 100644
--- a/gdk/win32/gdkselection-win32.c
+++ b/gdk/win32/gdkselection-win32.c
@@ -531,7 +531,7 @@ _gdk_win32_display_convert_selection (GdkDisplay *display,
       if ((hdata = GetClipboardData (CF_UNICODETEXT)) != NULL)
        {
          wchar_t *ptr, *p, *q;
-         guchar *data;
+         gchar *data;
          glong length, wclen;
 
          if ((ptr = GlobalLock (hdata)) != NULL)
@@ -559,7 +559,7 @@ _gdk_win32_display_convert_selection (GdkDisplay *display,
 
              if (data)
                selection_property_store (requestor, _utf8_string, 8,
-                                         data, strlen (data) + 1);
+                                         (guchar *) data, strlen (data) + 1);
              GlobalUnlock (hdata);
            }
        }
@@ -940,7 +940,7 @@ gdk_text_property_to_text_list_for_display (GdkDisplay   *display,
     
   g_get_charset (&charset);
 
-  result = g_convert (text, length, charset, source_charset,
+  result = g_convert ((const gchar *) text, length, charset, source_charset,
                      NULL, NULL, NULL);
   g_free (source_charset);
 
diff --git a/gtk/gtkprint-win32.c b/gtk/gtkprint-win32.c
index 04d614c..bc4e7c3 100644
--- a/gtk/gtkprint-win32.c
+++ b/gtk/gtkprint-win32.c
@@ -17,9 +17,13 @@
  */
 
 #ifndef _MSC_VER
+#ifndef _WIN32_WINNT
 #define _WIN32_WINNT 0x0500
+#endif
+#ifndef WINVER
 #define WINVER _WIN32_WINNT
 #endif
+#endif
 
 #include "config.h"
 #include "gtkprint-win32.h"
diff --git a/gtk/gtkprintoperation-win32.c b/gtk/gtkprintoperation-win32.c
index d537a34..64f7714 100644
--- a/gtk/gtkprintoperation-win32.c
+++ b/gtk/gtkprintoperation-win32.c
@@ -17,9 +17,13 @@
  */
 
 #ifndef _MSC_VER
+#ifndef _WIN32_WINNT
 #define _WIN32_WINNT 0x0500
+#endif
+#ifndef WINVER
 #define WINVER _WIN32_WINNT
 #endif
+#endif
 
 #define COBJMACROS
 #include "config.h"
@@ -680,7 +684,7 @@ devmode_to_settings (GtkPrintSettings *settings,
                              devmode->dmDriverVersion);
   if (devmode->dmDriverExtra != 0)
     {
-      char *extra = g_base64_encode (((char *)devmode) + sizeof (DEVMODEW),
+      char *extra = g_base64_encode (((const guchar *)devmode) + sizeof (DEVMODEW),
                                     devmode->dmDriverExtra);
       gtk_print_settings_set (settings,
                              GTK_PRINT_SETTINGS_WIN32_DRIVER_EXTRA,
@@ -935,10 +939,10 @@ devmode_from_settings (GtkPrintSettings *settings,
 {
   HANDLE hDevMode;
   LPDEVMODEW devmode;
-  char *extras;
+  guchar *extras;
   GtkPaperSize *paper_size;
   const char *extras_base64;
-  int extras_len;
+  gsize extras_len;
   const char *val;
 
   extras = NULL;
diff --git a/gtk/gtkwin32embedwidget.c b/gtk/gtkwin32embedwidget.c
index 383da0e..a4738c3 100644
--- a/gtk/gtkwin32embedwidget.c
+++ b/gtk/gtkwin32embedwidget.c
@@ -200,7 +200,7 @@ gtk_win32_embed_widget_realize (GtkWidget *widget)
   gtk_widget_get_allocation (widget, &allocation);
 
   attributes.window_type = GDK_WINDOW_CHILD;
-  attributes.title = gtk_window_get_title (window);
+  attributes.title = (gchar *) gtk_window_get_title (window);
   _gtk_window_get_wmclass (window, &attributes.wmclass_name, &attributes.wmclass_class);
   attributes.width = allocation.width;
   attributes.height = allocation.height;
@@ -219,7 +219,7 @@ gtk_win32_embed_widget_realize (GtkWidget *widget)
                            GDK_FOCUS_CHANGE_MASK);
 
   attributes_mask = GDK_WA_VISUAL;
-  attributes_mask |= (gtk_window_get_title (window) ? GDK_WA_TITLE : 0);
+  attributes_mask |= (attributes.title ? GDK_WA_TITLE : 0);
   attributes_mask |= (attributes.wmclass_name ? GDK_WA_WMCLASS : 0);
 
   gdk_window = gdk_window_new (embed_widget->parent_window,
diff --git a/gtk/inspector/visual.c b/gtk/inspector/visual.c
index f2bb18a..ab11cfa 100644
--- a/gtk/inspector/visual.c
+++ b/gtk/inspector/visual.c
@@ -188,7 +188,7 @@ get_data_path (const gchar *subdir)
 {
   gchar *base_datadir, *full_datadir;
 #if defined (GDK_WINDOWING_WIN32) || defined (GDK_WINDOWING_QUARTZ)
-  base_datadir = _gtk_get_datadir();
+  base_datadir = g_strdup (_gtk_get_datadir());
 #else
   base_datadir = g_strdup (GTK_DATADIR);
 #endif


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]