dircache: use alloca to avoid VLA in struct extension

Clang does not support VLA-in-struct so use alloca to
do the same thing by hand.

Change-Id: Ib135d1a90b00aac3098e4c64f9f5f5e397fe771c
This commit is contained in:
Aidan MacDonald 2026-08-14 13:35:21 +01:00
parent 8cfa4bfd8c
commit 0b52c28933

View file

@ -1395,15 +1395,12 @@ static void sab_process_dir(struct file_base_info *infop, bool issab)
should also filled in beforehand */
/* allocate the stack right now to the max demand */
struct dirsab
{
struct sab sab;
struct sab_component stack[issab ? DIRCACHE_MAX_DEPTH : 1];
} dirsab;
struct sab *sabp = &dirsab.sab;
size_t stackdepth = (issab ? DIRCACHE_MAX_DEPTH : 1);
struct sab *sabp = alloca(sizeof(*sabp) +
sizeof(sabp->stack[0]) * stackdepth);
sabp->quit = false;
sabp->stackend = &sabp->stack[ARRAYLEN(dirsab.stack)];
sabp->stackend = &sabp->stack[stackdepth];
sabp->top = sabp->stackend;
sabp->info = *infop;