d3drm: Avoid shift overflow when using RGBA_MAKE.
Thomas Faber
thomas.faber at reactos.org
Wed Nov 9 07:09:35 CST 2016
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
-------------- next part --------------
From fadb07db5efb99c86982e9b22a89040a3a5084d6 Mon Sep 17 00:00:00 2001
From: Thomas Faber <thomas.faber at reactos.org>
Date: Wed, 9 Nov 2016 06:27:25 +0100
Subject: d3drm: Avoid shift overflow when using RGBA_MAKE.
Signed-off-by: Thomas Faber <thomas.faber at reactos.org>
---
dlls/d3drm/frame.c | 4 ++--
dlls/d3drm/light.c | 2 +-
dlls/d3drm/meshbuilder.c | 4 ++--
3 files changed, 5 insertions(+), 5 deletions(-)
diff --git a/dlls/d3drm/frame.c b/dlls/d3drm/frame.c
index 978b1d8..2853c04 100644
--- a/dlls/d3drm/frame.c
+++ b/dlls/d3drm/frame.c
@@ -2005,7 +2005,7 @@ static HRESULT WINAPI d3drm_frame3_SetSceneBackgroundRGB(IDirect3DRMFrame3 *ifac
TRACE("iface %p, red %.8e, green %.8e, blue %.8e.\n", iface, red, green, blue);
frame->scenebackground = RGBA_MAKE((BYTE)(red * 255.0f),
- (BYTE)(green * 255.0f), (BYTE)(blue * 255.0f), 0xff);
+ (BYTE)(green * 255.0f), (BYTE)(blue * 255.0f), 0xffu);
return D3DRM_OK;
}
@@ -2949,7 +2949,7 @@ HRESULT d3drm_frame_create(struct d3drm_frame **frame, IUnknown *parent_frame, I
object->IDirect3DRMFrame3_iface.lpVtbl = &d3drm_frame3_vtbl;
object->d3drm = d3drm;
object->ref = 1;
- object->scenebackground = RGBA_MAKE(0, 0, 0, 0xff);
+ object->scenebackground = RGBA_MAKE(0, 0, 0, 0xffu);
memcpy(object->transform, identity, sizeof(D3DRMMATRIX4D));
diff --git a/dlls/d3drm/light.c b/dlls/d3drm/light.c
index 53accbf..36c8fd1 100644
--- a/dlls/d3drm/light.c
+++ b/dlls/d3drm/light.c
@@ -183,7 +183,7 @@ static HRESULT WINAPI d3drm_light_SetColorRGB(IDirect3DRMLight *iface,
TRACE("iface %p, red %.8e, green %.8e, blue %.8e.\n", iface, red, green, blue);
- light->color = RGBA_MAKE((BYTE)(red * 255.0f), (BYTE)(green * 255.0f), (BYTE)(blue * 255.0f), 0xff);
+ light->color = RGBA_MAKE((BYTE)(red * 255.0f), (BYTE)(green * 255.0f), (BYTE)(blue * 255.0f), 0xffu);
return D3DRM_OK;
}
diff --git a/dlls/d3drm/meshbuilder.c b/dlls/d3drm/meshbuilder.c
index 958e759..e570c1f 100644
--- a/dlls/d3drm/meshbuilder.c
+++ b/dlls/d3drm/meshbuilder.c
@@ -1694,7 +1694,7 @@ static HRESULT WINAPI d3drm_mesh_builder3_SetColorRGB(IDirect3DRMMeshBuilder3 *i
TRACE("iface %p, red %.8e, green %.8e, blue %.8e.\n", iface, red, green, blue);
- mesh_builder->color = RGBA_MAKE((BYTE)(red * 255.0f), (BYTE)(green * 255.0f), (BYTE)(blue * 255.0f), 0xff);
+ mesh_builder->color = RGBA_MAKE((BYTE)(red * 255.0f), (BYTE)(green * 255.0f), (BYTE)(blue * 255.0f), 0xffu);
return D3DRM_OK;
}
@@ -2595,7 +2595,7 @@ static HRESULT WINAPI d3drm_mesh_SetGroupColorRGB(IDirect3DRMMesh *iface,
if (id >= mesh->nb_groups)
return D3DRMERR_BADVALUE;
- mesh->groups[id].color = RGBA_MAKE((BYTE)(red * 255.0f), (BYTE)(green * 255.0f), (BYTE)(blue * 255.0f), 0xff);
+ mesh->groups[id].color = RGBA_MAKE((BYTE)(red * 255.0f), (BYTE)(green * 255.0f), (BYTE)(blue * 255.0f), 0xffu);
return D3DRM_OK;
}
--
2.10.2
More information about the wine-patches
mailing list