[PATCH] gdi32: Declare our intent explicitly to the compiler.

Ken Thomases ken at codeweavers.com
Wed Feb 17 09:04:14 CST 2016


On Feb 17, 2016, at 4:12 AM, Michael Stefaniuc <mstefani at redhat.com> wrote:
> 
> On 02/17/2016 10:27 AM, Charles Davis wrote:
>> Clang warns about this abs(3) call because the argument is of
>> unsigned type. Apparently, though, this is actually a signed value
>> that just happens to be stored in a DWORD. (Then why is this
>> parameter to ExtCreatePen() a DWORD?)
>> 
>> In any case, quiesce this warning with a cast.
> Well, clang is wrong here. abs() takes a signed integer and the
> implicit cast from unsigned to signed is perfectly valid C.

Warnings are not for calling out things that are invalid — that's what errors are for — they're for calling out things that may be unintentional or confusing.  I think this qualifies.  It's fairly non-obvious that this DWORD value should be treated as signed, as evidenced by Chip's initial approach of just removing the abs() call.  Something is needed to clarify the intent of the code.

Regards,
Ken




More information about the wine-devel mailing list