From: Paolo Bonzini <pbonzini@redhat.com>
To: Auger Eric <eric.auger@redhat.com>,
eric.auger.pro@gmail.com, qemu-devel@nongnu.org,
berrange@redhat.com, ehabkost@redhat.com, armbru@redhat.com
Subject: Re: [PATCH v2 1/2] qom: Introduce object_property_try_add_child()
Date: Wed, 24 Jun 2020 18:16:42 +0200 [thread overview]
Message-ID: <3f1aafa9-aedb-b067-7eb7-5d9bc7ce49d1@redhat.com> (raw)
In-Reply-To: <430f6b32-8456-ac1d-72b3-85e0e59ae9b5@redhat.com>
On 24/06/20 18:02, Auger Eric wrote:
> Hi Paolo,
>
> On 6/24/20 4:17 PM, Auger Eric wrote:
>> Hi Paolo,
>>
>> On 6/24/20 4:12 PM, Paolo Bonzini wrote:
>>> On 24/06/20 14:43, Eric Auger wrote:
>>>> + op = object_property_try_add(obj, name, type, object_get_child_property,
>>>> + NULL, object_finalize_child_property,
>>>> + child, errp);
>>>> + if (!op) {
>>>> + goto out;
>>>> + }
>>>> op->resolve = object_resolve_child_property;
>>>> +out:
>>>> object_ref(child);
>>>> child->parent = obj;
>>>> return op;
>>>
>>> I think if there's an error you need to return NULL without ref-ing
>>> child, shouldn't you?
>> hum yes you're fully right, the out label is badly placed.
> Looks the unref is done in user_creatable_add_type() in case of error.
There are two references involved:
- a reference returned from object_new. user_creatable_add_type()
passes it back to the caller. The object_unref() you found is done
before returning NULL, because in that case nothing is being passed to
the caller
- a reference stored in child->parent. In case of error that reference
is dropped with object_property_del before returning NULL.
object_property_try_add_child must not store anything in child->parent
in case of error, and therefore it need not add that reference either.
I hope this is clearer.
Thanks,
Paolo
> Isn't it the corresponding one? Anyway I think it is better to avoid
> getting the ref here as you suggest (and also free type) and don't unref
> in user_creatable_add_type.
>
> Thanks
>
> Eric
>>>
>>> You can then add another test that object_property_add_child succeeds
>>> after object_property_try_add_child fails.
>> OK
>>
>> Thanks
>>
>> Eric
>>>
>>> Paolo
>>>
>
next prev parent reply other threads:[~2020-06-24 16:18 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-06-24 12:42 [PATCH v2 0/2] Avoid abort on QMP attempt to add an object with duplicate id Eric Auger
2020-06-24 12:43 ` [PATCH v2 1/2] qom: Introduce object_property_try_add_child() Eric Auger
2020-06-24 14:12 ` Paolo Bonzini
2020-06-24 14:17 ` Auger Eric
2020-06-24 16:02 ` Auger Eric
2020-06-24 16:16 ` Paolo Bonzini [this message]
2020-06-24 17:03 ` Auger Eric
2020-06-24 12:43 ` [PATCH v2 2/2] tests/qmp-cmd-test: Add qmp/object-add-duplicate-id Eric Auger
2020-06-24 13:01 ` Thomas Huth
2020-06-24 16:13 ` Auger Eric
2020-06-24 13:35 ` [PATCH v2 0/2] Avoid abort on QMP attempt to add an object with duplicate id no-reply
2020-06-24 14:05 ` Auger Eric
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=3f1aafa9-aedb-b067-7eb7-5d9bc7ce49d1@redhat.com \
--to=pbonzini@redhat.com \
--cc=armbru@redhat.com \
--cc=berrange@redhat.com \
--cc=ehabkost@redhat.com \
--cc=eric.auger.pro@gmail.com \
--cc=eric.auger@redhat.com \
--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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).