From f5a74a5a50387c6f980b2e2f94f062487a1826da Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= Date: Thu, 19 Apr 2018 17:01:44 +0200 Subject: qobject: Modify qobject_ref() to return obj MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 Reviewed-by: Eric Blake Message-Id: <20180419150145.24795-5-marcandre.lureau@redhat.com> Reviewed-by: Markus Armbruster [Useless change to qobject_ref_impl() dropped, commit message improved slightly] Signed-off-by: Markus Armbruster --- block/blkdebug.c | 7 +++---- block/blkverify.c | 8 ++++---- block/null.c | 3 +-- block/nvme.c | 3 +-- block/quorum.c | 4 ++-- 5 files changed, 11 insertions(+), 14 deletions(-) (limited to 'block') 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(); -- cgit v1.2.1