mirror of
https://github.com/Motorhead1991/qemu.git
synced 2025-08-05 16:53:55 -06:00
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>
This commit is contained in:
parent
3d3eacaecc
commit
cb3e7f08ae
94 changed files with 609 additions and 613 deletions
|
@ -19,7 +19,7 @@ static char *get_cpu0_qom_path(void)
|
|||
|
||||
cpu0 = qobject_to(QDict, qlist_peek(ret));
|
||||
path = g_strdup(qdict_get_str(cpu0, "qom_path"));
|
||||
QDECREF(resp);
|
||||
qobject_unref(resp);
|
||||
return path;
|
||||
}
|
||||
|
||||
|
@ -30,8 +30,8 @@ static QObject *qom_get(const char *path, const char *prop)
|
|||
" 'property': %s } }",
|
||||
path, prop);
|
||||
QObject *ret = qdict_get(resp, "return");
|
||||
qobject_incref(ret);
|
||||
QDECREF(resp);
|
||||
qobject_ref(ret);
|
||||
qobject_unref(resp);
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
@ -41,7 +41,7 @@ static bool qom_get_bool(const char *path, const char *prop)
|
|||
QBool *value = qobject_to(QBool, qom_get(path, prop));
|
||||
bool b = qbool_get_bool(value);
|
||||
|
||||
QDECREF(value);
|
||||
qobject_unref(value);
|
||||
return b;
|
||||
}
|
||||
#endif
|
||||
|
@ -66,7 +66,7 @@ static void test_cpuid_prop(const void *data)
|
|||
g_assert_cmpint(val, ==, args->expected_value);
|
||||
qtest_end();
|
||||
|
||||
QDECREF(value);
|
||||
qobject_unref(value);
|
||||
g_free(path);
|
||||
}
|
||||
|
||||
|
@ -142,8 +142,8 @@ static void test_feature_flag(const void *data)
|
|||
|
||||
g_assert(!!(value & (1U << args->bitnr)) == args->expected_value);
|
||||
|
||||
QDECREF(present);
|
||||
QDECREF(filtered);
|
||||
qobject_unref(present);
|
||||
qobject_unref(filtered);
|
||||
g_free(path);
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue