From 41b91f198972645cab80a7a095e9552884832dfd Mon Sep 17 00:00:00 2001 From: nick black Date: Sat, 28 Dec 2024 13:01:32 -0500 Subject: [PATCH] eliminate rgbas[] VLA, restore -Wvla --- CMakeLists.txt | 2 +- src/lib/blit.c | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 1aaba5e9c..2974d8116 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -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) diff --git a/src/lib/blit.c b/src/lib/blit.c index fe042869d..2ef54e98f 100644 --- a/src/lib/blit.c +++ b/src/lib/blit.c @@ -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