SDL: Fixed warning C6326: Potential comparison of a constant with another constant. (0dad5)

From 0dad56354ceb4222be569e6969475adeec5a1ca1 Mon Sep 17 00:00:00 2001
From: Sam Lantinga <[EMAIL REDACTED]>
Date: Mon, 4 Dec 2023 20:54:11 -0800
Subject: [PATCH] Fixed warning C6326: Potential comparison of a constant with
 another constant.

---
 src/SDL_internal.h                   |  6 ++-
 src/video/yuv2rgb/yuv_rgb_std_func.h | 55 ++++++++++++++--------------
 2 files changed, 32 insertions(+), 29 deletions(-)

diff --git a/src/SDL_internal.h b/src/SDL_internal.h
index 23a836a8395e..2ae4ba2dd802 100644
--- a/src/SDL_internal.h
+++ b/src/SDL_internal.h
@@ -44,7 +44,11 @@
 #define HAVE_GCC_DIAGNOSTIC_PRAGMA 1
 #endif
 
-#ifdef _MSC_VER // SDL_MAX_SMALL_ALLOC_STACKSIZE is smaller than _ALLOCA_S_THRESHOLD and should be generally safe
+#ifdef _MSC_VER /* We use constant comparison for generated code */
+#pragma warning(disable : 6326)
+#endif
+
+#ifdef _MSC_VER /* SDL_MAX_SMALL_ALLOC_STACKSIZE is smaller than _ALLOCA_S_THRESHOLD and should be generally safe */
 #pragma warning(disable : 6255)
 #endif
 #define SDL_MAX_SMALL_ALLOC_STACKSIZE          128
diff --git a/src/video/yuv2rgb/yuv_rgb_std_func.h b/src/video/yuv2rgb/yuv_rgb_std_func.h
index 17b61db751e2..f359abae8b44 100644
--- a/src/video/yuv2rgb/yuv_rgb_std_func.h
+++ b/src/video/yuv2rgb/yuv_rgb_std_func.h
@@ -72,13 +72,12 @@
 #ifdef _MSC_VER /* Visual Studio analyzer can't tell that we're building this with different constants */
 #pragma warning(push)
 #pragma warning(disable : 6239)
