test-keyval: fix leaks
PATCH 1/1 test-keyval: fix leaks
--- tests/test-keyval.c | 4 ++++ 1 file changed, 4 insertions(+)
tests/test-keyval.c +4 -0
@@ -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); qlist =qobject_to_qlist (any);g_assert (qlist); +qobject_decref (any); 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);visit_check_struct (v, &error_abort);visit_end_struct (v,NULL );visit_free (v);
Signature · 1 line
2.12.0.191.gc5d8de91d
Quoted 4 lines · Marc-André Lureau
Signed-off-by Marc-André Lureau <[email protected]>--- tests/test-keyval.c | 4 ++++ 1 file changed, 4 insertions(+)
Leaks in the testsuite are not showstoppers, so I'm okay if we defer it to 2.10 to minimize churn now that we are late in hard freeze.
Signature · 3 lines
Eric Blake, Principal Software Engineer Red Hat, Inc. +1-919-301-3266 Virtualization: qemu.org | libvirt.org
Quoted 18 lines · Marc-André Lureau
Signed-off-by Marc-André Lureau <[email protected]>--- tests/test-keyval.c | 4 ++++ 1 file changed, 4 insertions(+)tests/test-keyval.c +1
-0@@ -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 );
tests/test-keyval.c static void test_keyval_visit_any(void) · line 650
Quoted 1 line
tests/test-keyval.c +0
-0@@ -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).
tests/test-keyval.c static void test_keyval_visit_any(void) · line 651
Quoted 1 line
tests/test-keyval.c +0
-0qlist =qobject_to_qlist (any);
Reference count unchanged.
tests/test-keyval.c static void test_keyval_visit_any(void) · line 653
Quoted 2 lines
tests/test-keyval.c +1
-0g_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 ...
tests/test-keyval.c static void test_keyval_visit_any(void) · line 660
Quoted 7 lines
tests/test-keyval.c +2
-0qstr =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?
tests/test-keyval.c static void test_keyval_visit_any(void) · line 663
Quoted 3 lines
tests/test-keyval.c +0
-0visit_check_struct (v, &error_abort);visit_end_struct (v,NULL );visit_free (v);
With the reference counting cleaned up:
Hi
Quoted 44 lines · Markus Armbruster
Quoted 18 lines · Marc-André Lureau
Signed-off-by Marc-André Lureau <[email protected]>--- tests/test-keyval.c | 4 ++++ 1 file changed, 4 insertions(+)tests/test-keyval.c +1
-0@@ -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 );tests/test-keyval.c static void test_keyval_visit_any(void) · line 650
Quoted 1 line
tests/test-keyval.c +0
-0@@ -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).tests/test-keyval.c static void test_keyval_visit_any(void) · line 651
Quoted 1 line
tests/test-keyval.c +0
-0qlist =qobject_to_qlist (any);Reference count unchanged.
tests/test-keyval.c static void test_keyval_visit_any(void) · line 653
Quoted 2 lines
tests/test-keyval.c +1
-0g_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 ...
tests/test-keyval.c static void test_keyval_visit_any(void) · line 660
Quoted 7 lines
tests/test-keyval.c +2
-0qstr =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);
Quoted 2 lines
... here. Okay to do that on commit?
sure, makes sense
Quoted 8 lines
tests/test-keyval.c static void test_keyval_visit_any(void) · line 663
Quoted 3 lines
tests/test-keyval.c +0
-0visit_check_struct (v, &error_abort);visit_end_struct (v,NULL );visit_free (v);With the reference counting cleaned up:
Reviewed-by Markus Armbruster <[email protected]>
thanks
Signature · 1 line
Marc-André Lureau
Markus Armbruster
AppliedQuoted 58 lines · Marc-André Lureau
Hi
Quoted 44 lines · Markus Armbruster
Quoted 18 lines · Marc-André Lureau
Signed-off-by Marc-André Lureau <[email protected]>--- tests/test-keyval.c | 4 ++++ 1 file changed, 4 insertions(+)tests/test-keyval.c +1
-0@@ -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 );tests/test-keyval.c static void test_keyval_visit_any(void) · line 650
Quoted 1 line
tests/test-keyval.c +0
-0@@ -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).tests/test-keyval.c static void test_keyval_visit_any(void) · line 651
Quoted 1 line
tests/test-keyval.c +0
-0qlist =qobject_to_qlist (any);Reference count unchanged.
tests/test-keyval.c static void test_keyval_visit_any(void) · line 653
Quoted 2 lines
tests/test-keyval.c +1
-0g_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 ...
tests/test-keyval.c static void test_keyval_visit_any(void) · line 660
Quoted 7 lines
tests/test-keyval.c +2
-0qstr =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);Quoted 2 lines
... here. Okay to do that on commit?
sure, makes sense
Quoted 4 lines
Quoted 3 lines
tests/test-keyval.c +0
-0visit_check_struct (v, &error_abort);visit_end_struct (v,NULL );visit_free (v);
Quoted 5 lines
Quoted 4 lines
With the reference counting cleaned up:
Reviewed-by Markus Armbruster <[email protected]>thanks
Applied to qapi-next, thanks!