summary refs log tree commit diff stats
path: root/tests/test-qobject-output-visitor.c
diff options
context:
space:
mode:
authorMarc-André Lureau <marcandre.lureau@redhat.com>2018-04-19 17:01:43 +0200
committerMarkus Armbruster <armbru@redhat.com>2018-05-04 08:27:53 +0200
commitcb3e7f08aeaab0ab13e629ce8496dca150a449ba (patch)
tree189830b93bea625aac19f86f26dc4b04cd99f5a3 /tests/test-qobject-output-visitor.c
parent3d3eacaeccaab718ea0e2ddaa578bfae9e311c59 (diff)
downloadfocaccia-qemu-cb3e7f08aeaab0ab13e629ce8496dca150a449ba.tar.gz
focaccia-qemu-cb3e7f08aeaab0ab13e629ce8496dca150a449ba.zip
qobject: Replace qobject_incref/QINCREF qobject_decref/QDECREF
Now that we can safely call QOBJECT() on QObject * as well as its
subtypes, we can have macros qobject_ref() / qobject_unref() that work
everywhere instead of having to use QINCREF() / QDECREF() for QObject
and qobject_incref() / qobject_decref() for its subtypes.

The replacement is mechanical, except I broke a long line, and added a
cast in monitor_qmp_cleanup_req_queue_locked().  Unlike
qobject_decref(), qobject_unref() doesn't accept void *.

Note that the new macros evaluate their argument exactly once, thus no
need to shout them.

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
Message-Id: <20180419150145.24795-4-marcandre.lureau@redhat.com>
Reviewed-by: Markus Armbruster <armbru@redhat.com>
[Rebased, semantic conflict resolved, commit message improved]
Signed-off-by: Markus Armbruster <armbru@redhat.com>
Diffstat (limited to 'tests/test-qobject-output-visitor.c')
-rw-r--r--tests/test-qobject-output-visitor.c18
1 files changed, 9 insertions, 9 deletions
diff --git a/tests/test-qobject-output-visitor.c b/tests/test-qobject-output-visitor.c
index ecf21c0f31..be635854b4 100644
--- a/tests/test-qobject-output-visitor.c
+++ b/tests/test-qobject-output-visitor.c
@@ -40,7 +40,7 @@ static void visitor_output_teardown(TestOutputVisitorData *data,
 {
     visit_free(data->ov);
     data->ov = NULL;
-    qobject_decref(data->obj);
+    qobject_unref(data->obj);
     data->obj = NULL;
 }
 
@@ -346,7 +346,7 @@ static void test_visitor_out_any(TestOutputVisitorData *data,
     g_assert(qnum);
     g_assert(qnum_get_try_int(qnum, &val));
     g_assert_cmpint(val, ==, -42);
-    qobject_decref(qobj);
+    qobject_unref(qobj);
 
     visitor_reset(data);
     qdict = qdict_new();
@@ -355,7 +355,7 @@ static void test_visitor_out_any(TestOutputVisitorData *data,
     qdict_put_str(qdict, "string", "foo");
     qobj = QOBJECT(qdict);
     visit_type_any(data->ov, NULL, &qobj, &error_abort);
-    qobject_decref(qobj);
+    qobject_unref(qobj);
     qdict = qobject_to(QDict, visitor_get(data));
     g_assert(qdict);
     qnum = qobject_to(QNum, qdict_get(qdict, "integer"));
@@ -630,7 +630,7 @@ static void check_native_list(QObject *qobj,
             qvalue = qobject_to(QNum, tmp);
             g_assert(qnum_get_try_uint(qvalue, &val));
             g_assert_cmpint(val, ==, i);
-            qobject_decref(qlist_pop(qlist));
+            qobject_unref(qlist_pop(qlist));
         }
         break;
 
@@ -654,7 +654,7 @@ static void check_native_list(QObject *qobj,
             qvalue = qobject_to(QNum, tmp);
             g_assert(qnum_get_try_int(qvalue, &val));
             g_assert_cmpint(val, ==, i);
-            qobject_decref(qlist_pop(qlist));
+            qobject_unref(qlist_pop(qlist));
         }
         break;
     case USER_DEF_NATIVE_LIST_UNION_KIND_BOOLEAN:
@@ -665,7 +665,7 @@ static void check_native_list(QObject *qobj,
             g_assert(tmp);
             qvalue = qobject_to(QBool, tmp);
             g_assert_cmpint(qbool_get_bool(qvalue), ==, i % 3 == 0);
-            qobject_decref(qlist_pop(qlist));
+            qobject_unref(qlist_pop(qlist));
         }
         break;
     case USER_DEF_NATIVE_LIST_UNION_KIND_STRING:
@@ -678,7 +678,7 @@ static void check_native_list(QObject *qobj,
             qvalue = qobject_to(QString, tmp);
             sprintf(str, "%d", i);
             g_assert_cmpstr(qstring_get_str(qvalue), ==, str);
-            qobject_decref(qlist_pop(qlist));
+            qobject_unref(qlist_pop(qlist));
         }
         break;
     case USER_DEF_NATIVE_LIST_UNION_KIND_NUMBER:
@@ -695,7 +695,7 @@ static void check_native_list(QObject *qobj,
             g_string_printf(double_actual, "%.6f", qnum_get_double(qvalue));
             g_assert_cmpstr(double_actual->str, ==, double_expected->str);
 
-            qobject_decref(qlist_pop(qlist));
+            qobject_unref(qlist_pop(qlist));
             g_string_free(double_expected, true);
             g_string_free(double_actual, true);
         }
@@ -703,7 +703,7 @@ static void check_native_list(QObject *qobj,
     default:
         g_assert_not_reached();
     }
-    QDECREF(qlist);
+    qobject_unref(qlist);
 }
 
 static void test_native_list(TestOutputVisitorData *data,