All of lore.kernel.org
 help / color / mirror / Atom feed
From: Markus Armbruster <armbru@redhat.com>
To: "Marc-André Lureau" <marcandre.lureau@gmail.com>
Cc: qemu-devel@nongnu.org
Subject: Re: [Qemu-devel] [PATCH] test-keyval: fix leaks
Date: Wed, 12 Apr 2017 16:56:14 +0200	[thread overview]
Message-ID: <87pogh1xpt.fsf@dusky.pond.sub.org> (raw)
In-Reply-To: <CAJ+F1C+XcrF042iTjsU6y5U7pqZDnaT8zMr1dGhe+W5bm34Naw@mail.gmail.com> (=?utf-8?Q?=22Marc-Andr=C3=A9?= Lureau"'s message of "Wed, 12 Apr 2017 14:33:07 +0000")

Marc-André Lureau <marcandre.lureau@gmail.com> writes:

> Hi
>
> On Wed, Apr 12, 2017 at 3:19 PM Markus Armbruster <armbru@redhat.com> wrote:
>
>> Marc-André Lureau <marcandre.lureau@redhat.com> writes:
>>
>> > Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
>> > ---
>> >  tests/test-keyval.c | 4 ++++
>> >  1 file changed, 4 insertions(+)
>> >
>> > diff --git a/tests/test-keyval.c b/tests/test-keyval.c
>> > index ba19560a22..141ee5d0c4 100644
>> > --- a/tests/test-keyval.c
>> > +++ b/tests/test-keyval.c
>> > @@ -628,6 +628,7 @@ static void test_keyval_visit_alternate(void)
>> >      visit_type_AltNumStr(v, "a", &ans, &error_abort);
>> >      g_assert_cmpint(ans->type, ==, QTYPE_QSTRING);
>> >      g_assert_cmpstr(ans->u.s, ==, "1");
>> > +    qapi_free_AltNumStr(ans);
>> >      visit_type_AltNumInt(v, "a", &ani, &err);
>> >      error_free_or_abort(&err);
>> >      visit_end_struct(v, NULL);
>> > @@ -649,11 +650,14 @@ static void test_keyval_visit_any(void)
>> >      visit_type_any(v, "a", &any, &error_abort);
>>
>> @any becomes a strong reference (qobject_input_type_any() increments the
>> reference count).
>>
>> >      qlist = qobject_to_qlist(any);
>>
>> Reference count unchanged.
>>
>> >      g_assert(qlist);
>> > +    qobject_decref(any);
>>
>> Uh, this is unnecessarily dirty: you relinquish the reference before
>> you're actually done with it.  Works only because there's *another*
>> reference hiding within @v.  Let's move this ...
>>
>> >      qstr = qobject_to_qstring(qlist_pop(qlist));
>> >      g_assert_cmpstr(qstring_get_str(qstr), ==, "null");
>> > +    QDECREF(qstr);
>> >      qstr = qobject_to_qstring(qlist_pop(qlist));
>> >      g_assert_cmpstr(qstring_get_str(qstr), ==, "1");
>> >      g_assert(qlist_empty(qlist));
>> > +    QDECREF(qstr);
>>
>> ... here.  Okay to do that on commit?
>>
>
>  sure, makes sense
>
>
>> >      visit_check_struct(v, &error_abort);
>> >      visit_end_struct(v, NULL);
>> >      visit_free(v);
>>
>> With the reference counting cleaned up:
>> Reviewed-by: Markus Armbruster <armbru@redhat.com>
>>
>>
> thanks

Applied to qapi-next, thanks!

      reply	other threads:[~2017-04-12 14:56 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-04-10 14:21 [Qemu-devel] [PATCH] test-keyval: fix leaks Marc-André Lureau
2017-04-10 15:28 ` Eric Blake
2017-04-12 11:19 ` Markus Armbruster
2017-04-12 14:33   ` Marc-André Lureau
2017-04-12 14:56     ` Markus Armbruster [this message]

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=87pogh1xpt.fsf@dusky.pond.sub.org \
    --to=armbru@redhat.com \
    --cc=marcandre.lureau@gmail.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 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.