Skip to contentSkip to conversation

tests: check-qom-proplist: fix leak

PATCH In review Marc-André Lureau 3 participants 5 messages Jun 9, 2017 – Jul 11, 2017

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 tests: check-qom-proplist: fix leak

user_creatable_add_opts() returns a reference (the other reference is for the root parent/child link).

Leak introduced in commit a1af255f065cc.

---
 tests/check-qom-proplist.c | 2 ++
 1 file changed, 2 insertions(+)
tests/check-qom-proplist.c +2 -0
index 8e432e9ab6..a3cd7ab29f 100644
@@ -428,6 +428,8 @@ static void test_dummy_createcmdl(void)
     g_assert(err == NULL);
     error_free(err);
 
+    object_unref(OBJECT(dobj));
+
     /*
      * cmdline-parsing via qemu_opts_parse() results in a QemuOpts entry
      * corresponding to the Object's ID to be added to the QemuOptsList
Signature · 1 line
2.13.0.91.g00982b8dd
#1 lore raw
Quoted 15 lines · Marc-André Lureau

user_creatable_add_opts() returns a reference (the other reference is for the root parent/child link).

Leak introduced in commit a1af255f065cc.

---
 tests/check-qom-proplist.c | 2 ++
 1 file changed, 2 insertions(+)
tests/check-qom-proplist.c +0 -0
index 8e432e9ab6..a3cd7ab29f 100644

tests/check-qom-proplist.c static void test_dummy_createcmdl(void) · line 431

Quoted 4 lines
tests/check-qom-proplist.c +1 -0
@@ -428,6 +428,8 @@ static void test_dummy_createcmdl(void)
     g_assert(err == NULL);
     error_free(err);
 
+    object_unref(OBJECT(dobj));

This should be spelled QDECREF(dobj);

(Hmm - maybe scripts/coccinelle/qobject.cocci should be taught this cleanup pattern...)

Signature · 3 lines
Eric Blake, Principal Software Engineer
Red Hat, Inc.           +1-919-301-3266
Virtualization:  qemu.org | libvirt.org
#2 lore raw
Quoted 19 lines · Eric Blake
Quoted 18 lines · Marc-André Lureau

user_creatable_add_opts() returns a reference (the other reference is for the root parent/child link).

Leak introduced in commit a1af255f065cc.

---
 tests/check-qom-proplist.c | 2 ++
 1 file changed, 2 insertions(+)
tests/check-qom-proplist.c +0 -0
index 8e432e9ab6..a3cd7ab29f 100644
@@ -428,6 +428,8 @@ static void test_dummy_createcmdl(void)
     g_assert(err == NULL);
     error_free(err);
 
Quoted 3 lines

tests/check-qom-proplist.c static void test_dummy_createcmdl(void) · line 431

Quoted 1 line
tests/check-qom-proplist.c +1 -0
+    object_unref(OBJECT(dobj));

This should be spelled QDECREF(dobj);

Caution, this is object_unref(), not qobject_decref().

We suck at naming.

Quoted 2 lines

(Hmm - maybe scripts/coccinelle/qobject.cocci should be taught this cleanup pattern...)

#3 lore raw
Quoted 21 lines · Markus Armbruster
Quoted 19 lines · Eric Blake
Quoted 18 lines · Marc-André Lureau

user_creatable_add_opts() returns a reference (the other reference is for the root parent/child link).

Leak introduced in commit a1af255f065cc.

---
 tests/check-qom-proplist.c | 2 ++
 1 file changed, 2 insertions(+)
tests/check-qom-proplist.c +0 -0
index 8e432e9ab6..a3cd7ab29f 100644
@@ -428,6 +428,8 @@ static void test_dummy_createcmdl(void)
     g_assert(err == NULL);
     error_free(err);
 
Quoted 5 lines
Quoted 3 lines

tests/check-qom-proplist.c static void test_dummy_createcmdl(void) · line 431

Quoted 1 line
tests/check-qom-proplist.c +1 -0
+    object_unref(OBJECT(dobj));

This should be spelled QDECREF(dobj);

Caution, this is object_unref(), not qobject_decref().

Indeed - now that I re-read it closely, I see that you are right. Oh well - I didn't waste much time improving the qobject coccinelle script, even though this patch proposal is unrelated to that one. :)

Quoted 2 lines

We suck at naming.

Not the first time.

Signature · 3 lines
Eric Blake, Principal Software Engineer
Red Hat, Inc.           +1-919-301-3266
Virtualization:  qemu.org | libvirt.org
Reviewed-by on v1 1/1
#4 lore raw
In reply to Marc-André Lureau

Copying qemu-trivial.

Quoted 15 lines · Marc-André Lureau

user_creatable_add_opts() returns a reference (the other reference is for the root parent/child link).

Leak introduced in commit a1af255f065cc.

---
 tests/check-qom-proplist.c | 2 ++
 1 file changed, 2 insertions(+)
tests/check-qom-proplist.c +0 -0
index 8e432e9ab6..a3cd7ab29f 100644

tests/check-qom-proplist.c static void test_dummy_createcmdl(void) · line 435

Quoted 8 lines
tests/check-qom-proplist.c +2 -0
@@ -428,6 +428,8 @@ static void test_dummy_createcmdl(void)
     g_assert(err == NULL);
     error_free(err);
 
+    object_unref(OBJECT(dobj));
+
     /*
      * cmdline-parsing via qemu_opts_parse() results in a QemuOpts entry
      * corresponding to the Object's ID to be added to the QemuOptsList