To not be a trial and error based approach. Rather, explicitly scan the existing property lists for the array format strings using a nested strcmp loop.
This prepares support for multiple properties with the same name. Signed-off-by: Peter Crosthwaite <peter.crosthwa...@xilinx.com> --- qom/object.c | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/qom/object.c b/qom/object.c index 96abd34..2a65ab5 100644 --- a/qom/object.c +++ b/qom/object.c @@ -735,19 +735,22 @@ object_property_add(Object *obj, const char *name, const char *type, int i; ObjectProperty *ret; char *name_no_array = g_strdup(name); + char *full_name; name_no_array[name_len - 3] = '\0'; - for (i = 0; ; ++i) { - char *full_name = g_strdup_printf("%s[%d]", name_no_array, i); + for (i = 0;; ++i) { + full_name = g_strdup_printf("%s[%d]", name_no_array, i); - ret = object_property_add(obj, full_name, type, get, set, - release, opaque, NULL); - g_free(full_name); - if (ret) { + if (!object_property_find(obj, full_name, NULL)) { break; } + g_free(full_name); } g_free(name_no_array); + + ret = object_property_add(obj, full_name, type, get, set, + release, opaque, &error_abort); + g_free(full_name); return ret; } -- 2.4.3.3.g905f831