On 04/17/2018 08:36 AM, Marc-André Lureau wrote: > 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. > > Note that the new macros evaluate their argument exactly once, thus no > need to shout them. > > Signed-off-by: Marc-André Lureau <marcandre.lur...@redhat.com> > ---
> +++ b/monitor.c > @@ -346,7 +346,7 @@ static void monitor_qmp_cleanup_req_queue_locked(Monitor > *mon) > static void monitor_qmp_cleanup_resp_queue_locked(Monitor *mon) > { > while (!g_queue_is_empty(mon->qmp.qmp_responses)) { > - qobject_decref(g_queue_pop_head(mon->qmp.qmp_responses)); > + qobject_unref((QObject *)g_queue_pop_head(mon->qmp.qmp_responses)); Interesting that you have to add a cast here. That is, the new macro is more type-safe than the old version (since g_queue_pop_head() returns void*); a quick audit of monitor.c shows we only ever pushed QObject* onto the queue in the first place... > @@ -494,9 +494,9 @@ static void monitor_json_emitter(Monitor *mon, QObject > *data) > * caller won't free the data (which will be finally freed in > * responder thread). > */ > - qobject_incref(data); > + qobject_ref(data); > qemu_mutex_lock(&mon->qmp.qmp_queue_lock); > - g_queue_push_tail(mon->qmp.qmp_responses, (void *)data); > + g_queue_push_tail(mon->qmp.qmp_responses, data); ...but you did manage to get rid of the pointless cast to void* in the process. Reviewed-by: Eric Blake <ebl...@redhat.com> -- Eric Blake, Principal Software Engineer Red Hat, Inc. +1-919-301-3266 Virtualization: qemu.org | libvirt.org
signature.asc
Description: OpenPGP digital signature