aboutsummaryrefslogtreecommitdiff
path: root/tests/check-qnum.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/check-qnum.c
parent3d3eacaeccaab718ea0e2ddaa578bfae9e311c59 (diff)
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/check-qnum.c')
-rw-r--r--tests/check-qnum.c28
1 files changed, 14 insertions, 14 deletions
diff --git a/tests/check-qnum.c b/tests/check-qnum.c
index 9187da734b..4105015872 100644
--- a/tests/check-qnum.c
+++ b/tests/check-qnum.c
@@ -35,7 +35,7 @@ static void qnum_from_int_test(void)
g_assert_cmpint(qn->base.refcnt, ==, 1);
g_assert_cmpint(qobject_type(QOBJECT(qn)), ==, QTYPE_QNUM);
- QDECREF(qn);
+ qobject_unref(qn);
}
static void qnum_from_uint_test(void)
@@ -50,7 +50,7 @@ static void qnum_from_uint_test(void)
g_assert(qn->base.refcnt == 1);
g_assert(qobject_type(QOBJECT(qn)) == QTYPE_QNUM);
- QDECREF(qn);
+ qobject_unref(qn);
}
static void qnum_from_double_test(void)
@@ -65,7 +65,7 @@ static void qnum_from_double_test(void)
g_assert_cmpint(qn->base.refcnt, ==, 1);
g_assert_cmpint(qobject_type(QOBJECT(qn)), ==, QTYPE_QNUM);
- QDECREF(qn);
+ qobject_unref(qn);
}
static void qnum_from_int64_test(void)
@@ -76,7 +76,7 @@ static void qnum_from_int64_test(void)
qn = qnum_from_int(value);
g_assert_cmpint((int64_t) qn->u.i64, ==, value);
- QDECREF(qn);
+ qobject_unref(qn);
}
static void qnum_get_int_test(void)
@@ -87,7 +87,7 @@ static void qnum_get_int_test(void)
qn = qnum_from_int(value);
g_assert_cmpint(qnum_get_int(qn), ==, value);
- QDECREF(qn);
+ qobject_unref(qn);
}
static void qnum_get_uint_test(void)
@@ -100,25 +100,25 @@ static void qnum_get_uint_test(void)
qn = qnum_from_uint(value);
g_assert(qnum_get_try_uint(qn, &val));
g_assert_cmpuint(val, ==, value);
- QDECREF(qn);
+ qobject_unref(qn);
qn = qnum_from_int(value);
g_assert(qnum_get_try_uint(qn, &val));
g_assert_cmpuint(val, ==, value);
- QDECREF(qn);
+ qobject_unref(qn);
/* invalid cases */
qn = qnum_from_int(-1);
g_assert(!qnum_get_try_uint(qn, &val));
- QDECREF(qn);
+ qobject_unref(qn);
qn = qnum_from_uint(-1ULL);
g_assert(!qnum_get_try_int(qn, &ival));
- QDECREF(qn);
+ qobject_unref(qn);
qn = qnum_from_double(0.42);
g_assert(!qnum_get_try_uint(qn, &val));
- QDECREF(qn);
+ qobject_unref(qn);
}
static void qobject_to_qnum_test(void)
@@ -127,11 +127,11 @@ static void qobject_to_qnum_test(void)
qn = qnum_from_int(0);
g_assert(qobject_to(QNum, QOBJECT(qn)) == qn);
- QDECREF(qn);
+ qobject_unref(qn);
qn = qnum_from_double(0);
g_assert(qobject_to(QNum, QOBJECT(qn)) == qn);
- QDECREF(qn);
+ qobject_unref(qn);
}
static void qnum_to_string_test(void)
@@ -143,13 +143,13 @@ static void qnum_to_string_test(void)
tmp = qnum_to_string(qn);
g_assert_cmpstr(tmp, ==, "123456");
g_free(tmp);
- QDECREF(qn);
+ qobject_unref(qn);
qn = qnum_from_double(0.42);
tmp = qnum_to_string(qn);
g_assert_cmpstr(tmp, ==, "0.42");
g_free(tmp);
- QDECREF(qn);
+ qobject_unref(qn);
}
int main(int argc, char **argv)