aboutsummaryrefslogtreecommitdiff
path: root/util/keyval.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 /util/keyval.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 'util/keyval.c')
-rw-r--r--util/keyval.c12
1 files changed, 6 insertions, 6 deletions
diff --git a/util/keyval.c b/util/keyval.c
index 1c7351a233..13def4af54 100644
--- a/util/keyval.c
+++ b/util/keyval.c
@@ -126,7 +126,7 @@ static int key_to_index(const char *key, const char **end)
* Else, fail because we have conflicting needs on how to map
* @key_in_cur.
* In any case, take over the reference to @value, i.e. if the caller
- * wants to hold on to a reference, it needs to QINCREF().
+ * wants to hold on to a reference, it needs to qobject_ref().
* Use @key up to @key_cursor to identify the key in error messages.
* On success, return the mapped value.
* On failure, store an error through @errp and return NULL.
@@ -143,7 +143,7 @@ static QObject *keyval_parse_put(QDict *cur,
if (qobject_type(old) != (value ? QTYPE_QSTRING : QTYPE_QDICT)) {
error_setg(errp, "Parameters '%.*s.*' used inconsistently",
(int)(key_cursor - key), key);
- QDECREF(value);
+ qobject_unref(value);
return NULL;
}
if (!value) {
@@ -375,10 +375,10 @@ static QObject *keyval_listify(QDict *cur, GSList *key_of_cur, Error **errp)
error_setg(errp, "Parameter '%s%d' missing", key, i);
g_free(key);
g_free(elt);
- QDECREF(list);
+ qobject_unref(list);
return NULL;
}
- qobject_incref(elt[i]);
+ qobject_ref(elt[i]);
qlist_append_obj(list, elt[i]);
}
@@ -404,7 +404,7 @@ QDict *keyval_parse(const char *params, const char *implied_key,
while (*s) {
s = keyval_parse_one(qdict, s, implied_key, errp);
if (!s) {
- QDECREF(qdict);
+ qobject_unref(qdict);
return NULL;
}
implied_key = NULL;
@@ -412,7 +412,7 @@ QDict *keyval_parse(const char *params, const char *implied_key,
listified = keyval_listify(qdict, NULL, errp);
if (!listified) {
- QDECREF(qdict);
+ qobject_unref(qdict);
return NULL;
}
assert(listified == QOBJECT(qdict));