include: Avoid overflow (warning) in RGBA_MAKE.

Henri Verbeet hverbeet at gmail.com
Tue Sep 6 03:48:19 CDT 2016


On 6 September 2016 at 08:41, Dmitry Timoshkov <dmitry at baikal.ru> wrote:
> Gerald Pfeifer <gerald at pfeifer.com> wrote:
>
>> --- a/include/d3dtypes.h
>> +++ b/include/d3dtypes.h
>> @@ -53,7 +53,7 @@ typedef LONG D3DFIXED;
>>  #define RGBA_GETRED(rgb)        (((rgb) >> 16) & 0xff)
>>  #define RGBA_GETGREEN(rgb)      (((rgb) >> 8) & 0xff)
>>  #define RGBA_GETBLUE(rgb)       ((rgb) & 0xff)
>> -#define RGBA_MAKE(r, g, b, a)   ((D3DCOLOR) (((a) << 24) | ((r) << 16) | ((g) << 8) | (b)))
>> +#define RGBA_MAKE(r, g, b, a)   ((D3DCOLOR) (((unsigned)(a) << 24) | ((r) << 16) | ((g) << 8) | (b)))
>
> This is a public header, probably you need to fix the callers of this macro
> instead.
>
Signed overflow is undefined, so this change is compatible. It's also
unlikely to be an issue in practice on any architecture we support. I
might have preferred something similar to D3DCOLOR_ARGB though.

That's not to say the users of the macro don't have room for improvement.



More information about the wine-devel mailing list