unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
* bug#23771: Eliminating compiler warnings
@ 2016-06-15  2:04 Ken Brown
  2016-06-15 14:44 ` Eli Zaretskii
  2016-06-15 20:24 ` Richard Stallman
  0 siblings, 2 replies; 14+ messages in thread
From: Ken Brown @ 2016-06-15  2:04 UTC (permalink / raw)
  To: 23771

[-- Attachment #1: Type: text/plain, Size: 1435 bytes --]

I would like to get rid of all compiler warnings in the Cygwin builds 
(X11, w32, and nox).  There are currently none in the X11 build, but 
there are a lot in the other builds.  Many of the warnings in the w32 
build probably occur in the MinGW build also.  And all of the warnings 
in the nox build would occur in any build without a window system.

The seven patches attached attempt to eliminate all the currently 
existing warnings.  There is one patch for each type of warning.  Since 
they affect other platforms besides Cygwin, I won't install them until 
someone has had a chance to review them.  There's obviously no rush 
about this.

Two comments: First, patch 0006-... is there because there might be a 
jump over an AUTO_STRING call.  (This happens exactly once in the 
Cygwin-w32 build.)  It seems stupid to have to worry about this.  An 
alternative would be to just disable the -Wjump-misses-init warning.

Second, patch 0007-... is there because I couldn't think of a reasonable 
way to avoid -Waddress warnings when compiling w32fns.c, w32menu.c, and 
menu.c in the Cygwin-w32 build.  Everything I thought of would have made 
the code very ugly.  So I simply disabled that warning for the 
Cygwin-w32 build, and I took the liberty of doing the same thing for the 
MinGW build, which I think is also affected in some cases.  If someone 
sees a better way of eliminating those warnings, that would be preferable.

Ken

[-- Attachment #2: 0001-Eliminate-noreturn-warnings-if-there-s-no-window-sys.patch --]
[-- Type: text/plain, Size: 2983 bytes --]

From 15bda1697070a1fe97b1706fa27ac49c2439b6cb Mon Sep 17 00:00:00 2001
From: Ken Brown <kbrown@cornell.edu>
Date: Mon, 13 Jun 2016 17:11:57 -0400
Subject: [PATCH 1/7] =?UTF-8?q?Eliminate=20"noreturn"=20warnings=20if=20th?=
 =?UTF-8?q?ere=E2=80=99s=20no=20window=20system?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

* src/frame.c (decode_window_system_frame, check_window_system):
Define new _Noreturn versions if !HAVE_WINDOW_SYSTEM.
* src/frame.h: (decode_window_system_frame, check_window_system):
Adjust prototypes.
---
 src/frame.c | 18 ++++++++++++++++--
 src/frame.h |  6 ++++--
 2 files changed, 20 insertions(+), 4 deletions(-)

diff --git a/src/frame.c b/src/frame.c
index df97539..653d660 100644
--- a/src/frame.c
+++ b/src/frame.c
@@ -113,8 +113,6 @@ window_system_available (struct frame *f)
   return f ? FRAME_WINDOW_P (f) || FRAME_MSDOS_P (f) : x_display_list != NULL;
 }
 
-#endif /* HAVE_WINDOW_SYSTEM */
-
 struct frame *
 decode_window_system_frame (Lisp_Object frame)
 {
@@ -133,6 +131,22 @@ check_window_system (struct frame *f)
 	   : "Window system is not in use or not initialized");
 }
 
+#else  /* not HAVE_WINDOW_SYSTEM */
+
+_Noreturn void
+decode_window_system_frame (Lisp_Object frame)
+{
+  error ("Window system is not in use");
+}
+
+_Noreturn void
+check_window_system (struct frame *f)
+{
+  error ("Window system is not in use");
+}
+
+#endif	/* not HAVE_WINDOW_SYSTEM */
+
 /* Return the value of frame parameter PROP in frame FRAME.  */
 
 Lisp_Object
