According to the spec, the compiler is free to use a signed, unsigned, or even char type for enums, provided all values fit within the type. For example, constructs like `*_FORCE_DWORD` can force an unsigned type using a value like `0xffffffff`. While some headers use this approach, it’s inconsistent and 0x7fffffff is often used instead.
Unfortunately, MSVC and GCC differ in their behavior: GCC always uses an unsigned type, while MSVC uses a signed type when possible. Consequently, Clang’s behavior depends on the mode being used.
Additionally, Clang emits a warning for "useless" checks when building Wine in MinGW mode. For instance: ``` dlls/gdiplus/graphics.c:7337:18: warning: result of comparison of unsigned enum expression < 0 is always false [-WTautological-unsigned-enum-zero-compare] 7337 | src_space < 0 || src_space > CoordinateSpaceDevice) ```
This warning is impractical for code that aims to be portable. The check is not tautological when building in MSVC mode (e.g., in our CI). I considered disabling the warning, but since this is the only place in the codebase where it’s problematic, I believe we can simply adjust the check.
This resolves the last warning in LLVM builds, allowing -Werror to be used in MinGW mode as well.
From: Jacek Caban jacek@codeweavers.com
Fixes -Wtautological-unsigned-enum-zero-compare warning on llvm-mingw. --- dlls/gdiplus/graphics.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-)
diff --git a/dlls/gdiplus/graphics.c b/dlls/gdiplus/graphics.c index 0574f6e8aba..4699f8c21d3 100644 --- a/dlls/gdiplus/graphics.c +++ b/dlls/gdiplus/graphics.c @@ -7332,9 +7332,8 @@ GpStatus gdip_transform_points(GpGraphics *graphics, GpCoordinateSpace dst_space GpStatus WINGDIPAPI GdipTransformPoints(GpGraphics *graphics, GpCoordinateSpace dst_space, GpCoordinateSpace src_space, GpPointF *points, INT count) { - if(!graphics || !points || count <= 0 || - dst_space < 0 || dst_space > CoordinateSpaceDevice || - src_space < 0 || src_space > CoordinateSpaceDevice) + if(!graphics || !points || count <= 0 || (UINT)dst_space > CoordinateSpaceDevice || + (UINT)src_space > CoordinateSpaceDevice) return InvalidParameter;
if(graphics->busy)
This merge request was approved by Esme Povirk.