On Tue, 15 Aug 2023 at 13:44, Daniel Henrique Barboza <dbarb...@ventanamicro.com> wrote: > > > > On 8/10/23 14:49, Alistair Francis wrote: > > On Thu, Jul 27, 2023 at 6:20 PM Daniel Henrique Barboza > > <dbarb...@ventanamicro.com> wrote: > >> > >> This last blank element is used by the 'for' loop to check if a property > >> has a valid name. > >> > >> Remove it and use ARRAY_SIZE() instead like riscv_cpu_options is already > >> using. All future arrays will also do the same and we'll able to > >> encapsulate more repetitions in macros later on. > > > > Is this the right approach? This seem different to the rest of QEMU > > I am not sure if we have a 'right approach' in this case or not. I see both > being used in QEMU.
The major use of the DEFINE_PROP_* macros is for creating a property list to pass to device_class_set_props(). Those lists must be terminated with the DEFINE_PROP_END_OF_LIST() marker (because the function takes a pointer and can't tell the size of the list with ARRAY_SIZE()). For cases like this where you're writing code locally to manually iterate through the array and never pass it to any other code in QEMU, both approaches work. But it does seem to me a little confusing to have a non-terminated property array. thanks -- PMM