d3drm: Avoid shift overflow when using RGBA_MAKE.

Henri Verbeet hverbeet at gmail.com
Thu Nov 10 09:26:42 CST 2016


On 9 November 2016 at 14:09, Thomas Faber <thomas.faber at reactos.org> wrote:
> This causes warnings on Arch Linux.
> gcc (GCC) 6.2.1 20160830
>
> In file included from ../../include/d3drmdef.h:25:0,
>                 from ../../include/d3drmobj.h:25,
>                 from ../../include/d3drm.h:27,
>                 from d3drm_private.h:24,
>                 from frame.c:30:
> frame.c: In function ‘d3drm_frame3_SetSceneBackgroundRGB’:
> ../../include/d3dtypes.h:56:51: error: result of ‘255 << 24’ requires 33
> bits to represent, but ‘int’ only has 32 bits [-Werror=shift-overflow=]
> #define RGBA_MAKE(r, g, b, a)   ((D3DCOLOR) (((a) << 24) | ((r) << 16) |
> ((g) << 8) | (b)))
>                                                   ^
> frame.c:2007:30: note: in expansion of macro ‘RGBA_MAKE’
>     frame->scenebackground = RGBA_MAKE((BYTE)(red * 255.0f),
>                              ^~~~~~~~~
> frame.c: In function ‘d3drm_frame_create’:
> ../../include/d3dtypes.h:56:51: error: result of ‘255 << 24’ requires 33
> bits to represent, but ‘int’ only has 32 bits [-Werror=shift-overflow=]
> #define RGBA_MAKE(r, g, b, a)   ((D3DCOLOR) (((a) << 24) | ((r) << 16) |
> ((g) << 8) | (b)))
>                                                   ^
> frame.c:2952:31: note: in expansion of macro ‘RGBA_MAKE’
>     object->scenebackground = RGBA_MAKE(0, 0, 0, 0xff);
>                               ^~~~~~~~~
> cc1: all warnings being treated as errors
>
I've just sent a different patch
(https://source.winehq.org/patches/data/127691), that hopefully also
addresses this.



More information about the wine-devel mailing list