[PATCH] gdi32: Avoid a variable holding an ARRAY_SIZE
Michael Stefaniuc
mstefani at winehq.org
Fri Oct 5 14:35:34 CDT 2018
Signed-off-by: Michael Stefaniuc <mstefani at winehq.org>
---
dlls/gdi32/dibdrv/opengl.c | 7 +++----
1 file changed, 3 insertions(+), 4 deletions(-)
diff --git a/dlls/gdi32/dibdrv/opengl.c b/dlls/gdi32/dibdrv/opengl.c
index dba5db0356..7c6043c2c6 100644
--- a/dlls/gdi32/dibdrv/opengl.c
+++ b/dlls/gdi32/dibdrv/opengl.c
@@ -94,7 +94,6 @@ static const struct
{ OSMESA_RGB_565, 16, 5, 0, 6, 5, 5, 11, 0, 0, 16, 32, 8 },
{ OSMESA_RGB_565, 16, 5, 0, 6, 5, 5, 11, 0, 0, 16, 16, 8 },
};
-static const int nb_formats = sizeof(pixel_formats) / sizeof(pixel_formats[0]);
static BOOL init_opengl(void)
{
@@ -148,7 +147,7 @@ failed:
*/
static int dibdrv_wglDescribePixelFormat( HDC hdc, int fmt, UINT size, PIXELFORMATDESCRIPTOR *descr )
{
- int ret = sizeof(pixel_formats) / sizeof(pixel_formats[0]);
+ int ret = ARRAY_SIZE( pixel_formats );
if (!descr) return ret;
if (fmt <= 0 || fmt > ret) return 0;
@@ -198,7 +197,7 @@ static struct wgl_context *dibdrv_wglCreateContext( HDC hdc )
if (!(context = HeapAlloc( GetProcessHeap(), 0, sizeof( *context )))) return NULL;
context->format = GetPixelFormat( hdc );
- if (!context->format || context->format > nb_formats) context->format = 1;
+ if (!context->format || context->format > ARRAY_SIZE( pixel_formats )) context->format = 1;
if (!(context->context = pOSMesaCreateContextExt( pixel_formats[context->format - 1].mesa,
pixel_formats[context->format - 1].depth_bits,
@@ -306,7 +305,7 @@ static BOOL dibdrv_wglMakeCurrent( HDC hdc, struct wgl_context *context )
*/
static BOOL dibdrv_wglSetPixelFormat( HDC hdc, int fmt, const PIXELFORMATDESCRIPTOR *descr )
{
- if (fmt <= 0 || fmt > nb_formats) return FALSE;
+ if (fmt <= 0 || fmt > ARRAY_SIZE( pixel_formats )) return FALSE;
return GdiSetPixelFormat( hdc, fmt, descr );
}
--
2.14.4
More information about the wine-devel
mailing list