On Wed, 16 Sept 2026 at 11:00, Mohamed Mediouni <[email protected]> wrote: > > Working around this compiler warning: > > ../hw/vmapple/aes.c:257:14: warning: variable length array folded to constant > array as an extension [-Wgnu-folding-constant] > 257 | char hex[MAX_LEN * 2 + 1] = ""; > | ^~~~~~~~~~~~~~~ > 1 warning generated.
I'm surprised this wasn't already caught by our '-Wvla' setting: we don't want to have variable length arrays at all. > Signed-off-by: Mohamed Mediouni <[email protected]> > --- > hw/vmapple/aes.c | 3 ++- > 1 file changed, 2 insertions(+), 1 deletion(-) > > diff --git a/hw/vmapple/aes.c b/hw/vmapple/aes.c > index 553e688adb..9d062d5a7f 100644 > --- a/hw/vmapple/aes.c > +++ b/hw/vmapple/aes.c > @@ -253,7 +253,7 @@ static bool cmd_iv(AESState *s) > > static void dump_data(const char *desc, const void *p, size_t len) > { > - static const size_t MAX_LEN = 0x1000; > +#define MAX_LEN 0x1000 > char hex[MAX_LEN * 2 + 1] = ""; > > if (len > MAX_LEN) { > @@ -262,6 +262,7 @@ static void dump_data(const char *desc, const void *p, > size_t len) > > qemu_hexdump_to_buffer(hex, sizeof(hex), p, len); > trace_aes_dump_data(desc, hex); > +#undef MAX_LEN > } MAX_LEN is an awkwardly generic name. I would define it outside the function, something like /* Maximum amount of AES data to dump in trace events */ #define MAX_AES_DUMP_DATA_LEN 0x1000 Then you don't need to #undef it as there's no risk of a clash. (Really this function ought not to do the binary-to-hex conversion of all the data unless the trace event is actually enabled, which docs/devel/tracing.rst says you can do, and it would maybe be nice to emit at least some truncated data in the "more than 1K of data" case, but let's stick to fixing the compile issues for the moment.) thanks -- PMM