diff --git a/src/frame.h b/src/frame.h
index 7d64e00..0189ca1 100644
--- a/src/frame.h
+++ b/src/frame.h
@@ -1102,12 +1102,13 @@ extern Lisp_Object selected_frame;
 extern int frame_default_tool_bar_height;
 #endif
 
-extern struct frame *decode_window_system_frame (Lisp_Object);
 extern struct frame *decode_live_frame (Lisp_Object);
 extern struct frame *decode_any_frame (Lisp_Object);
 extern struct frame *make_initial_frame (void);
 extern struct frame *make_frame (bool);
 #ifdef HAVE_WINDOW_SYSTEM
+extern void check_window_system (struct frame *);
+extern struct frame *decode_window_system_frame (Lisp_Object);
 extern struct frame *make_minibuffer_frame (void);
 extern struct frame *make_frame_without_minibuffer (Lisp_Object,
                                                     struct kboard *,
@@ -1115,8 +1116,9 @@ extern struct frame *make_frame_without_minibuffer (Lisp_Object,
 extern bool window_system_available (struct frame *);
 #else /* not HAVE_WINDOW_SYSTEM */
 #define window_system_available(f) ((void) (f), false)
+extern _Noreturn void check_window_system (struct frame *);
+extern _Noreturn void decode_window_system_frame (Lisp_Object);
 #endif /* HAVE_WINDOW_SYSTEM */
-extern void check_window_system (struct frame *);
 extern void frame_make_pointer_invisible (struct frame *);
 extern void frame_make_pointer_visible (struct frame *);
 extern Lisp_Object delete_frame (Lisp_Object, Lisp_Object);
-- 
2.8.3


[-- Attachment #3: 0002-Fix-unused-variable-compiler-warnings.patch --]
[-- Type: text/plain, Size: 15577 bytes --]

From 3a373d7dc22bee795519f619e0504d23fb784cac Mon Sep 17 00:00:00 2001
From: Ken Brown <kbrown@cornell.edu>
Date: Tue, 14 Jun 2016 15:09:35 -0400
Subject: [PATCH 2/7] Fix "unused variable" compiler warnings

* src/frame.h (FRAME_FRINGE_COLS, FRAME_TOTAL_FRINGE_WIDTH)
(FRAME_LEFT_FRINGE_WIDTH, FRAME_RIGHT_FRINGE_WIDTH)
(FRAME_INTERNAL_BORDER_WIDTH, FRAME_RIGHT_DIVIDER_WIDTH)
(FRAME_BOTTOM_DIVIDER_WIDTH): Explicitly discard unused argument.

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

* src/w32fns.c (Fx_show_tip): Declare 'f'.
(Fx_file_dialog): Declare 'filter_a' only if not NTGUI_UNICODE.

* src/w32term.c (w32_scroll_bar_handle_click):
(w32_horizontal_scroll_bar_handle_click): Declare 'f'.

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

* src/xdisp.c (handle_single_display_spec): Declare
'fringe_bitmap' only if HAVE_WINDOW_SYSTEM.
(append_space_for_newline): Declare 'g' only if
HAVE_WINDOW_SYSTEM.
(Fmove_point_visually): Declare and set 'target_is_eol_p' only if
HAVE_WINDOW_SYSTEM.
(show_mouse_face): Declare and set 'f' and 'phys_cursor_p' only if
HAVE_WINDOW_SYSTEM.
(note_mode_line_or_margin_highlight): Declare and set 'cursor'
only if HAVE_WINDOW_SYSTEM.
(note_mouse_highlight): Declare and set 'cursor' and 'pointer'
only if HAVE_WINDOW_SYSTEM.

* src/xfaces.c (realize_default_face): Declare and set 'face' only
if HAVE_X_WINDOWS.

* src/frame.c (Ficonify_frame, Fset_frame_position): Declare and
set 'f' only if HAVE_WINDOW_SYSTEM.

* src/font.c (font_open_entity): Declare and set 'min_width' only
if HAVE_WINDOW_SYSTEM.

* src/dispextern.h (FACE_SUITABLE_FOR_ASCII_CHAR_P)
(FACE_FOR_CHAR): Explicitly discard unused arguments.

* src/composite.c (autocmp_chars): Declare and set 'f' only if
HAVE_WINDOW_SYSTEM.
---
 src/composite.c  |  2 ++
 src/dispextern.h |  7 +++++--
 src/font.c       |  7 ++++++-
 src/frame.c      |  6 ++----
 src/frame.h      | 14 +++++++-------
 src/image.c      |  6 +++---
 src/w32fns.c     |  4 +++-
 src/w32term.c    |  2 ++
 src/w32term.h    |  2 +-
 src/xdisp.c      | 34 +++++++++++++++++++++++++++-------
 src/xfaces.c     |  6 ++++--
 11 files changed, 62 insertions(+), 28 deletions(-)

diff --git a/src/composite.c b/src/composite.c
index bef1c5f..4f9758b 100644
--- a/src/composite.c
+++ b/src/composite.c
@@ -867,7 +867,9 @@ autocmp_chars (Lisp_Object rule, ptrdiff_t charpos, ptrdiff_t bytepos,
 	       Lisp_Object string)
 {
   ptrdiff_t count = SPECPDL_INDEX ();
+#ifdef HAVE_WINDOW_SYSTEM
   struct frame *f = XFRAME (win->frame);
+#endif
   Lisp_Object pos = make_number (charpos);
   ptrdiff_t to;
   ptrdiff_t pt = PT, pt_byte = PT_BYTE;
diff --git a/src/dispextern.h b/src/dispextern.h
index e83b7c7..987d7f8 100644
--- a/src/dispextern.h
+++ b/src/dispextern.h
@@ -1843,8 +1843,11 @@ struct face_cache
 
 #else /* not HAVE_WINDOW_SYSTEM */
 
-#define FACE_SUITABLE_FOR_ASCII_CHAR_P(FACE, CHAR) true
-#define FACE_FOR_CHAR(F, FACE, CHAR, POS, OBJECT) ((FACE)->id)
+#define FACE_SUITABLE_FOR_ASCII_CHAR_P(FACE, CHAR)	   \
+  ((void) (FACE), (void) (CHAR), true)
+#define FACE_FOR_CHAR(F, FACE, CHAR, POS, OBJECT)	   \
+  ((void) (F), (void) (FACE), (void) (CHAR), (void) (POS), \
+   (void) (OBJECT), (FACE)->id)
 
 #endif /* not HAVE_WINDOW_SYSTEM */
 
diff --git a/src/font.c b/src/font.c
index f289891..cedb400 100644
--- a/src/font.c
+++ b/src/font.c
@@ -2863,7 +2863,10 @@ font_open_entity (struct frame *f, Lisp_Object entity, int pixel_size)
   struct font_driver_list *driver_list;
   Lisp_Object objlist, size, val, font_object;
   struct font *font;
-  int min_width, height, psize;
+  int height, psize;
+#ifdef HAVE_WINDOW_SYSTEM
+  int min_width;
+#endif
 
   eassert (FONT_ENTITY_P (entity));
   size = AREF (entity, FONT_SIZE_INDEX);
@@ -2907,10 +2910,12 @@ font_open_entity (struct frame *f, Lisp_Object entity, int pixel_size)
 	Fcons (font_object, AREF (entity, FONT_OBJLIST_INDEX)));
 
   font = XFONT_OBJECT (font_object);
+#ifdef HAVE_WINDOW_SYSTEM
   min_width = (font->min_width ? font->min_width
 	       : font->average_width ? font->average_width
 	       : font->space_width ? font->space_width
 	       : 1);
+#endif
 
   int font_ascent, font_descent;
   get_font_ascent_descent (font, &font_ascent, &font_descent);
diff --git a/src/frame.c b/src/frame.c
index 653d660..3fcdd58 100644
--- a/src/frame.c
+++ b/src/frame.c
@@ -2143,13 +2143,12 @@ DEFUN ("iconify-frame", Ficonify_frame, Siconify_frame,
 If omitted, FRAME defaults to the currently selected frame.  */)
   (Lisp_Object frame)
 {
-  struct frame *f = decode_live_frame (frame);
-
   /* Don't allow minibuf_window to remain on an iconified frame.  */
   check_minibuf_window (frame, EQ (minibuf_window, selected_window));
 
   /* I think this should be done with a hook.  */
 #ifdef HAVE_WINDOW_SYSTEM
+  struct frame *f = decode_live_frame (frame);
   if (FRAME_WINDOW_P (f))
       x_iconify_frame (f);
 #endif
@@ -3015,13 +3014,12 @@ or bottom edge of the outer frame of FRAME relative to the right or
 bottom edge of FRAME's display.  */)
   (Lisp_Object frame, Lisp_Object x, Lisp_Object y)
 {
-  register struct frame *f = decode_live_frame (frame);
-
   CHECK_TYPE_RANGED_INTEGER (int, x);
   CHECK_TYPE_RANGED_INTEGER (int, y);
 
   /* I think this should be done with a hook.  */
 #ifdef HAVE_WINDOW_SYSTEM
+  register struct frame *f = decode_live_frame (frame);
   if (FRAME_WINDOW_P (f))
     x_set_offset (f, XINT (x), XINT (y), 1);
 #endif
diff --git a/src/frame.h b/src/frame.h
index 0189ca1..ea68421 100644
--- a/src/frame.h
+++ b/src/frame.h
@@ -1183,13 +1183,13 @@ extern Lisp_Object Vframe_list;
 
 #else /* not HAVE_WINDOW_SYSTEM */
 
-#define FRAME_FRINGE_COLS(F)	0
-#define FRAME_TOTAL_FRINGE_WIDTH(F)	0
-#define FRAME_LEFT_FRINGE_WIDTH(F)  0
-#define FRAME_RIGHT_FRINGE_WIDTH(F) 0
-#define FRAME_INTERNAL_BORDER_WIDTH(F) 0
-#define FRAME_RIGHT_DIVIDER_WIDTH(F) 0
-#define FRAME_BOTTOM_DIVIDER_WIDTH(F) 0
+#define FRAME_FRINGE_COLS(F) ((void) (F), 0)
+#define FRAME_TOTAL_FRINGE_WIDTH(F) ((void) (F), 0)
+#define FRAME_LEFT_FRINGE_WIDTH(F) ((void) (F), 0)
+#define FRAME_RIGHT_FRINGE_WIDTH(F) ((void) (F), 0)
+#define FRAME_INTERNAL_BORDER_WIDTH(F) ((void) (F), 0)
+#define FRAME_RIGHT_DIVIDER_WIDTH(F) ((void) (F), 0)
+#define FRAME_BOTTOM_DIVIDER_WIDTH(F) ((void) (F), 0)
 
 #endif /* not HAVE_WINDOW_SYSTEM */
 \f
diff --git a/src/image.c b/src/image.c
index 657852b..88ec2b7 100644
--- a/src/image.c
+++ b/src/image.c
@@ -80,7 +80,6 @@ typedef struct w32_bitmap_record Bitmap_Record;
 #define PIX_MASK_DRAW	1
 
 #define x_defined_color w32_defined_color
-#define DefaultDepthOfScreen(screen) (one_w32_display_info.n_cbits)
 
 #endif /* HAVE_NTGUI */
 
@@ -223,6 +222,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;
   Pixmap bitmap;
   bitmap = CreateBitmap (width, height,
 			 FRAME_DISPLAY_INFO (XFRAME (frame))->n_planes,
@@ -272,9 +272,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;
diff --git a/src/w32fns.c b/src/w32fns.c
index f2b438c..ff45f53 100644
--- a/src/w32fns.c
+++ b/src/w32fns.c
@@ -6888,7 +6888,7 @@ A tooltip's maximum size is specified by `x-max-tooltip-size'.
 Text larger than the specified size is clipped.  */)
   (Lisp_Object string, Lisp_Object frame, Lisp_Object parms, Lisp_Object timeout, Lisp_Object dx, Lisp_Object dy)
 {
-  struct frame *tip_f;
+  struct frame *f, *tip_f;
   struct window *w;
   int root_x, root_y;
   struct buffer *old_buffer;
@@ -7288,7 +7288,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 ();
diff --git a/src/w32term.c b/src/w32term.c
index c16c8f4..649e743 100644
--- a/src/w32term.c
+++ b/src/w32term.c
@@ -4184,6 +4184,7 @@ w32_scroll_bar_handle_click (struct scroll_bar *bar, W32Msg *msg,
     int dragging = bar->dragging;
     SCROLLINFO si;
     int sb_event = LOWORD (msg->msg.wParam);
+    struct frame *f;
 
     si.cbSize = sizeof (si);
     if (sb_event == SB_THUMBTRACK)
@@ -4298,6 +4299,7 @@ w32_horizontal_scroll_bar_handle_click (struct scroll_bar *bar, W32Msg *msg,
     int dragging = bar->dragging;
     SCROLLINFO si;
     int sb_event = LOWORD (msg->msg.wParam);
+    struct frame *f;
 
     si.cbSize = sizeof (si);
     if (sb_event == SB_THUMBTRACK)
diff --git a/src/w32term.h b/src/w32term.h
index e134da5..3204770 100644
--- a/src/w32term.h
+++ b/src/w32term.h
@@ -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)
diff --git a/src/xdisp.c b/src/xdisp.c
index d589080..9a58238 100644
--- a/src/xdisp.c
+++ b/src/xdisp.c
@@ -5017,7 +5017,9 @@ handle_single_display_spec (struct it *it, Lisp_Object spec, Lisp_Object object,
 	  || EQ (XCAR (spec), Qright_fringe))
       && CONSP (XCDR (spec)))
     {
+#ifdef HAVE_WINDOW_SYSTEM
       int fringe_bitmap;
+#endif
 
       if (it)
 	{
@@ -19509,8 +19511,9 @@ append_space_for_newline (struct it *it, bool default_face_p)
 	  struct text_pos saved_pos;
 	  Lisp_Object saved_object;
 	  struct face *face;
+#ifdef HAVE_WINDOW_SYSTEM
 	  struct glyph *g;
-
+#endif
 	  saved_object = it->object;
 	  saved_pos = it->position;
 
@@ -21687,8 +21690,9 @@ Value is the new character position of point.  */)
       int pt_x, target_x, pixel_width, pt_vpos;
       bool at_eol_p;
       bool overshoot_expected = false;
+#ifdef HAVE_WINDOW_SYSTEM
       bool target_is_eol_p = false;
-
+#endif
       /* Setup the arena.  */
       SET_TEXT_POS (pt, PT, PT_BYTE);
       start_display (&it, w, pt);
@@ -21802,7 +21806,9 @@ Value is the new character position of point.  */)
 	    {
 	      move_it_by_lines (&it, -1);
 	      target_x = it.last_visible_x - !FRAME_WINDOW_P (it.f);
+#ifdef HAVE_WINDOW_SYSTEM
 	      target_is_eol_p = true;
+#endif
 	      /* Under word-wrap, we don't know the x coordinate of
 		 the last character displayed on the previous line,
 		 which immediately precedes the wrap point.  To find
@@ -28594,7 +28600,9 @@ static void
 show_mouse_face (Mouse_HLInfo *hlinfo, enum draw_glyphs_face draw)
 {
   struct window *w = XWINDOW (hlinfo->mouse_face_window);
+#ifdef HAVE_WINDOW_SYSTEM
   struct frame *f = XFRAME (WINDOW_FRAME (w));
+#endif
 
   if (/* If window is in the process of being destroyed, don't bother
 	 to do anything.  */
@@ -28605,7 +28613,10 @@ show_mouse_face (Mouse_HLInfo *hlinfo, enum draw_glyphs_face draw)
 	 anymore.  This can happen when a window is split.  */
       && hlinfo->mouse_face_end_row < w->current_matrix->nrows)
     {
+#ifdef HAVE_WINDOW_SYSTEM
       bool phys_cursor_on_p = w->phys_cursor_on_p;
+#endif
+
       struct glyph_row *row, *first, *last;
 
       first = MATRIX_ROW (w->current_matrix, hlinfo->mouse_face_beg_row);
@@ -29697,8 +29708,8 @@ note_mode_line_or_margin_highlight (Lisp_Object window, int x, int y,
   Mouse_HLInfo *hlinfo = MOUSE_HL_INFO (f);
 #ifdef HAVE_WINDOW_SYSTEM
   Display_Info *dpyinfo;
-#endif
   Cursor cursor = No_Cursor;
+#endif
   Lisp_Object pointer = Qnil;
   int dx, dy, width, height;
   ptrdiff_t charpos;
@@ -29950,9 +29961,10 @@ note_mode_line_or_margin_highlight (Lisp_Object window, int x, int y,
 	       && hlinfo->mouse_face_beg_row == vpos )
 	    return;
 
+#ifdef HAVE_WINDOW_SYSTEM
 	  if (clear_mouse_face (hlinfo))
 	    cursor = No_Cursor;
-
+#endif
 	  if (!row->reversed_p)
 	    {
 	      hlinfo->mouse_face_beg_col = hpos;
@@ -30017,8 +30029,10 @@ note_mouse_highlight (struct frame *f, int x, int y)
   enum window_part part = ON_NOTHING;
   Lisp_Object window;
   struct window *w;
+#ifdef HAVE_WINDOW_SYSTEM
   Cursor cursor = No_Cursor;
   Lisp_Object pointer = Qnil;  /* Takes precedence over cursor!  */
+#endif
   struct buffer *b;
 
   /* When a menu is active, don't highlight because this looks odd.  */
@@ -30201,9 +30215,9 @@ note_mouse_highlight (struct frame *f, int x, int y)
 	      && glyph->type == STRETCH_GLYPH
 	      && glyph->avoid_cursor_p))
 	{
+#ifdef HAVE_WINDOW_SYSTEM
 	  if (clear_mouse_face (hlinfo))
 	    cursor = No_Cursor;
-#ifdef HAVE_WINDOW_SYSTEM
 	  if (FRAME_WINDOW_P (f) && NILP (pointer))
 	    {
 	      if (area != TEXT_AREA)
@@ -30256,9 +30270,10 @@ note_mouse_highlight (struct frame *f, int x, int y)
 
       same_region = coords_in_mouse_face_p (w, hpos, vpos);
 
+#ifdef HAVE_WINDOW_SYSTEM
       if (same_region)
 	cursor = No_Cursor;
-
+#endif
       /* Check mouse-face highlighting.  */
       if (! same_region
 	  /* If there exists an overlay with mouse-face overlapping
@@ -30283,10 +30298,11 @@ note_mouse_highlight (struct frame *f, int x, int y)
 	    goto check_help_echo;
 	  hlinfo->mouse_face_overlay = overlay;
 
+#ifdef HAVE_WINDOW_SYSTEM
 	  /* Clear the display of the old active region, if any.  */
 	  if (clear_mouse_face (hlinfo))
 	    cursor = No_Cursor;
-
+#endif
 	  /* If no overlay applies, get a text property.  */
 	  if (NILP (overlay))
 	    mouse_face = Fget_text_property (position, Qmouse_face, object);
@@ -30316,7 +30332,9 @@ note_mouse_highlight (struct frame *f, int x, int y)
 		= face_at_string_position (w, object, pos, 0, &ignore,
 					   glyph->face_id, true);
 	      show_mouse_face (hlinfo, DRAW_MOUSE_FACE);
+#ifdef HAVE_WINDOW_SYSTEM
 	      cursor = No_Cursor;
+#endif
 	    }
 	  else
 	    {
@@ -30400,7 +30418,9 @@ note_mouse_highlight (struct frame *f, int x, int y)
 					      : XFASTINT (after),
 					      before_string, after_string,
 					      disp_string);
+#ifdef HAVE_WINDOW_SYSTEM
 		  cursor = No_Cursor;
+#endif
 		}
 	    }
 	}
diff --git a/src/xfaces.c b/src/xfaces.c
index de73c01..426b9ab 100644
--- a/src/xfaces.c
+++ b/src/xfaces.c
@@ -5195,10 +5195,12 @@ realize_basic_faces (struct frame *f)
 static bool
 realize_default_face (struct frame *f)
 {
+#ifdef HAVE_X_WINDOWS
   struct face_cache *c = FRAME_FACE_CACHE (f);
+  struct face *face;
+#endif
   Lisp_Object lface;
   Lisp_Object attrs[LFACE_VECTOR_SIZE];
-  struct face *face;
 
   /* If the `default' face is not yet known, create it.  */
   lface = lface_from_face_name (f, Qdefault, false);
@@ -5288,10 +5290,10 @@ realize_default_face (struct frame *f)
   eassert (lface_fully_specified_p (XVECTOR (lface)->contents));
   check_lface (lface);
   memcpy (attrs, XVECTOR (lface)->contents, sizeof attrs);
-  face = realize_face (c, attrs, DEFAULT_FACE_ID);
 
 #ifdef HAVE_WINDOW_SYSTEM
 #ifdef HAVE_X_WINDOWS
+  face = realize_face (c, attrs, DEFAULT_FACE_ID);
   if (FRAME_X_P (f) && face->font != FRAME_FONT (f))
     {
       /* This can happen when making a frame on a display that does
-- 
2.8.3


[-- Attachment #4: 0003-Avoid-empty-body-compiler-warnings.patch --]
[-- Type: text/plain, Size: 731 bytes --]

From 6cd2bafdcf9ae2fda8a377bcf5d254a09138605b Mon Sep 17 00:00:00 2001
From: Ken Brown <kbrown@cornell.edu>
Date: Tue, 14 Jun 2016 18:17:57 -0400
Subject: [PATCH 3/7] Avoid "empty body" compiler warnings

* src/conf_post.h (DebPrint): Add empty braces if not EMACSDEBUG.
---
 src/conf_post.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/conf_post.h b/src/conf_post.h
index 4459caf..25db0c6 100644
--- a/src/conf_post.h
+++ b/src/conf_post.h
@@ -211,7 +211,7 @@ 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)
+#  define DebPrint(stuff) {}
 # endif
 #endif
 
-- 
2.8.3


[-- Attachment #5: 0004-Fix-format-compiler-warnings.patch --]
[-- Type: text/plain, Size: 2608 bytes --]

From 3450cf787f6b1ea3f083e147705c454d8efd4416 Mon Sep 17 00:00:00 2001
From: Ken Brown <kbrown@cornell.edu>
Date: Tue, 14 Jun 2016 18:52:41 -0400
Subject: [PATCH 4/7] Fix "format" compiler warnings

* src/w32fns.c (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.

* 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.
---
 src/w32fns.c  | 6 +++---
 src/w32font.c | 4 ++--
 src/w32term.c | 2 +-
 3 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/src/w32fns.c b/src/w32fns.c
index ff45f53..86ebc8f 100644
--- a/src/w32fns.c
+++ b/src/w32fns.c
@@ -8964,7 +8964,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;
 }
@@ -10333,8 +10333,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)
diff --git a/src/w32font.c b/src/w32font.c
index b8884a5..4d15cff 100644
--- a/src/w32font.c
+++ b/src/w32font.c
@@ -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;
       }
 
diff --git a/src/w32term.c b/src/w32term.c
index 649e743..4462517 100644
--- a/src/w32term.c
+++ b/src/w32term.c
@@ -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;
 	}
 
-- 
2.8.3


[-- Attachment #6: 0005-Don-t-define-unneeded-function-on-Cygwin.patch --]
[-- Type: text/plain, Size: 1345 bytes --]

From f970bedaf0b6a22b717c8c8036612f1a642e5aa4 Mon Sep 17 00:00:00 2001
From: Ken Brown <kbrown@cornell.edu>
Date: Tue, 14 Jun 2016 19:01:32 -0400
Subject: [PATCH 5/7] =?UTF-8?q?Don=E2=80=99t=20define=20unneeded=20functio?=
 =?UTF-8?q?n=20on=20Cygwin?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

* src/w32fns.c (check_w32_winkey_state): Define and use only if
WINDOWSNT.
---
 src/w32fns.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/src/w32fns.c b/src/w32fns.c
index 86ebc8f..f0ae241 100644
--- a/src/w32fns.c
+++ b/src/w32fns.c
@@ -2406,6 +2406,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 +2434,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 +2625,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);
-- 
2.8.3


[-- Attachment #7: 0006-Avoid-jump-misses-init-compiler-warnings.patch --]
[-- Type: text/plain, Size: 1011 bytes --]

From a447218bb7ebbc3eec49bfee9f29575483bd16b4 Mon Sep 17 00:00:00 2001
From: Ken Brown <kbrown@cornell.edu>
Date: Tue, 14 Jun 2016 19:06:34 -0400
Subject: [PATCH 6/7] Avoid "jump misses init" compiler warnings
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

* src/lisp.h (AUTO_STRING_WITH_LEN): Don’t initialize 'name’.
---
 src/lisp.h | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/src/lisp.h b/src/lisp.h
index 972ca33..b07bf05 100644
--- a/src/lisp.h
+++ b/src/lisp.h
@@ -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)					\
-- 
2.8.3


[-- Attachment #8: 0007-Avoid-address-compiler-warnings.patch --]
[-- Type: text/plain, Size: 948 bytes --]

From fffe83061fecd26f5b534f47148ebc046cb03366 Mon Sep 17 00:00:00 2001
From: Ken Brown <kbrown@cornell.edu>
Date: Tue, 14 Jun 2016 21:29:35 -0400
Subject: [PATCH 7/7] Avoid "address" compiler warnings

* configure.ac: Disable the -Wno-address compiler warning for the
MinGW and Cygwin-w32 builds.
---
 configure.ac | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/configure.ac b/configure.ac
index 2674806..3565905 100644
--- a/configure.ac
+++ b/configure.ac
@@ -995,6 +995,11 @@ AC_DEFUN
     gl_WARN_ADD([-Wno-pointer-sign])
   fi
 
+  # This causes too much noise in the MinGW and Cygwin-w32 builds.
+  if test $opsys = mingw32 || (test $opsys = cygwin && test $with_w32 = yes); then
+    gl_WARN_ADD([-Wno-address])
+  fi
+
   AC_DEFINE([GCC_LINT], [1], [Define to 1 if --enable-gcc-warnings.])
   AC_DEFINE([GNULIB_PORTCHECK], [1], [enable some gnulib portability checks])
   AH_VERBATIM([GNULIB_PORTCHECK_FORTIFY_SOURCE],
-- 
2.8.3


^ permalink raw reply related	[flat|nested] 14+ messages in thread

end of thread, other threads:[~2016-06-23  7:15 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-06-15  2:04 bug#23771: Eliminating compiler warnings Ken Brown
2016-06-15 14:44 ` Eli Zaretskii
2016-06-16  1:38   ` Ken Brown
2016-06-16 15:14     ` Eli Zaretskii
2016-06-16 15:50       ` Paul Eggert
2016-06-21  3:11       ` Ken Brown
2016-06-22  1:12     ` Paul Eggert
2016-06-22  6:10       ` martin rudalics
2016-06-23  7:15         ` Paul Eggert
2016-06-22 14:04       ` Andy Moreton
2016-06-22 14:10         ` Ken Brown
2016-06-22 14:06       ` Ken Brown
2016-06-15 20:24 ` Richard Stallman
2016-06-16  1:41   ` Ken Brown

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).