From: Paul Eggert Date: Sat, 23 Jan 2016 09:02:00 +0000 (-0800) Subject: Pacify --enable-gcc-warnings --with-cairo X-Git-Tag: emacs-25.0.90~83 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=c07bddd69dab6252ce1e8a283a023d693b7d7ad6;p=emacs.git Pacify --enable-gcc-warnings --with-cairo Problem reported by Alexander Kuleshov in: http://lists.gnu.org/archive/html/emacs-devel/2016-01/msg01289.html * src/gtkutil.c (xg_get_page_setup): Use switch rather than if-then-else. * src/image.c (COLOR_TABLE_SUPPORT): Define directly rather than via #define and optional later #undef. (lookup_rgb_color) [USE_CAIRO && ENABLE_CHECKING]: Crash when the pixel is undefined, as there is a genuine bug here (Bug#22442). * src/image.c (tiff_load, gif_load, svg_load_image) (x_kill_gs_process) [USE_CAIRO]: * src/xterm.c (x_draw_fringe_bitmap) [USE_CAIRO]: Omit unused locals, or move them to where they’re needed. (x_clear_area1): Now ATTRIBUTE_UNUSED. --- diff --git a/src/gtkutil.c b/src/gtkutil.c index 768df342983..14b76ce67ae 100644 --- a/src/gtkutil.c +++ b/src/gtkutil.c @@ -4084,20 +4084,28 @@ xg_page_setup_dialog (void) Lisp_Object xg_get_page_setup (void) { - GtkPageOrientation orientation; Lisp_Object orientation_symbol; if (page_setup == NULL) page_setup = gtk_page_setup_new (); - orientation = gtk_page_setup_get_orientation (page_setup); - if (orientation == GTK_PAGE_ORIENTATION_PORTRAIT) - orientation_symbol = Qportrait; - else if (orientation == GTK_PAGE_ORIENTATION_LANDSCAPE) - orientation_symbol = Qlandscape; - else if (orientation == GTK_PAGE_ORIENTATION_REVERSE_PORTRAIT) - orientation_symbol = Qreverse_portrait; - else if (orientation == GTK_PAGE_ORIENTATION_REVERSE_LANDSCAPE) - orientation_symbol = Qreverse_landscape; + + switch (gtk_page_setup_get_orientation (page_setup)) + { + case GTK_PAGE_ORIENTATION_PORTRAIT: + orientation_symbol = Qportrait; + break; + case GTK_PAGE_ORIENTATION_LANDSCAPE: + orientation_symbol = Qlandscape; + break; + case GTK_PAGE_ORIENTATION_REVERSE_PORTRAIT: + orientation_symbol = Qreverse_portrait; + break; + case GTK_PAGE_ORIENTATION_REVERSE_LANDSCAPE: + orientation_symbol = Qreverse_landscape; + break; + default: + eassume (false); + } return listn (CONSTYPE_HEAP, 7, Fcons (Qorientation, orientation_symbol), diff --git a/src/image.c b/src/image.c index 8bb5ff77b22..4681cba1f87 100644 --- a/src/image.c +++ b/src/image.c @@ -57,8 +57,6 @@ along with GNU Emacs. If not, see . */ #endif /* HAVE_WINDOW_SYSTEM */ #ifdef HAVE_X_WINDOWS -#define COLOR_TABLE_SUPPORT 1 - typedef struct x_bitmap_record Bitmap_Record; #define GET_PIXEL(ximg, x, y) XGetPixel (ximg, x, y) #define NO_PIXMAP None @@ -74,9 +72,6 @@ typedef struct x_bitmap_record Bitmap_Record; # include "w32.h" #endif -/* W32_TODO : Color tables on W32. */ -#undef COLOR_TABLE_SUPPORT - typedef struct w32_bitmap_record Bitmap_Record; #define GET_PIXEL(ximg, x, y) GetPixel (ximg, x, y) #define NO_PIXMAP 0 @@ -89,13 +84,7 @@ typedef struct w32_bitmap_record Bitmap_Record; #endif /* HAVE_NTGUI */ -#ifdef USE_CAIRO -#undef COLOR_TABLE_SUPPORT -#endif - #ifdef HAVE_NS -#undef COLOR_TABLE_SUPPORT - typedef struct ns_bitmap_record Bitmap_Record; #define GET_PIXEL(ximg, x, y) XGetPixel (ximg, x, y) @@ -109,6 +98,12 @@ typedef struct ns_bitmap_record Bitmap_Record; #define DefaultDepthOfScreen(screen) x_display_list->n_planes #endif /* HAVE_NS */ +#if (defined HAVE_X_WINDOWS \ + && ! (defined HAVE_NTGUI || defined USE_CAIRO || defined HAVE_NS)) +/* W32_TODO : Color tables on W32. */ +# define COLOR_TABLE_SUPPORT 1 +#endif + static void x_disable_image (struct frame *, struct image *); static void x_edge_detection (struct frame *, struct image *, Lisp_Object, Lisp_Object); @@ -4615,16 +4610,13 @@ colors_in_color_table (int *n) static unsigned long lookup_rgb_color (struct frame *f, int r, int g, int b) { - unsigned long pixel; - #ifdef HAVE_NTGUI - pixel = PALETTERGB (r >> 8, g >> 8, b >> 8); -#endif /* HAVE_NTGUI */ - -#ifdef HAVE_NS - pixel = RGB_TO_ULONG (r >> 8, g >> 8, b >> 8); -#endif /* HAVE_NS */ - return pixel; + return PALETTERGB (r >> 8, g >> 8, b >> 8); +#elif defined HAVE_NS + return RGB_TO_ULONG (r >> 8, g >> 8, b >> 8); +#else + eassume (false); +#endif } static void @@ -7320,7 +7312,6 @@ tiff_load (struct frame *f, struct image *img) { unsigned char *data = (unsigned char *) xmalloc (width*height*4); uint32_t *dataptr = (uint32_t *) data; - int r, g, b, a; for (y = 0; y < height; ++y) { @@ -7634,19 +7625,19 @@ gif_load (struct frame *f, struct image *img) { int rc, width, height, x, y, i, j; ColorMapObject *gif_color_map; - unsigned long pixel_colors[256]; GifFileType *gif; gif_memory_source memsrc; Lisp_Object specified_bg = image_spec_value (img->spec, QCbackground, NULL); Lisp_Object specified_file = image_spec_value (img->spec, QCfile, NULL); Lisp_Object specified_data = image_spec_value (img->spec, QCdata, NULL); - unsigned long bgcolor = 0; EMACS_INT idx; int gif_err; #ifdef USE_CAIRO unsigned char *data = 0; #else + unsigned long pixel_colors[256]; + unsigned long bgcolor = 0; XImagePtr ximg; #endif @@ -7833,9 +7824,13 @@ gif_load (struct frame *f, struct image *img) gif_load call to construct and save all animation frames. */ init_color_table (); + +#ifndef USE_CAIRO if (STRINGP (specified_bg)) bgcolor = x_alloc_image_color (f, img, specified_bg, FRAME_BACKGROUND_PIXEL (f)); +#endif + for (j = 0; j <= idx; ++j) { /* We use a local variable `raster' here because RasterBits is a @@ -9182,11 +9177,6 @@ svg_load_image (struct frame *f, /* Pointer to emacs frame structure. * int height; const guint8 *pixels; int rowstride; - XImagePtr ximg; - Lisp_Object specified_bg; - XColor background; - int x; - int y; #if ! GLIB_CHECK_VERSION (2, 36, 0) /* g_type_init is a glib function that must be called prior to @@ -9240,16 +9230,14 @@ svg_load_image (struct frame *f, /* Pointer to emacs frame structure. * #ifdef USE_CAIRO { unsigned char *data = (unsigned char *) xmalloc (width*height*4); - int y; uint32_t bgcolor = get_spec_bg_or_alpha_as_argb (img, f); - for (y = 0; y < height; ++y) + for (int y = 0; y < height; ++y) { const guchar *iconptr = pixels + y * rowstride; uint32_t *dataptr = (uint32_t *) (data + y * rowstride); - int x; - for (x = 0; x < width; ++x) + for (int x = 0; x < width; ++x) { if (iconptr[3] == 0) *dataptr = bgcolor; @@ -9269,6 +9257,7 @@ svg_load_image (struct frame *f, /* Pointer to emacs frame structure. * } #else /* Try to create a x pixmap to hold the svg pixmap. */ + XImagePtr ximg; if (!image_create_x_image_and_pixmap (f, img, width, height, 0, &ximg, 0)) { g_object_unref (pixbuf); @@ -9279,7 +9268,8 @@ svg_load_image (struct frame *f, /* Pointer to emacs frame structure. * /* Handle alpha channel by combining the image with a background color. */ - specified_bg = image_spec_value (img->spec, QCbackground, NULL); + XColor background; + Lisp_Object specified_bg = image_spec_value (img->spec, QCbackground, NULL); if (!STRINGP (specified_bg) || !x_defined_color (f, SSDATA (specified_bg), &background, 0)) x_query_frame_background_color (f, &background); @@ -9295,9 +9285,9 @@ svg_load_image (struct frame *f, /* Pointer to emacs frame structure. * non-transparent images. Each pixel must be "flattened" by calculating the resulting color, given the transparency of the pixel, and the image background color. */ - for (y = 0; y < height; ++y) + for (int y = 0; y < height; ++y) { - for (x = 0; x < width; ++x) + for (int x = 0; x < width; ++x) { int red; int green; @@ -9597,8 +9587,6 @@ x_kill_gs_process (Pixmap pixmap, struct frame *f) 0, 0, img->width, img->height, ~0, ZPixmap); if (ximg) { - int x, y; - /* Initialize the color table. */ init_color_table (); @@ -9606,8 +9594,8 @@ x_kill_gs_process (Pixmap pixmap, struct frame *f) color table. After having done so, the color table will contain an entry for each color used by the image. */ #ifdef COLOR_TABLE_SUPPORT - for (y = 0; y < img->height; ++y) - for (x = 0; x < img->width; ++x) + for (int y = 0; y < img->height; ++y) + for (int x = 0; x < img->width; ++x) { unsigned long pixel = XGetPixel (ximg, x, y); diff --git a/src/xterm.c b/src/xterm.c index 6a38d24c636..1f71afd7f70 100644 --- a/src/xterm.c +++ b/src/xterm.c @@ -1313,7 +1313,6 @@ x_draw_fringe_bitmap (struct window *w, struct glyph_row *row, struct draw_fring { struct frame *f = XFRAME (WINDOW_FRAME (w)); Display *display = FRAME_X_DISPLAY (f); - Window window = FRAME_X_WINDOW (f); GC gc = f->output_data.x->normal_gc; struct face *face = p->face; @@ -1356,6 +1355,7 @@ x_draw_fringe_bitmap (struct window *w, struct glyph_row *row, struct draw_fring #else /* not USE_CAIRO */ if (p->which) { + Window window = FRAME_X_WINDOW (f); char *bits; Pixmap pixmap, clipmask = (Pixmap) 0; int depth = DefaultDepthOfScreen (FRAME_X_SCREEN (f)); @@ -3758,7 +3758,7 @@ x_delete_glyphs (struct frame *f, register int n) /* Like XClearArea, but check that WIDTH and HEIGHT are reasonable. If they are <= 0, this is probably an error. */ -static void +static ATTRIBUTE_UNUSED void x_clear_area1 (Display *dpy, Window window, int x, int y, int width, int height, int exposures) { @@ -3766,7 +3766,6 @@ x_clear_area1 (Display *dpy, Window window, XClearArea (dpy, window, x, y, width, height, exposures); } - void x_clear_area (struct frame *f, int x, int y, int width, int height) {