-#pragma warning(disable : 6326)
 #endif
 
 void STD_FUNCTION_NAME(
-	uint32_t width, uint32_t height, 
-	const uint8_t *Y, const uint8_t *U, const uint8_t *V, uint32_t Y_stride, uint32_t UV_stride, 
-	uint8_t *RGB, uint32_t RGB_stride, 
+	uint32_t width, uint32_t height,
+	const uint8_t *Y, const uint8_t *U, const uint8_t *V, uint32_t Y_stride, uint32_t UV_stride,
+	uint8_t *RGB, uint32_t RGB_stride,
 	YCbCrType yuv_type)
 {
 	const YUV2RGBParam *const param = &(YUV2RGB[yuv_type]);
@@ -119,26 +118,26 @@ void STD_FUNCTION_NAME(
 		for(x=0; x<(width-(uv_x_sample_interval-1)); x+=uv_x_sample_interval)
 		{
 			// Compute U and V contributions, common to the four pixels
-			
+
 			int32_t u_tmp = ((*u_ptr)-128);
 			int32_t v_tmp = ((*v_ptr)-128);
-			
+
 			int32_t r_tmp = (v_tmp*param->v_r_factor);
 			int32_t g_tmp = (u_tmp*param->u_g_factor + v_tmp*param->v_g_factor);
 			int32_t b_tmp = (u_tmp*param->u_b_factor);
-			
+
 			// Compute the Y contribution for each pixel
-			
+
 			int32_t y_tmp = ((y_ptr1[0]-param->y_shift)*param->y_factor);
 			PACK_PIXEL(rgb_ptr1);
-			
+
 			y_tmp = ((y_ptr1[y_pixel_stride]-param->y_shift)*param->y_factor);
 			PACK_PIXEL(rgb_ptr1);
-			
+
 			#if uv_y_sample_interval > 1
 			y_tmp = ((y_ptr2[0]-param->y_shift)*param->y_factor);
 			PACK_PIXEL(rgb_ptr2);
-				
+
 			y_tmp = ((y_ptr2[y_pixel_stride]-param->y_shift)*param->y_factor);
 			PACK_PIXEL(rgb_ptr2);
 			#endif
@@ -155,19 +154,19 @@ void STD_FUNCTION_NAME(
 		if (uv_x_sample_interval == 2 && x == (width-1))
 		{
 			// Compute U and V contributions, common to the four pixels
-			
+
 			int32_t u_tmp = ((*u_ptr)-128);
 			int32_t v_tmp = ((*v_ptr)-128);
-			
+
 			int32_t r_tmp = (v_tmp*param->v_r_factor);
 			int32_t g_tmp = (u_tmp*param->u_g_factor + v_tmp*param->v_g_factor);
 			int32_t b_tmp = (u_tmp*param->u_b_factor);
-			
+
 			// Compute the Y contribution for each pixel
-			
+
 			int32_t y_tmp = ((y_ptr1[0]-param->y_shift)*param->y_factor);
 			PACK_PIXEL(rgb_ptr1);
-			
+
 			#if uv_y_sample_interval > 1
 			y_tmp = ((y_ptr2[0]-param->y_shift)*param->y_factor);
 			PACK_PIXEL(rgb_ptr2);
@@ -181,28 +180,28 @@ void STD_FUNCTION_NAME(
 		const uint8_t *y_ptr1=Y+y*Y_stride,
 			*u_ptr=U+(y/uv_y_sample_interval)*UV_stride,
 			*v_ptr=V+(y/uv_y_sample_interval)*UV_stride;
-		
+
 		uint8_t *rgb_ptr1=RGB+y*RGB_stride;
-		
+
 		for(x=0; x<(width-(uv_x_sample_interval-1)); x+=uv_x_sample_interval)
 		{
 			// Compute U and V contributions, common to the four pixels
-			
+
 			int32_t u_tmp = ((*u_ptr)-128);
 			int32_t v_tmp = ((*v_ptr)-128);
-			
+
 			int32_t r_tmp = (v_tmp*param->v_r_factor);
 			int32_t g_tmp = (u_tmp*param->u_g_factor + v_tmp*param->v_g_factor);
 			int32_t b_tmp = (u_tmp*param->u_b_factor);
-			
+
 			// Compute the Y contribution for each pixel
-			
+
 			int32_t y_tmp = ((y_ptr1[0]-param->y_shift)*param->y_factor);
 			PACK_PIXEL(rgb_ptr1);
-			
+
 			y_tmp = ((y_ptr1[y_pixel_stride]-param->y_shift)*param->y_factor);
 			PACK_PIXEL(rgb_ptr1);
-			
+
 			y_ptr1+=2*y_pixel_stride;
 			u_ptr+=2*uv_pixel_stride/uv_x_sample_interval;
 			v_ptr+=2*uv_pixel_stride/uv_x_sample_interval;
@@ -212,16 +211,16 @@ void STD_FUNCTION_NAME(
 		if (uv_x_sample_interval == 2 && x == (width-1))
 		{
 			// Compute U and V contributions, common to the four pixels
-			
+
 			int32_t u_tmp = ((*u_ptr)-128);
 			int32_t v_tmp = ((*v_ptr)-128);
-			
+
 			int32_t r_tmp = (v_tmp*param->v_r_factor);
 			int32_t g_tmp = (u_tmp*param->u_g_factor + v_tmp*param->v_g_factor);
 			int32_t b_tmp = (u_tmp*param->u_b_factor);
-			
+
 			// Compute the Y contribution for each pixel
-			
+
 			int32_t y_tmp = ((y_ptr1[0]-param->y_shift)*param->y_factor);
 			PACK_PIXEL(rgb_ptr1);
 		}