From f41e4b82a42e22f7cdc9a05d02125bdc63334e6a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Zbigniew=20J=C4=99drzejewski-Szmek?= Date: Mon, 6 Feb 2023 12:03:09 +0100 Subject: [PATCH] shared/json: avoid use of fake flex array --- src/shared/json.c | 17 ++++++----------- 1 file changed, 6 insertions(+), 11 deletions(-) diff --git a/src/shared/json.c b/src/shared/json.c index fd54835efa3..c2700481971 100644 --- a/src/shared/json.c +++ b/src/shared/json.c @@ -101,17 +101,12 @@ struct JsonVariant { /* If is_reference as indicated above is set, this is where the reference object is actually stored. */ JsonVariant *reference; - /* Strings are placed immediately after the structure. Note that when this is a JsonVariant embedded - * into an array we might encode strings up to INLINE_STRING_LENGTH characters directly inside the - * element, while longer strings are stored as references. When this object is not embedded into an - * array, but stand-alone we allocate the right size for the whole structure, i.e. the array might be - * much larger than INLINE_STRING_LENGTH. - * - * Note that because we want to allocate arrays of the JsonVariant structure we specify [0] here, - * rather than the prettier []. If we wouldn't, then this char array would have undefined size, and so - * would the union and then the struct this is included in. And of structures with undefined size we - * can't allocate arrays (at least not easily). */ - char string[0]; + /* Strings are placed immediately after the structure. Note that when this is a JsonVariant + * embedded into an array we might encode strings up to INLINE_STRING_LENGTH characters + * directly inside the element, while longer strings are stored as references. When this + * object is not embedded into an array, but stand-alone, we allocate the right size for the + * whole structure, i.e. the array might be much larger than INLINE_STRING_LENGTH. */ + DECLARE_FLEX_ARRAY(char, string); }; };