mirror of
https://git.savannah.gnu.org/git/emacs.git
synced 2026-09-10 07:46:51 -04:00
Port MinGW GCC 9.2 image.c fix to non MS-Windows
Avoid useless casts on GCC 14+ platforms on non MS-Windows, by using a cast only if HAVE_NTGUI. That cast should not provoke -Wuseless-cast regardless of how MS-Windows defines HDC, since it casts to an Emacs-defined type. This change lets the code compile again on Fedora 44 with --enable-gcc-warnings. * src/dispextern.h (PIX_CONTAINER_TO_CONTEXT): New macro. It defaults to the identity macro. (Emacs_Pix_Context): Default to Emacs_Pix_Container. * src/image.c (pbm_load, png_load_body, jpeg_load_body) (tiff_load, gif_load, svg_load_image): Use the new macro instead of a cast.
This commit is contained in:
parent
967d8182cf
commit
54b6ea14a9
|
|
@ -115,7 +115,6 @@ xstrcasecmp (char const *a, char const *b)
|
|||
typedef struct x_display_info Display_Info;
|
||||
#ifndef USE_CAIRO
|
||||
typedef XImage *Emacs_Pix_Container;
|
||||
typedef XImage *Emacs_Pix_Context;
|
||||
#endif /* !USE_CAIRO */
|
||||
#define NativeRectangle XRectangle
|
||||
#endif
|
||||
|
|
@ -130,7 +129,6 @@ typedef struct
|
|||
int bits_per_pixel; /* bits per pixel (ZPixmap) */
|
||||
} *Emacs_Pix_Container;
|
||||
typedef Emacs_Pix_Container Emacs_Pixmap;
|
||||
typedef Emacs_Pix_Container Emacs_Pix_Context;
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_NTGUI
|
||||
|
|
@ -138,6 +136,7 @@ typedef Emacs_Pix_Container Emacs_Pix_Context;
|
|||
typedef struct w32_display_info Display_Info;
|
||||
typedef XImage *Emacs_Pix_Container;
|
||||
typedef HDC Emacs_Pix_Context;
|
||||
# define PIX_CONTAINER_TO_CONTEXT(c) ((Emacs_Pix_Context) (c))
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_NS
|
||||
|
|
@ -145,7 +144,6 @@ typedef HDC Emacs_Pix_Context;
|
|||
/* Following typedef needed to accommodate the MSDOS port, believe it or not. */
|
||||
typedef struct ns_display_info Display_Info;
|
||||
typedef Emacs_Pixmap Emacs_Pix_Container;
|
||||
typedef Emacs_Pixmap Emacs_Pix_Context;
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_PGTK
|
||||
|
|
@ -160,14 +158,12 @@ typedef XImagePtr XImagePtr_or_DC;
|
|||
#include "haikugui.h"
|
||||
typedef struct haiku_display_info Display_Info;
|
||||
typedef Emacs_Pixmap Emacs_Pix_Container;
|
||||
typedef Emacs_Pixmap Emacs_Pix_Context;
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_ANDROID
|
||||
#include "androidgui.h"
|
||||
typedef struct android_display_info Display_Info;
|
||||
typedef struct android_image *Emacs_Pix_Container;
|
||||
typedef struct android_image *Emacs_Pix_Context;
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_WINDOW_SYSTEM
|
||||
|
|
@ -193,6 +189,14 @@ typedef void *Emacs_Cursor;
|
|||
# define WINDOW_HANDLE_UINTPTR(h) ((uintptr_t) {(h)})
|
||||
# endif
|
||||
|
||||
/* Ordinarily an Emacs_Pix_Context is just an Emacs_Pix_Container;
|
||||
platforms can override this by defining the latter type
|
||||
and defining the conversion macro PIX_CONTAINER_TO_CONTEXT. */
|
||||
# ifndef PIX_CONTAINER_TO_CONTEXT
|
||||
typedef Emacs_Pix_Container Emacs_Pix_Context;
|
||||
# define PIX_CONTAINER_TO_CONTEXT(c) (c)
|
||||
# endif
|
||||
|
||||
/* ``box'' structure similar to that found in the X sample server,
|
||||
meaning that X2 and Y2 are not actually the end of the box, but one
|
||||
pixel past the end of the box, which makes checking for overlaps
|
||||
|
|
|
|||
14
src/image.c
14
src/image.c
|
|
@ -7841,7 +7841,7 @@ pbm_load (struct frame *f, struct image *img)
|
|||
|
||||
if (NILP (image_spec_value (img->spec, QCbackground, NULL)))
|
||||
/* Casting avoids a GCC warning. */
|
||||
IMAGE_BACKGROUND (img, f, (Emacs_Pix_Context)ximg);
|
||||
IMAGE_BACKGROUND (img, f, PIX_CONTAINER_TO_CONTEXT (ximg));
|
||||
|
||||
/* Put ximg into the image. */
|
||||
image_put_x_image (f, img, ximg, 0);
|
||||
|
|
@ -8587,7 +8587,7 @@ png_load_body (struct frame *f, struct image *img, struct png_load_context *c)
|
|||
img->height = height;
|
||||
|
||||
/* Maybe fill in the background field while we have ximg handy. */
|
||||
IMAGE_BACKGROUND (img, f, (Emacs_Pix_Context)ximg);
|
||||
IMAGE_BACKGROUND (img, f, PIX_CONTAINER_TO_CONTEXT (ximg));
|
||||
|
||||
/* Put ximg into the image. */
|
||||
image_put_x_image (f, img, ximg, 0);
|
||||
|
|
@ -8597,7 +8597,7 @@ png_load_body (struct frame *f, struct image *img, struct png_load_context *c)
|
|||
{
|
||||
/* Fill in the background_transparent field while we have the
|
||||
mask handy. Casting avoids a GCC warning. */
|
||||
image_background_transparent (img, f, (Emacs_Pix_Context)mask_img);
|
||||
image_background_transparent (img, f, PIX_CONTAINER_TO_CONTEXT (mask_img));
|
||||
|
||||
image_put_x_image (f, img, mask_img, 1);
|
||||
}
|
||||
|
|
@ -9164,7 +9164,7 @@ jpeg_load_body (struct frame *f, struct image *img,
|
|||
|
||||
/* Maybe fill in the background field while we have ximg handy. */
|
||||
if (NILP (image_spec_value (img->spec, QCbackground, NULL)))
|
||||
IMAGE_BACKGROUND (img, f, (Emacs_Pix_Context)ximg);
|
||||
IMAGE_BACKGROUND (img, f, PIX_CONTAINER_TO_CONTEXT (ximg));
|
||||
|
||||
/* Put ximg into the image. */
|
||||
image_put_x_image (f, img, ximg, 0);
|
||||
|
|
@ -9604,7 +9604,7 @@ tiff_load (struct frame *f, struct image *img)
|
|||
|
||||
/* Maybe fill in the background field while we have ximg handy. */
|
||||
if (NILP (image_spec_value (img->spec, QCbackground, NULL)))
|
||||
IMAGE_BACKGROUND (img, f, (Emacs_Pix_Context)ximg);
|
||||
IMAGE_BACKGROUND (img, f, PIX_CONTAINER_TO_CONTEXT (ximg));
|
||||
|
||||
/* Put ximg into the image. */
|
||||
image_put_x_image (f, img, ximg, 0);
|
||||
|
|
@ -10326,7 +10326,7 @@ gif_load (struct frame *f, struct image *img)
|
|||
|
||||
/* Maybe fill in the background field while we have ximg handy. */
|
||||
if (NILP (image_spec_value (img->spec, QCbackground, NULL)))
|
||||
IMAGE_BACKGROUND (img, f, (Emacs_Pix_Context)ximg);
|
||||
IMAGE_BACKGROUND (img, f, PIX_CONTAINER_TO_CONTEXT (ximg));
|
||||
|
||||
/* Put ximg into the image. */
|
||||
image_put_x_image (f, img, ximg, 0);
|
||||
|
|
@ -12510,7 +12510,7 @@ svg_load_image (struct frame *f, struct image *img, char *contents,
|
|||
|
||||
/* Maybe fill in the background field while we have ximg handy.
|
||||
Casting avoids a GCC warning. */
|
||||
IMAGE_BACKGROUND (img, f, (Emacs_Pix_Context)ximg);
|
||||
IMAGE_BACKGROUND (img, f, PIX_CONTAINER_TO_CONTEXT (ximg));
|
||||
|
||||
/* Put ximg into the image. */
|
||||
image_put_x_image (f, img, ximg, 0);
|
||||
|
|
|
|||
Loading…
Reference in a new issue