eliminate rgbas[] VLA, restore -Wvla

This commit is contained in:
nick black 2024-12-28 13:01:32 -05:00 committed by nick black
parent 9f770c43fb
commit 5e2dd99019
2 changed files with 3 additions and 2 deletions

View File

@ -130,7 +130,7 @@ endif()
if(MSVC)
add_compile_options(/W4)
else()
add_compile_options(-Wall -Wextra -W -Wshadow -Wstrict-aliasing=2)
add_compile_options(-Wall -Wextra -W -Wshadow -Wvla -Wstrict-aliasing=2)
# -ffast-math dies on NaNs we draw from libav (by -ffinite-math-only)
add_compile_options(-fno-signed-zeros -fno-trapping-math -fassociative-math)
add_compile_options(-fno-math-errno -freciprocal-math -funsafe-math-optimizations)

View File

@ -929,13 +929,14 @@ hires_blit(ncplane* nc, int linesize, const void* data, int leny, int lenx,
//fprintf(stderr, "hiresblitter %dx%d -> %d/%d+%d/%d\n", leny, lenx, dimy, dimx, bargs->u.cell.placey, bargs->u.cell.placex);
const unsigned char* dat = data;
int visy = bargs->begy;
assert(cellheight <= 4); // due to rgbas[] array below
for(y = bargs->u.cell.placey ; visy < (bargs->begy + leny) && y < dimy ; ++y, visy += cellheight){
if(ncplane_cursor_move_yx(nc, y, bargs->u.cell.placex < 0 ? 0 : bargs->u.cell.placex)){
return -1;
}
int visx = bargs->begx;
for(x = bargs->u.cell.placex ; visx < (bargs->begx + lenx) && x < dimx ; ++x, visx += 2){
uint32_t rgbas[cellheight * 2]; // row-major
uint32_t rgbas[8]; // row-major
memset(rgbas, 0, sizeof(rgbas));
memcpy(&rgbas[0], (dat + (linesize * visy) + (visx * 4)), sizeof(*rgbas));
// conditional looks at first column, begininng at the second row