All of lore.kernel.org
 help / color / mirror / Atom feed
From: Anthony Liguori <aliguori@us.ibm.com>
To: Peter Maydell <peter.maydell@linaro.org>, qemu-devel@nongnu.org
Cc: Paolo Bonzini <pbonzini@redhat.com>,
	Markus Armbruster <armbru@redhat.com>,
	patches@linaro.org
Subject: Re: [Qemu-devel] [PATCH v2] qom: Reject attempts to add a property that already exists
Date: Mon, 08 Oct 2012 08:29:03 -0500	[thread overview]
Message-ID: <87haq5rt28.fsf@codemonkey.ws> (raw)
In-Reply-To: <CAFEAcA-P65CX3FPEWJHXo1absgXw1PSQeJfpcwTzT5GMnEWeqA@mail.gmail.com>

Peter Maydell <peter.maydell@linaro.org> writes:

> Ping!

This is wrong.

Container properties are added by the user.  You will turn a gracefully
failure (during hotplug) into an abort().

Please limit this to static properties as they are not added by a user.

Regards,

Anthony Liguori

>
> -- PMM
>
> On 7 September 2012 14:55, Peter Maydell <peter.maydell@linaro.org> wrote:
>> Reject attempts to add a property to an object if one of
>> that name already exists. This is always a bug in the caller;
>> this is merely diagnosing it gracefully rather than behaving
>> oddly later.
>>
>> Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
>> ---
>> Changes v1->v2:
>>  * use abort() rather than assert(0), as suggested by Paolo
>>  * make the diagnostic message a little more helpful by
>>    including the type name, and adding '' around names
>>  * the patches fixing bugs which this patch makes fatal errors
>>    have both now been committed to master, so there's no
>>    barrier to committing it now
>>
>>  qom/object.c |   13 ++++++++++++-
>>  1 file changed, 12 insertions(+), 1 deletion(-)
>>
>> diff --git a/qom/object.c b/qom/object.c
>> index e3e9242..3da4c0e 100644
>> --- a/qom/object.c
>> +++ b/qom/object.c
>> @@ -620,7 +620,18 @@ void object_property_add(Object *obj, const char *name, const char *type,
>>                           ObjectPropertyRelease *release,
>>                           void *opaque, Error **errp)
>>  {
>> -    ObjectProperty *prop = g_malloc0(sizeof(*prop));
>> +    ObjectProperty *prop;
>> +
>> +    QTAILQ_FOREACH(prop, &obj->properties, node) {
>> +        if (strcmp(prop->name, name) == 0) {
>> +            /* This is always a bug in the caller */
>> +            fprintf(stderr, "attempt to add duplicate property '%s'"
>> +                    " to object (type '%s')\n", name, object_get_typename(obj));
>> +            abort();
>> +        }
>> +    }
>> +
>> +    prop = g_malloc0(sizeof(*prop));
>>
>>      prop->name = g_strdup(name);
>>      prop->type = g_strdup(type);
>> --
>> 1.7.9.5
>>
>>

  reply	other threads:[~2012-10-08 13:29 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-09-07 13:55 [Qemu-devel] [PATCH v2] qom: Reject attempts to add a property that already exists Peter Maydell
2012-09-07 14:13 ` Andreas Färber
2012-10-08 13:00 ` Peter Maydell
2012-10-08 13:29   ` Anthony Liguori [this message]
2012-10-08 13:38     ` Peter Crosthwaite
2012-10-08 13:57       ` Peter Maydell
2012-10-08 13:47     ` Peter Maydell
2012-10-08 17:06       ` Anthony Liguori

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87haq5rt28.fsf@codemonkey.ws \
    --to=aliguori@us.ibm.com \
    --cc=armbru@redhat.com \
    --cc=patches@linaro.org \
    --cc=pbonzini@redhat.com \
    --cc=peter.maydell@linaro.org \
    --cc=qemu-devel@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.