Silence GCC stringop-overflow
At optimization level -O3, GCC generates a warning about its own optimizations, likely due to loop unrolling. Manually unroll the loop to eliminate any ambiguity and prevent the warning.
This commit is contained in:
parent
3dca8dbf66
commit
a27d49b6f2
|
@ -265,9 +265,7 @@ static uint8_t *rtga_tga_load(rtga_context *s,
|
||||||
int RLE_repeating = 0;
|
int RLE_repeating = 0;
|
||||||
int RLE_count = 0;
|
int RLE_count = 0;
|
||||||
int read_next_pixel = 1;
|
int read_next_pixel = 1;
|
||||||
/* Needs to be at least 33 bytes to silence a GCC warning,
|
unsigned char raw_data[4] = {0};
|
||||||
* only 4 are actually used */
|
|
||||||
unsigned char raw_data[33] = {0};
|
|
||||||
unsigned char *tga_palette = NULL;
|
unsigned char *tga_palette = NULL;
|
||||||
|
|
||||||
/* Do I need to load a palette? */
|
/* Do I need to load a palette? */
|
||||||
|
@ -337,8 +335,14 @@ static uint8_t *rtga_tga_load(rtga_context *s,
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
/* read in the data raw */
|
/* read in the data raw */
|
||||||
for (j = 0; j*8 < tga_bits_per_pixel; ++j)
|
/* manually unroll, probably GCC bug 92955 */
|
||||||
raw_data[j] = rtga_get8(s);
|
j = 0;
|
||||||
|
switch (tga_bits_per_pixel) {
|
||||||
|
case 32: raw_data[j++] = rtga_get8(s); /* fallthrough */
|
||||||
|
case 24: raw_data[j++] = rtga_get8(s); /* fallthrough */
|
||||||
|
case 16: raw_data[j++] = rtga_get8(s); /* fallthrough */
|
||||||
|
case 8: raw_data[j++] = rtga_get8(s);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* clear the reading flag for the next pixel */
|
/* clear the reading flag for the next pixel */
|
||||||
|
|
Loading…
Reference in New Issue