From 015172d1ba36de9ab2ca2cae020b6ab6793dbb8c Mon Sep 17 00:00:00 2001 From: Eli Zaretskii Date: Fri, 15 Sep 2017 11:46:37 +0300 Subject: [PATCH] Avoid compilation warnings with GCC 7 on MS-Windows * src/w32term.c (w32_setup_relief_color, construct_mouse_click) (w32_read_socket): Initialize variables to shut up bogus compilation warnings from GCC 7. * src/unexw32.c (COPY_CHUNK, COPY_PROC_CHUNK): Cast to DWORD_PTR to avoid compiler warnings about printing signed values using %x format spec. * src/dispnew.c (adjust_glyph_matrix): Add eassert to avoid compiler warning about possible NULL pointer dereference. * src/lisp.h (pI): Tweak the definition some more for MinGW64. --- src/dispnew.c | 1 + src/lisp.h | 3 ++- src/unexw32.c | 6 +++--- src/w32term.c | 9 +++++---- 4 files changed, 11 insertions(+), 8 deletions(-) diff --git a/src/dispnew.c b/src/dispnew.c index 2d1df546982..ec9c77ded51 100644 --- a/src/dispnew.c +++ b/src/dispnew.c @@ -386,6 +386,7 @@ adjust_glyph_matrix (struct window *w, struct glyph_matrix *matrix, int x, int y Do nothing if MATRIX' size, position, vscroll, and marginal areas haven't changed. This optimization is important because preserving the matrix means preventing redisplay. */ + eassert (w != NULL || matrix->pool != NULL); if (matrix->pool == NULL) { left = margin_glyphs_to_reserve (w, dim.width, w->left_margin_cols); diff --git a/src/lisp.h b/src/lisp.h index c5aea9c34cb..c5030824427 100644 --- a/src/lisp.h +++ b/src/lisp.h @@ -101,7 +101,8 @@ enum { EMACS_INT_WIDTH = LLONG_WIDTH, EMACS_UINT_WIDTH = ULLONG_WIDTH }; which will cause a warning for %lld etc. */ # if defined __MINGW32__ \ && (!defined __USE_MINGW_ANSI_STDIO \ - || !(GNUC_PREREQ (6, 0, 0) && __MINGW32_MAJOR_VERSION >= 5)) + || (!defined MINGW_W64 \ + && !(GNUC_PREREQ (6, 0, 0) && __MINGW32_MAJOR_VERSION >= 5))) # define pI "I64" # else /* ! MinGW */ # define pI "ll" diff --git a/src/unexw32.c b/src/unexw32.c index d3d6a90f686..0c6b48342e5 100644 --- a/src/unexw32.c +++ b/src/unexw32.c @@ -500,8 +500,8 @@ copy_executable_and_dump_data (file_data *p_infile, if (verbose) \ { \ printf ("%s\n", (message)); \ - printf ("\t0x%"pDWP" Offset in input file.\n", s - p_infile->file_base); \ - printf ("\t0x%"pDWP" Offset in output file.\n", dst - p_outfile->file_base); \ + printf ("\t0x%"pDWP" Offset in input file.\n", (DWORD_PTR)(s - p_infile->file_base)); \ + printf ("\t0x%"pDWP" Offset in output file.\n", (DWORD_PTR)(dst - p_outfile->file_base)); \ printf ("\t0x%"pDWP" Size in bytes.\n", count); \ } \ memcpy (dst, s, count); \ @@ -517,7 +517,7 @@ copy_executable_and_dump_data (file_data *p_infile, printf ("%s\n", (message)); \ printf ("\t0x%p Address in process.\n", s); \ printf ("\t0x%p Base output file.\n", p_outfile->file_base); \ - printf ("\t0x%"pDWP" Offset in output file.\n", dst - p_outfile->file_base); \ + printf ("\t0x%"pDWP" Offset in output file.\n", (DWORD_PTR)(dst - p_outfile->file_base)); \ printf ("\t0x%p Address in output file.\n", dst); \ printf ("\t0x%"pDWP" Size in bytes.\n", count); \ } \ diff --git a/src/w32term.c b/src/w32term.c index e62ae7e8426..a7a510b9ecb 100644 --- a/src/w32term.c +++ b/src/w32term.c @@ -1645,6 +1645,7 @@ w32_setup_relief_color (struct frame *f, struct relief *relief, double factor, if (w32_alloc_lighter_color (f, &pixel, factor, delta)) xgcv.foreground = relief->pixel = pixel; + xgcv.font = NULL; /* avoid compiler warnings */ if (relief->gc == 0) { #if 0 /* TODO: stipple */ @@ -3087,8 +3088,8 @@ parse_button (int message, int xbutton, int * pbutton, int * pup) static Lisp_Object construct_mouse_click (struct input_event *result, W32Msg *msg, struct frame *f) { - int button; - int up; + int button = 0; + int up = 0; parse_button (msg->msg.message, HIWORD (msg->msg.wParam), &button, &up); @@ -4976,8 +4977,8 @@ w32_read_socket (struct terminal *terminal, /* If we decide we want to generate an event to be seen by the rest of Emacs, we put it here. */ bool tool_bar_p = 0; - int button; - int up; + int button = 0; + int up = 0; f = (x_mouse_grabbed (dpyinfo) ? dpyinfo->last_mouse_frame : x_window_to_frame (dpyinfo, msg.msg.hwnd)); -- 2.39.5