Skip to content

Commit

Permalink
crnlib: fix CodeQL report cpp/comparison-with-wider-type
Browse files Browse the repository at this point in the history
  • Loading branch information
illwieckz committed Jul 10, 2024
1 parent 277eb5a commit b5f707f
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
6 changes: 3 additions & 3 deletions crnlib/crn_comp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -632,7 +632,7 @@ static void remap_color_endpoints(uint16* remapping, const optimize_color_params
remaining[i].e = unpacked_endpoints[i];
}
crnlib::vector<uint16> 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;
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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++)
Expand Down
6 changes: 3 additions & 3 deletions crnlib/crn_dxt_hc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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]];
}
}
Expand Down

0 comments on commit b5f707f

Please sign in to comment.