diff mbox

[4/4] Revert "qom: Add automatic arrayification to object_property_add()"

Message ID 1415812130-2592-5-git-send-email-armbru@redhat.com
State New
Headers show

Commit Message

Markus Armbruster Nov. 12, 2014, 5:08 p.m. UTC
This reverts commit 339659041f87a76f8b71ad3d12cadfc5f89b4bb3.

It's been replaced by object_gen_new_property_name().

Signed-off-by: Markus Armbruster <armbru@redhat.com>
---
 qom/object.c | 21 ---------------------
 1 file changed, 21 deletions(-)

Comments

Andreas Färber Nov. 12, 2014, 5:14 p.m. UTC | #1
Am 12.11.2014 um 18:08 schrieb Markus Armbruster:
> This reverts commit 339659041f87a76f8b71ad3d12cadfc5f89b4bb3.
> 
> It's been replaced by object_gen_new_property_name().
> 
> Signed-off-by: Markus Armbruster <armbru@redhat.com>
> ---
>  qom/object.c | 21 ---------------------
>  1 file changed, 21 deletions(-)

Acked-by: Andreas Färber <afaerber@suse.de>

I believe the sole purpose was to share code between memory and gpio
here. If we agree on how to do that differently, this can be dropped.

Regards,
Andreas
Paolo Bonzini Nov. 12, 2014, 10:25 p.m. UTC | #2
On 12/11/2014 18:14, Andreas Färber wrote:
>> > This reverts commit 339659041f87a76f8b71ad3d12cadfc5f89b4bb3.
>> > 
>> > It's been replaced by object_gen_new_property_name().
>> > 
>> > Signed-off-by: Markus Armbruster <armbru@redhat.com>
>> > ---
>> >  qom/object.c | 21 ---------------------
>> >  1 file changed, 21 deletions(-)
> Acked-by: Andreas Färber <afaerber@suse.de>
> 
> I believe the sole purpose was to share code between memory and gpio
> here.

The plan was to move [*] down into the devices.  Devices that do not
need to arrayify properties (e.g. most qdev-ified devices) can then skip
the [*] and have nicer names.

Paolo
Peter Maydell Nov. 12, 2014, 10:47 p.m. UTC | #3
On 12 November 2014 22:25, Paolo Bonzini <pbonzini@redhat.com> wrote:
> The plan was to move [*] down into the devices.  Devices that do not
> need to arrayify properties (e.g. most qdev-ified devices) can then skip
> the [*] and have nicer names.

Qdev devices have array properties already via a different
mechanism, right? (Did we have a plan to unify them somehow?)

-- PMM
Paolo Bonzini Nov. 13, 2014, 10:05 a.m. UTC | #4
On 12/11/2014 23:47, Peter Maydell wrote:
> On 12 November 2014 22:25, Paolo Bonzini <pbonzini@redhat.com> wrote:
> > The plan was to move [*] down into the devices.  Devices that do not
> > need to arrayify properties (e.g. most qdev-ified devices) can then skip
> > the [*] and have nicer names.
>
> Qdev devices have array properties already via a different
> mechanism, right? (Did we have a plan to unify them somehow?)

I've never looked into qdev array properties that much, actually.

But these are not properties with a JSON-array type; they are basically
just "a bunch of properties with similar names".

Paolo
Peter Maydell Nov. 13, 2014, 10:50 a.m. UTC | #5
On 13 November 2014 10:05, Paolo Bonzini <pbonzini@redhat.com> wrote:
>
>
> On 12/11/2014 23:47, Peter Maydell wrote:
>> On 12 November 2014 22:25, Paolo Bonzini <pbonzini@redhat.com> wrote:
>> > The plan was to move [*] down into the devices.  Devices that do not
>> > need to arrayify properties (e.g. most qdev-ified devices) can then skip
>> > the [*] and have nicer names.
>>
>> Qdev devices have array properties already via a different
>> mechanism, right? (Did we have a plan to unify them somehow?)
>
> I've never looked into qdev array properties that much, actually.

qdev array properties work by:
 * user of the device sets the "len-myarray" property to n
 * this automatically causes the creation of properties
   "myarray[0]" through to "myarray[n-1]" and allocation of
   some memory to contain their values
 * user of the device can then set those properties on the device

So you can use them to define properties which are
variable-length arrays, rather than having to decide at
build time how long the array could possibly be.

-- PMM
diff mbox

Patch

diff --git a/qom/object.c b/qom/object.c
index 4c46662..2aed3de 100644
--- a/qom/object.c
+++ b/qom/object.c
@@ -729,27 +729,6 @@  object_property_add(Object *obj, const char *name, const char *type,
                     void *opaque, Error **errp)
 {
     ObjectProperty *prop;
-    size_t name_len = strlen(name);
-
-    if (name_len >= 3 && !memcmp(name + name_len - 3, "[*]", 4)) {
-        int i;
-        ObjectProperty *ret;
-        char *name_no_array = g_strdup(name);
-
-        name_no_array[name_len - 3] = '\0';
-        for (i = 0; ; ++i) {
-            char *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) {
-                break;
-            }
-        }
-        g_free(name_no_array);
-        return ret;
-    }
 
     QTAILQ_FOREACH(prop, &obj->properties, node) {
         if (strcmp(prop->name, name) == 0) {