aboutsummaryrefslogtreecommitdiff
path: root/tests/libqtest.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/libqtest.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/libqtest.c')
-rw-r--r--tests/libqtest.c24
1 files changed, 12 insertions, 12 deletions
diff --git a/tests/libqtest.c b/tests/libqtest.c
index 6f33a37667..43fb97e035 100644
--- a/tests/libqtest.c
+++ b/tests/libqtest.c
@@ -517,8 +517,8 @@ void qmp_fd_sendv(int fd, const char *fmt, va_list ap)
/* Send QMP request */
socket_send(fd, str, qstring_get_length(qstr));
- QDECREF(qstr);
- qobject_decref(qobj);
+ qobject_unref(qstr);
+ qobject_unref(qobj);
}
}
@@ -585,7 +585,7 @@ void qtest_async_qmp(QTestState *s, const char *fmt, ...)
void qtest_qmpv_discard_response(QTestState *s, const char *fmt, va_list ap)
{
QDict *response = qtest_qmpv(s, fmt, ap);
- QDECREF(response);
+ qobject_unref(response);
}
void qtest_qmp_discard_response(QTestState *s, const char *fmt, ...)
@@ -596,7 +596,7 @@ void qtest_qmp_discard_response(QTestState *s, const char *fmt, ...)
va_start(ap, fmt);
response = qtest_qmpv(s, fmt, ap);
va_end(ap);
- QDECREF(response);
+ qobject_unref(response);
}
QDict *qtest_qmp_eventwait_ref(QTestState *s, const char *event)
@@ -609,7 +609,7 @@ QDict *qtest_qmp_eventwait_ref(QTestState *s, const char *event)
(strcmp(qdict_get_str(response, "event"), event) == 0)) {
return response;
}
- QDECREF(response);
+ qobject_unref(response);
}
}
@@ -618,7 +618,7 @@ void qtest_qmp_eventwait(QTestState *s, const char *event)
QDict *response;
response = qtest_qmp_eventwait_ref(s, event);
- QDECREF(response);
+ qobject_unref(response);
}
char *qtest_hmpv(QTestState *s, const char *fmt, va_list ap)
@@ -634,12 +634,12 @@ char *qtest_hmpv(QTestState *s, const char *fmt, va_list ap)
ret = g_strdup(qdict_get_try_str(resp, "return"));
while (ret == NULL && qdict_get_try_str(resp, "event")) {
/* Ignore asynchronous QMP events */
- QDECREF(resp);
+ qobject_unref(resp);
resp = qtest_qmp_receive(s);
ret = g_strdup(qdict_get_try_str(resp, "return"));
}
g_assert(ret);
- QDECREF(resp);
+ qobject_unref(resp);
g_free(cmd);
return ret;
}
@@ -1021,7 +1021,7 @@ void qtest_cb_for_every_machine(void (*cb)(const char *machine))
}
qtest_end();
- QDECREF(response);
+ qobject_unref(response);
}
/*
@@ -1050,7 +1050,7 @@ void qtest_qmp_device_add(const char *driver, const char *id, const char *fmt,
g_assert(response);
g_assert(!qdict_haskey(response, "event")); /* We don't expect any events */
g_assert(!qdict_haskey(response, "error"));
- QDECREF(response);
+ qobject_unref(response);
}
/*
@@ -1095,6 +1095,6 @@ void qtest_qmp_device_del(const char *id)
g_assert(event);
g_assert_cmpstr(qdict_get_str(event, "event"), ==, "DEVICE_DELETED");
- QDECREF(response1);
- QDECREF(response2);
+ qobject_unref(response1);
+ qobject_unref(response2);
}