Skip to content

Commit

Permalink
eliminate rgbas[] VLA, restore -Wvla
Browse files Browse the repository at this point in the history
  • Loading branch information
dankamongmen committed Dec 28, 2024
1 parent b1a0986 commit 41b91f1
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
3 changes: 2 additions & 1 deletion src/lib/blit.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 41b91f1

Please sign in to comment.