]> code.delx.au - gnu-emacs/commitdiff
Fix compiler warnings in Cygwin-w32 build
authorKen Brown <kbrown@cornell.edu>
Tue, 21 Jun 2016 03:05:12 +0000 (23:05 -0400)
committerKen Brown <kbrown@cornell.edu>
Tue, 21 Jun 2016 03:05:12 +0000 (23:05 -0400)
* src/conf_post.h (DebPrint) [!EMACSDEBUG]: Add empty do-while
loop to avoid compiler warnings about empty body of 'if'
statement.

* src/image.c [HAVE_NTGUI] (DefaultDepthOfScreen): Disable unused
macro.
(x_create_bitmap_from_data): Declare 'frame'.
(x_create_bitmap_from_file): Don't declare unused variable
'dpyinfo'.

* src/lisp.h (AUTO_STRING_WITH_LEN): Avoid initialization to
prevent "jump-misses-init" compiler warnings.

* src/w32fns.c (check_w32_winkey_state): Define and use only if
WINDOWSNT.
(Fx_show_tip): Declare 'f'.
(Fx_file_dialog): Declare 'filter_a' only if not NTGUI_UNICODE.
(w32_strerror): Use format specifier %d for sprintf argument of
type int.
(emacs_abort): Cast sprintf argument of type DWORD to unsigned
int, and use format specifier %x, for compatibility with Cygwin.
(unicode_append_menu) [NTGUI_UNICODE]:
* src/w32menu.c [NTGUI_UNICODE] (get_menu_item_info)
(set_menu_item_info, unicode_append_menu)
(unicode_message_box):
* src/menu.c [NTGUI_UNICODE] (unicode_append_menu): Define as
functions rather than macros to avoid "address will always
evaluate as true" compiler warnings.

* src/w32font.c (w32_to_x_charset): Use format specifier %d for
sprintf argument of type int.

* src/w32term.c (x_draw_glyphless_glyph_string_foreground): Cast
sprintf argument of type int to unsigned int to match %X format
specifier.
(w32_scroll_bar_handle_click):
(w32_horizontal_scroll_bar_handle_click): Declare 'f'.

* src/w32term.h (FRAME_DISPLAY_INFO): Explicitly discard unused
argument.

src/conf_post.h
src/image.c
src/lisp.h
src/menu.c
src/w32fns.c
src/w32font.c
src/w32menu.c
src/w32term.c
src/w32term.h

index 4459caf3f99a3710f0e0a44d7a9497b2813f03c8..431b7a9d8268d012004e8887537fc6adf3c9359b 100644 (file)
@@ -211,7 +211,8 @@ You lose; /* Emacs for DOS must be compiled with DJGPP */
 extern void _DebPrint (const char *fmt, ...);
 #  define DebPrint(stuff) _DebPrint stuff
 # else
-#  define DebPrint(stuff)
+/* Avoid compiler warnings about empty body of 'if' statement.  */
+#  define DebPrint(stuff) do {} while (false)
 # endif
 #endif
 
index 657852b1a804bf4d9a40d1e6db4ec5e2c7da5554..0df415c37c937787215c4e1de3ea3cba87bc331b 100644 (file)
@@ -80,7 +80,9 @@ typedef struct w32_bitmap_record Bitmap_Record;
 #define PIX_MASK_DRAW  1
 
 #define x_defined_color w32_defined_color
+#if 0                          /* unused */
 #define DefaultDepthOfScreen(screen) (one_w32_display_info.n_cbits)
+#endif
 
 #endif /* HAVE_NTGUI */
 
