On 7/13/23 17:40, Richard Henderson wrote:
On 7/12/23 21:57, Daniel Henrique Barboza wrote:
+#define ADD_CPU_PROPERTIES_ARRAY(_dev, _array) \
+ for (prop = _array; prop && prop->name; prop++) { \
+ qdev_property_add_static(_dev, prop); \
+ } \
do { } while(0)
Watch the \ on the last line of the macro.
Declare the iterator within the macro, rather than use one defined in the outer
scope.
Like this?
#define ADD_CPU_PROPERTIES_ARRAY(_dev, _array) \
do { \
Property *prop; \
for (prop = _array; prop && prop->name; prop++) { \
qdev_property_add_static(_dev, prop); \
} \
} while(0)
Why not use ARRAY_SIZE?
Hm, the arrays are finishing with DEFINE_PROP_END_OF_LIST() (I copied the
existing
array structure), which adds an empty element, so ARRAY_SIZE will get empty
stuff
in the end.
Since these are new arrays I can get rid of the end_of_list blank element and
use
ARRAY_SIZE().
Daniel
r~