From 50b9b216d909a3dc4a7b8382ef7de33516aeee76 Mon Sep 17 00:00:00 2001 From: Alex Hung Date: Mon, 31 Aug 2026 14:12:04 -0600 Subject: [PATCH] drm/amd/display: Fix signedness mismatches in cm3 [Why] In cm3_helper_translate_curve_to_degamma_hw_format(), seg_distr[] and the loop counter k are uint32_t, while -1, region_start/region_end and i are signed. Comparing them relies on implicit integer conversions, which some compilers diagnose and which obscures the intent of the comparisons. [How] Add explicit casts so the signedness of each comparison is stated in the code. No functional change. Assisted-by: Copilot:Claude-Opus-5 Reviewed-by: Tom Chung Signed-off-by: Alex Hung Signed-off-by: Ray Wu Tested-by: Dan Wheeler Signed-off-by: Alex Deucher --- drivers/gpu/drm/amd/display/dc/dcn30/dcn30_cm_common.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/drivers/gpu/drm/amd/display/dc/dcn30/dcn30_cm_common.c b/drivers/gpu/drm/amd/display/dc/dcn30/dcn30_cm_common.c index 62ca235cd649..eb299f7f9c41 100644 --- a/drivers/gpu/drm/amd/display/dc/dcn30/dcn30_cm_common.c +++ b/drivers/gpu/drm/amd/display/dc/dcn30/dcn30_cm_common.c @@ -356,20 +356,20 @@ bool cm3_helper_translate_curve_to_degamma_hw_format( region_end = 0; for (i = region_end - region_start; i < MAX_REGIONS_NUMBER ; i++) - seg_distr[i] = -1; + seg_distr[i] = (uint32_t)-1; for (k = 0; k < MAX_REGIONS_NUMBER; k++) { - if (seg_distr[k] != -1) + if (seg_distr[k] != (uint32_t)-1) hw_points += (1 << seg_distr[k]); } j = 0; - for (k = 0; k < (region_end - region_start); k++) { + for (k = 0; k < (uint32_t)(region_end - region_start); k++) { increment = (NUMBER_SW_SEGMENTS << 4) / (1 << seg_distr[k]); start_index = (region_start + k + MAX_LOW_POINT) * NUMBER_SW_SEGMENTS; for (i = (start_index << 4); - i < (start_index << 4) + (NUMBER_SW_SEGMENTS << 4); + i < (int32_t)(start_index << 4) + (NUMBER_SW_SEGMENTS << 4); i += increment) { if (j == hw_points - 1) break;