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 5abcc45 commit 52ac792
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
4 changes: 2 additions & 2 deletions crnlib/crn_comp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -639,7 +639,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 All @@ -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]];
}
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 52ac792

Please sign in to comment.