summaryrefslogtreecommitdiff
path: root/block
diff options
context:
space:
mode:
authorMarc-André Lureau <marcandre.lureau@redhat.com>2018-04-19 17:01:44 +0200
committerMarkus Armbruster <armbru@redhat.com>2018-05-04 08:27:53 +0200
commitf5a74a5a50387c6f980b2e2f94f062487a1826da (patch)
treeeefbe4d2f8bb0f889c9643d140fd702f131c4fd0 /block
parentcb3e7f08aeaab0ab13e629ce8496dca150a449ba (diff)
downloadqemu-f5a74a5a50387c6f980b2e2f94f062487a1826da.tar.gz
qobject: Modify qobject_ref() to return obj
For convenience and clarity, make it possible to call qobject_ref() at the time when the reference is associated with a variable, or argument, by making qobject_ref() return the same pointer as given. Use that to simplify the callers. Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com> Reviewed-by: Eric Blake <eblake@redhat.com> Message-Id: <20180419150145.24795-5-marcandre.lureau@redhat.com> Reviewed-by: Markus Armbruster <armbru@redhat.com> [Useless change to qobject_ref_impl() dropped, commit message improved slightly] Signed-off-by: Markus Armbruster <armbru@redhat.com>
Diffstat (limited to 'block')
-rw-r--r--block/blkdebug.c7
-rw-r--r--block/blkverify.c8
-rw-r--r--block/null.c3
-rw-r--r--block/nvme.c3
-rw-r--r--block/quorum.c4
5 files changed, 11 insertions, 14 deletions
diff --git a/block/blkdebug.c b/block/blkdebug.c
index 689703d386..053372c22e 100644
--- a/block/blkdebug.c
+++ b/block/blkdebug.c
@@ -845,13 +845,12 @@ static void blkdebug_refresh_filename(BlockDriverState *bs, QDict *options)
opts = qdict_new();
qdict_put_str(opts, "driver", "blkdebug");
- qobject_ref(bs->file->bs->full_open_options);
- qdict_put(opts, "image", bs->file->bs->full_open_options);
+ qdict_put(opts, "image", qobject_ref(bs->file->bs->full_open_options));
for (e = qdict_first(options); e; e = qdict_next(options, e)) {
if (strcmp(qdict_entry_key(e), "x-image")) {
- qobject_ref(qdict_entry_value(e));
- qdict_put_obj(opts, qdict_entry_key(e), qdict_entry_value(e));
+ qdict_put_obj(opts, qdict_entry_key(e),
+ qobject_ref(qdict_entry_value(e)));
}
}
diff --git a/block/blkverify.c b/block/blkverify.c
index 3cffcb1ca6..754cc9e857 100644
--- a/block/blkverify.c
+++ b/block/blkverify.c
@@ -291,10 +291,10 @@ static void blkverify_refresh_filename(BlockDriverState *bs, QDict *options)
QDict *opts = qdict_new();
qdict_put_str(opts, "driver", "blkverify");
- qobject_ref(bs->file->bs->full_open_options);
- qdict_put(opts, "raw", bs->file->bs->full_open_options);
- qobject_ref(s->test_file->bs->full_open_options);
- qdict_put(opts, "test", s->test_file->bs->full_open_options);
+ qdict_put(opts, "raw",
+ qobject_ref(bs->file->bs->full_open_options));
+ qdict_put(opts, "test",
+ qobject_ref(s->test_file->bs->full_open_options));
bs->full_open_options = opts;
}
diff --git a/block/null.c b/block/null.c
index 700a2d0857..3944550f67 100644
--- a/block/null.c
+++ b/block/null.c
@@ -244,7 +244,6 @@ static int coroutine_fn null_co_block_status(BlockDriverState *bs,
static void null_refresh_filename(BlockDriverState *bs, QDict *opts)
{
- qobject_ref(opts);
qdict_del(opts, "filename");
if (!qdict_size(opts)) {
@@ -253,7 +252,7 @@ static void null_refresh_filename(BlockDriverState *bs, QDict *opts)
}
qdict_put_str(opts, "driver", bs->drv->format_name);
- bs->full_open_options = opts;
+ bs->full_open_options = qobject_ref(opts);
}
static BlockDriver bdrv_null_co = {
diff --git a/block/nvme.c b/block/nvme.c
index e192da9ee1..6f71122bf5 100644
--- a/block/nvme.c
+++ b/block/nvme.c
@@ -1073,7 +1073,6 @@ static int nvme_reopen_prepare(BDRVReopenState *reopen_state,
static void nvme_refresh_filename(BlockDriverState *bs, QDict *opts)
{
- qobject_ref(opts);
qdict_del(opts, "filename");
if (!qdict_size(opts)) {
@@ -1082,7 +1081,7 @@ static void nvme_refresh_filename(BlockDriverState *bs, QDict *opts)
}
qdict_put_str(opts, "driver", bs->drv->format_name);
- bs->full_open_options = opts;
+ bs->full_open_options = qobject_ref(opts);
}
static void nvme_refresh_limits(BlockDriverState *bs, Error **errp)
diff --git a/block/quorum.c b/block/quorum.c
index 862cea366d..a5051da56e 100644
--- a/block/quorum.c
+++ b/block/quorum.c
@@ -1082,8 +1082,8 @@ static void quorum_refresh_filename(BlockDriverState *bs, QDict *options)
children = qlist_new();
for (i = 0; i < s->num_children; i++) {
- qobject_ref(s->children[i]->bs->full_open_options);
- qlist_append(children, s->children[i]->bs->full_open_options);
+ qlist_append(children,
+ qobject_ref(s->children[i]->bs->full_open_options));
}
opts = qdict_new();