From 52ac7929dd7f37e9db2fae6788b36cedc48914ee Mon Sep 17 00:00:00 2001 From: Thomas Debesse Date: Thu, 11 Jul 2024 00:34:34 +0200 Subject: [PATCH] crnlib: fix CodeQL report cpp/comparison-with-wider-type --- crnlib/crn_comp.cpp | 4 ++-- crnlib/crn_dxt_hc.cpp | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/crnlib/crn_comp.cpp b/crnlib/crn_comp.cpp index e341a8c6..31051b25 100644 --- a/crnlib/crn_comp.cpp +++ b/crnlib/crn_comp.cpp @@ -639,7 +639,7 @@ static void remap_color_endpoints(uint16* remapping, const optimize_color_params remaining[i].e = unpacked_endpoints[i]; } crnlib::vector chosen(n << 1); - uint remaining_count = n, chosen_front = n, chosen_back = chosen_front; + uint16 remaining_count = n, chosen_front = n, chosen_back = chosen_front; chosen[chosen_front] = selected; optimize_color_params::unpacked_endpoint front_e = remaining[selected].e, back_e = front_e; bool front_updated = true, back_updated = true; @@ -665,7 +665,7 @@ static void remap_color_endpoints(uint16* remapping, const optimize_color_params } frequency = hist + selected * n; uint frequency_front = 0, frequency_back = 0; - for (int front = chosen_front, back = chosen_back, scale = back - front; scale > 0; front++, back--, scale -= 2) { + for (uint16 front = chosen_front, back = chosen_back, scale = back - front; scale > 0; front++, back--, scale -= 2) { frequency_front += scale * frequency[chosen[front]]; frequency_back += scale * frequency[chosen[back]]; } diff --git a/crnlib/crn_dxt_hc.cpp b/crnlib/crn_dxt_hc.cpp index 18c9c39c..4e621f2b 100644 --- a/crnlib/crn_dxt_hc.cpp +++ b/crnlib/crn_dxt_hc.cpp @@ -374,10 +374,10 @@ void dxt_hc::determine_tiles_task(uint64 data, void*) { } } - for (uint8 c = m_has_color_blocks ? 0 : cAlpha0; c < cAlpha0 + m_num_alpha_blocks; c++) { - for (uint8 e = 0; e < 8; e++) { + for (uint c = m_has_color_blocks ? 0 : cAlpha0; c < cAlpha0 + m_num_alpha_blocks; c++) { + for (uint e = 0; e < 8; e++) { total_error[c][e] = 0; - for (uint8 t = 0, s = e + 1; s; s >>= 1, t++) + for (uint t = 0, s = e + 1; s; s >>= 1, t++) total_error[c][e] += tile_error[c][tiles[e][t]]; } }