@@ -223,6 +225,7 @@ x_create_bitmap_from_data (struct frame *f, char *bits, unsigned int width, unsi
 #endif /* HAVE_X_WINDOWS */
 
 #ifdef HAVE_NTGUI
+  Lisp_Object frame UNINIT;    /* The value is not used.  */
   Pixmap bitmap;
   bitmap = CreateBitmap (width, height,
                         FRAME_DISPLAY_INFO (XFRAME (frame))->n_planes,
@@ -272,9 +275,9 @@ x_create_bitmap_from_file (struct frame *f, Lisp_Object file)
 {
 #ifdef HAVE_NTGUI
   return -1;  /* W32_TODO : bitmap support */
-#endif /* HAVE_NTGUI */
-
+#else
   Display_Info *dpyinfo = FRAME_DISPLAY_INFO (f);
+#endif
 
 #ifdef HAVE_NS
   ptrdiff_t id;
index e0eb52a84ea220103a4932414fe65ccbfd0b8d20..6a8f829546e1643a6fd220ac20f23cdef8d13555 100644 (file)
@@ -4634,8 +4634,10 @@ enum
    STR's value is not necessarily copied.  The resulting Lisp string
    should not be modified or made visible to user code.  */
 
+/* Avoid initializing NAME to prevent "jump-misses-init" compiler
+   warnings.  */
 #define AUTO_STRING_WITH_LEN(name, str, len)                           \
-  Lisp_Object name =                                                   \
+  Lisp_Object name; name =                                             \
     (USE_STACK_STRING                                                  \
      ? (make_lisp_ptr                                                  \
        ((&(union Aligned_String)                                       \
index e3d943e109f348f0c98c04e93012456457d37cd0..90bb19a2e94059d48ebf8c6a2fc36e093e97b984 100644 (file)
@@ -42,11 +42,7 @@ along with GNU Emacs.  If not, see <http://www.gnu.org/licenses/>.  */
 #endif /* HAVE_WINDOW_SYSTEM */
 
 #ifdef HAVE_NTGUI
-# ifdef NTGUI_UNICODE
-# define unicode_append_menu AppendMenuW
-# else /* !NTGUI_UNICODE */
 extern AppendMenuW_Proc unicode_append_menu;
-# endif /* NTGUI_UNICODE */
 #endif /* HAVE_NTGUI  */
 
 #include "menu.h"
index f2b438cbe0ee873c9fc7349639fefe2f0754973f..bc9c74748d74f9660054c87ccacd1f516f64c8cf 100644 (file)
@@ -186,11 +186,7 @@ MonitorFromWindow_Proc monitor_from_window_fn = NULL;
 EnumDisplayMonitors_Proc enum_display_monitors_fn = NULL;
 GetTitleBarInfo_Proc get_title_bar_info_fn = NULL;
 
-#ifdef NTGUI_UNICODE
-#define unicode_append_menu AppendMenuW
-#else /* !NTGUI_UNICODE */
 extern AppendMenuW_Proc unicode_append_menu;
-#endif /* NTGUI_UNICODE */
 
 /* Flag to selectively ignore WM_IME_CHAR messages.  */
 static int ignore_ime_char = 0;
@@ -2406,6 +2402,7 @@ hook_w32_key (int hook, int modifier, int vkey)
     }
 }
 
+#ifdef WINDOWSNT
 /* Check the current Win key pressed state.  */
 int
 check_w32_winkey_state (int vkey)
@@ -2433,6 +2430,7 @@ check_w32_winkey_state (int vkey)
     }
   return 0;
 }
+#endif /* WINDOWSNT */
 
 /* Reset the keyboard hook state.  Locking the workstation with Win-L
    leaves the Win key(s) "down" from the hook's point of view - the
@@ -2623,8 +2621,10 @@ modifier_set (int vkey)
       else
        return (GetKeyState (vkey) & 0x1);
     }
+#ifdef WINDOWSNT
   if (w32_kbdhook_active && (vkey == VK_LWIN || vkey == VK_RWIN))
     return check_w32_winkey_state (vkey);
+#endif
 
   if (!modifiers_recorded)
     return (GetKeyState (vkey) & 0x8000);
@@ -7043,6 +7043,7 @@ Text larger than the specified size is clipped.  */)
 
       /* Create a frame for the tooltip, and record it in the global
         variable tip_frame.  */
+      struct frame *f;         /* The value is unused.  */
       if (NILP (tip_frame = x_create_tip_frame (FRAME_DISPLAY_INFO (f), parms)))
        {
          /* Creating the tip frame failed.  */
@@ -7288,7 +7289,9 @@ value of DIR as in previous invocations; this is standard Windows behavior.  */)
 {
   /* Filter index: 1: All Files, 2: Directories only  */
   static const wchar_t filter_w[] = L"All Files (*.*)\0*.*\0Directories\0*|*\0";
+#ifndef NTGUI_UNICODE
   static const char filter_a[] = "All Files (*.*)\0*.*\0Directories\0*|*\0";
+#endif
 
   Lisp_Object filename = default_filename;
   struct frame *f = SELECTED_FRAME ();
@@ -8962,7 +8965,7 @@ w32_strerror (int error_no)
       --ret;
   buf[ret] = '\0';
   if (!ret)
-    sprintf (buf, "w32 error %u", error_no);
+    sprintf (buf, "w32 error %d", error_no);
 
   return buf;
 }
@@ -10331,8 +10334,8 @@ emacs_abort (void)
               but not on Windows 7.  addr2line doesn't mind a missing
               "0x", but will be confused by an extra one.  */
            if (except_addr)
-             sprintf (buf, "\r\nException 0x%lx at this address:\r\n%p\r\n",
-                      except_code, except_addr);
+             sprintf (buf, "\r\nException 0x%x at this address:\r\n%p\r\n",
+                      (unsigned int) except_code, except_addr);
            if (stderr_fd >= 0)
              {
                if (except_addr)
index b8884a50db9a0ea1d1439f14b432c5d94adb63e3..4d15cffb9f69664e534e4feae322f728bbb78833 100644 (file)
@@ -1747,7 +1747,7 @@ w32_to_x_charset (int fncharset, char *matching)
 
     default:
       /* Encode numerical value of unknown charset.  */
-      sprintf (buf, "*-#%u", fncharset);
+      sprintf (buf, "*-#%d", fncharset);
       return buf;
     }
 
@@ -1834,7 +1834,7 @@ w32_to_x_charset (int fncharset, char *matching)
     /* If no match, encode the numeric value. */
     if (!best_match)
       {
-        sprintf (buf, "*-#%u", fncharset);
+        sprintf (buf, "*-#%d", fncharset);
         return buf;
       }
 
index fecbf33a12bcd6a65dafd37c45af898fa4e93904..13296d9d855a77fd7c8aee28018e0218bb41fdc9 100644 (file)
@@ -77,10 +77,10 @@ typedef int (WINAPI * MessageBoxW_Proc) (
     IN UINT type);
 
 #ifdef NTGUI_UNICODE
-#define get_menu_item_info GetMenuItemInfoA
-#define set_menu_item_info SetMenuItemInfoA
-#define unicode_append_menu AppendMenuW
-#define unicode_message_box MessageBoxW
+GetMenuItemInfoA_Proc get_menu_item_info = GetMenuItemInfoA;
+SetMenuItemInfoA_Proc set_menu_item_info = SetMenuItemInfoA;
+AppendMenuW_Proc unicode_append_menu = AppendMenuW;
+MessageBoxW_Proc unicode_message_box = MessageBoxW;
 #else /* !NTGUI_UNICODE */
 GetMenuItemInfoA_Proc get_menu_item_info = NULL;
 SetMenuItemInfoA_Proc set_menu_item_info = NULL;
index c16c8f4eecc1a80aa630243631122b4cb47307a9..7ef34079e30bfad581ce59efb934dd55ab62824b 100644 (file)
@@ -1434,7 +1434,7 @@ x_draw_glyphless_glyph_string_foreground (struct glyph_string *s)
        {
          sprintf ((char *) buf, "%0*X",
                   glyph->u.glyphless.ch < 0x10000 ? 4 : 6,
-                  glyph->u.glyphless.ch);
+                  (unsigned int) glyph->u.glyphless.ch);
          str = buf;
        }
 
@@ -4198,6 +4198,7 @@ w32_scroll_bar_handle_click (struct scroll_bar *bar, W32Msg *msg,
       y = si.nPos;
 
     bar->dragging = 0;
+    struct frame *f;           /* Value is not used.  */
     FRAME_DISPLAY_INFO (f)->last_mouse_scroll_bar_pos = msg->msg.wParam;
 
     switch (sb_event)
@@ -4313,6 +4314,7 @@ w32_horizontal_scroll_bar_handle_click (struct scroll_bar *bar, W32Msg *msg,
     y = si.nMax - si.nPage;
 
     bar->dragging = 0;
+    struct frame *f;           /* Value is not used.  */
     FRAME_DISPLAY_INFO (f)->last_mouse_scroll_bar_pos = msg->msg.wParam;
 
     switch (sb_event)
index e134da5ea5c9d3e93f12dce0edf45f9592b7e05c..320477073a5268cf26015ac9f4ce94b344c3dc0f 100644 (file)
@@ -399,7 +399,7 @@ extern struct w32_output w32term_display;
 #define FRAME_BASELINE_OFFSET(f) ((f)->output_data.w32->baseline_offset)
 
 /* This gives the w32_display_info structure for the display F is on.  */
-#define FRAME_DISPLAY_INFO(f) (&one_w32_display_info)
+#define FRAME_DISPLAY_INFO(f) ((void) (f), (&one_w32_display_info))
 
 /* This is the `Display *' which frame F is on.  */
 #define FRAME_X_DISPLAY(f) (0)