Skip to content

Commit

Permalink
codeql/cpp-comparison-with-wider-type (#172)
Browse files Browse the repository at this point in the history
- fixes codeql cpp/comparison-with-wider-type, types now match in loop condition
  • Loading branch information
michaeldsmith authored Jan 25, 2025
1 parent 24607fe commit 470d9f3
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 10 deletions.
13 changes: 7 additions & 6 deletions ctlrender/tiff_file.cc
Original file line number Diff line number Diff line change
Expand Up @@ -278,6 +278,7 @@ void tiff_read_multiplane(TIFF *t, float scale, ctl::dpx::fb<float> * pixels) {
uint32_t row;
uint32_t orientation_offset;
uint16_t d;
uint32_t e;

TIFFGetFieldDefaulted(t, TIFFTAG_IMAGEWIDTH, &w);
TIFFGetFieldDefaulted(t, TIFFTAG_IMAGELENGTH, &h);
Expand All @@ -300,8 +301,8 @@ void tiff_read_multiplane(TIFF *t, float scale, ctl::dpx::fb<float> * pixels) {
for(row=0; row<4; row++) {
if(row<samples_per_pixel) {
scanline_buffer_uint8[row]=(uint8_t *)alloca(scanline_size);
for(d=0; d<w; d++) {
scanline_buffer_uint8[row][d]= row==3 ? 255 : 0;
for(e=0; e<w; e++) {
scanline_buffer_uint8[row][e]= row==3 ? 255 : 0;
}
} else {
scanline_buffer_uint8[row]=NULL;
Expand Down Expand Up @@ -330,8 +331,8 @@ void tiff_read_multiplane(TIFF *t, float scale, ctl::dpx::fb<float> * pixels) {
for(row=0; row<4; row++) {
if(row<samples_per_pixel) {
scanline_buffer_uint16[row]=(uint16_t *)alloca(scanline_size);
for(d=0; d<w; d++) {
scanline_buffer_uint16[row][d]= row==3 ? 65535 : 0;
for(e=0; e<w; e++) {
scanline_buffer_uint16[row][e]= row==3 ? 65535 : 0;
}
} else {
scanline_buffer_uint16[row]=NULL;
Expand All @@ -358,8 +359,8 @@ void tiff_read_multiplane(TIFF *t, float scale, ctl::dpx::fb<float> * pixels) {
for(row=0; row<4; row++) {
if(row<samples_per_pixel) {
scanline_buffer_float[row]=(float *)alloca(scanline_size);
for(d=0; d<w; d++) {
scanline_buffer_float[row][d]= row==3 ? 1.0 : 0.0;
for(e=0; e<w; e++) {
scanline_buffer_float[row][e]= row==3 ? 1.0 : 0.0;
}
} else {
scanline_buffer_float[row]=NULL;
Expand Down
7 changes: 4 additions & 3 deletions ctlrender/transform.cc
Original file line number Diff line number Diff line change
Expand Up @@ -699,6 +699,7 @@ void transform(const char *inputFile, const char *outputFile,
ctl_operation_t ctl_operation;
CTLParameters::const_iterator parameters_iter;
uint8_t i;
uint32_t j;
std::string error;
ctl::dpx::fb<float> image_buffer;

Expand Down Expand Up @@ -807,11 +808,11 @@ void transform(const char *inputFile, const char *outputFile,

char name[16];

for (i = 4; i < image_buffer.depth(); i++)
for (j = 4; j < image_buffer.depth(); j++)
{
memset(name, 0, sizeof(name));
snprintf(name, sizeof(name) - 1, "c%02dIn", i);
ctl_results.push_back(mkresult(name, NULL, image_buffer, i));
snprintf(name, sizeof(name) - 1, "c%02dIn", j);
ctl_results.push_back(mkresult(name, NULL, image_buffer, j));
}

for (operations_iter = ctl_operations.begin(); operations_iter != ctl_operations.end(); operations_iter++)
Expand Down
2 changes: 1 addition & 1 deletion lib/dpx/dpx_rw.cc
Original file line number Diff line number Diff line change
Expand Up @@ -268,7 +268,7 @@ void rwinfo::write_init(std::ostream *o, dpx *h) {
}

void rwinfo::find_home(dpx *h, uint8_t element, uint64_t size) {
uint8_t i;
uint16_t i;
rwinfo info;
uint64_t eof;
uint64_t actual_eof;
Expand Down

0 comments on commit 470d9f3

Please sign in to comment.