From b5f707fc0702266ba43ac72afb64348e6ad68257 Mon Sep 17 00:00:00 2001 From: Thomas Debesse Date: Thu, 11 Jul 2024 00:58:38 +0200 Subject: [PATCH] crnlib: fix CodeQL report cpp/comparison-with-wider-type --- crnlib/crn_comp.cpp | 6 +++--- crnlib/crn_dxt_hc.cpp | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/crnlib/crn_comp.cpp b/crnlib/crn_comp.cpp index 7a37e47b..fc3c6d96 100644 --- a/crnlib/crn_comp.cpp +++ b/crnlib/crn_comp.cpp @@ -632,7 +632,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; @@ -883,7 +883,7 @@ static void remap_alpha_endpoints(uint16* remapping, const optimize_alpha_params const optimize_alpha_params::unpacked_endpoint& e_back = unpacked_endpoints[chosen.back()]; uint16 selected_index = 0; uint64 best_value = 0, selected_similarity_front = 0, selected_similarity_back = 0; - for (uint16 i = 0; i < remaining.size(); i++) { + for (size_t i = 0; i < remaining.size(); i++) { uint remaining_index = remaining[i]; const optimize_alpha_params::unpacked_endpoint& e_remaining = unpacked_endpoints[remaining_index]; uint error_front = math::square(e_remaining.low - e_front.low) + math::square(e_remaining.high - e_front.high); @@ -912,7 +912,7 @@ static void remap_alpha_endpoints(uint16* remapping, const optimize_alpha_params chosen.push_back(selected); } remaining.erase(remaining.begin() + selected_index); - for (uint16 i = 0; i < remaining.size(); i++) + for (size_t i = 0; i < remaining.size(); i++) total_frequency[remaining[i]] += frequency[remaining[i]]; } for (uint16 i = 0; i < n; i++) 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]]; } }