|
|
357786 |
From 48749c03c412fa59ca643bbd4defd341903c33c1 Mon Sep 17 00:00:00 2001
|
|
|
357786 |
From: Markus Armbruster <armbru@redhat.com>
|
|
|
357786 |
Date: Mon, 18 Jun 2018 08:43:19 +0200
|
|
|
357786 |
Subject: [PATCH 12/54] block: Clean up a misuse of qobject_to() in
|
|
|
357786 |
.bdrv_co_create_opts()
|
|
|
357786 |
|
|
|
357786 |
RH-Author: Markus Armbruster <armbru@redhat.com>
|
|
|
357786 |
Message-id: <20180618084330.30009-13-armbru@redhat.com>
|
|
|
357786 |
Patchwork-id: 80733
|
|
|
357786 |
O-Subject: [RHEL-7.6 qemu-kvm-rhev PATCH 12/23] block: Clean up a misuse of qobject_to() in .bdrv_co_create_opts()
|
|
|
357786 |
Bugzilla: 1557995
|
|
|
357786 |
RH-Acked-by: Max Reitz <mreitz@redhat.com>
|
|
|
357786 |
RH-Acked-by: Jeffrey Cody <jcody@redhat.com>
|
|
|
357786 |
RH-Acked-by: Kevin Wolf <kwolf@redhat.com>
|
|
|
357786 |
|
|
|
357786 |
The following pattern occurs in the .bdrv_co_create_opts() methods of
|
|
|
357786 |
parallels, qcow, qcow2, qed, vhdx and vpc:
|
|
|
357786 |
|
|
|
357786 |
qobj = qdict_crumple_for_keyval_qiv(qdict, errp);
|
|
|
357786 |
qobject_unref(qdict);
|
|
|
357786 |
qdict = qobject_to(QDict, qobj);
|
|
|
357786 |
if (qdict == NULL) {
|
|
|
357786 |
ret = -EINVAL;
|
|
|
357786 |
goto done;
|
|
|
357786 |
}
|
|
|
357786 |
|
|
|
357786 |
v = qobject_input_visitor_new_keyval(QOBJECT(qdict));
|
|
|
357786 |
[...]
|
|
|
357786 |
ret = 0;
|
|
|
357786 |
done:
|
|
|
357786 |
qobject_unref(qdict);
|
|
|
357786 |
[...]
|
|
|
357786 |
return ret;
|
|
|
357786 |
|
|
|
357786 |
If qobject_to() fails, we return failure without setting errp. That's
|
|
|
357786 |
wrong. As far as I can tell, it cannot fail here. Clean it up
|
|
|
357786 |
anyway, by removing the useless conversion.
|
|
|
357786 |
|
|
|
357786 |
Signed-off-by: Markus Armbruster <armbru@redhat.com>
|
|
|
357786 |
Reviewed-by: Kevin Wolf <kwolf@redhat.com>
|
|
|
357786 |
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
|
|
|
357786 |
(cherry picked from commit 92adf9dbcd3cf9cedddae995b04a99f5c42ae08c)
|
|
|
357786 |
Signed-off-by: Miroslav Rezanina <mrezanin@redhat.com>
|
|
|
357786 |
---
|
|
|
357786 |
block/parallels.c | 9 ++++-----
|
|
|
357786 |
block/qcow.c | 9 ++++-----
|
|
|
357786 |
block/qcow2.c | 9 ++++-----
|
|
|
357786 |
block/qed.c | 9 ++++-----
|
|
|
357786 |
block/vhdx.c | 9 ++++-----
|
|
|
357786 |
block/vpc.c | 9 ++++-----
|
|
|
357786 |
6 files changed, 24 insertions(+), 30 deletions(-)
|
|
|
357786 |
|
|
|
357786 |
diff --git a/block/parallels.c b/block/parallels.c
|
|
|
357786 |
index aa58955..1c96c39 100644
|
|
|
357786 |
--- a/block/parallels.c
|
|
|
357786 |
+++ b/block/parallels.c
|
|
|
357786 |
@@ -614,7 +614,7 @@ static int coroutine_fn parallels_co_create_opts(const char *filename,
|
|
|
357786 |
BlockdevCreateOptions *create_options = NULL;
|
|
|
357786 |
Error *local_err = NULL;
|
|
|
357786 |
BlockDriverState *bs = NULL;
|
|
|
357786 |
- QDict *qdict = NULL;
|
|
|
357786 |
+ QDict *qdict;
|
|
|
357786 |
QObject *qobj;
|
|
|
357786 |
Visitor *v;
|
|
|
357786 |
int ret;
|
|
|
357786 |
@@ -652,14 +652,13 @@ static int coroutine_fn parallels_co_create_opts(const char *filename,
|
|
|
357786 |
qdict_put_str(qdict, "file", bs->node_name);
|
|
|
357786 |
|
|
|
357786 |
qobj = qdict_crumple_for_keyval_qiv(qdict, errp);
|
|
|
357786 |
- qobject_unref(qdict);
|
|
|
357786 |
- qdict = qobject_to(QDict, qobj);
|
|
|
357786 |
- if (qdict == NULL) {
|
|
|
357786 |
+ if (!qobj) {
|
|
|
357786 |
ret = -EINVAL;
|
|
|
357786 |
goto done;
|
|
|
357786 |
}
|
|
|
357786 |
|
|
|
357786 |
- v = qobject_input_visitor_new_keyval(QOBJECT(qdict));
|
|
|
357786 |
+ v = qobject_input_visitor_new_keyval(qobj);
|
|
|
357786 |
+ qobject_unref(qobj);
|
|
|
357786 |
visit_type_BlockdevCreateOptions(v, NULL, &create_options, &local_err);
|
|
|
357786 |
visit_free(v);
|
|
|
357786 |
|
|
|
357786 |
diff --git a/block/qcow.c b/block/qcow.c
|
|
|
357786 |
index 14b7296..43a595a 100644
|
|
|
357786 |
--- a/block/qcow.c
|
|
|
357786 |
+++ b/block/qcow.c
|
|
|
357786 |
@@ -944,7 +944,7 @@ static int coroutine_fn qcow_co_create_opts(const char *filename,
|
|
|
357786 |
{
|
|
|
357786 |
BlockdevCreateOptions *create_options = NULL;
|
|
|
357786 |
BlockDriverState *bs = NULL;
|
|
|
357786 |
- QDict *qdict = NULL;
|
|
|
357786 |
+ QDict *qdict;
|
|
|
357786 |
QObject *qobj;
|
|
|
357786 |
Visitor *v;
|
|
|
357786 |
const char *val;
|
|
|
357786 |
@@ -996,14 +996,13 @@ static int coroutine_fn qcow_co_create_opts(const char *filename,
|
|
|
357786 |
qdict_put_str(qdict, "file", bs->node_name);
|
|
|
357786 |
|
|
|
357786 |
qobj = qdict_crumple_for_keyval_qiv(qdict, errp);
|
|
|
357786 |
- qobject_unref(qdict);
|
|
|
357786 |
- qdict = qobject_to(QDict, qobj);
|
|
|
357786 |
- if (qdict == NULL) {
|
|
|
357786 |
+ if (!qobj) {
|
|
|
357786 |
ret = -EINVAL;
|
|
|
357786 |
goto fail;
|
|
|
357786 |
}
|
|
|
357786 |
|
|
|
357786 |
- v = qobject_input_visitor_new_keyval(QOBJECT(qdict));
|
|
|
357786 |
+ v = qobject_input_visitor_new_keyval(qobj);
|
|
|
357786 |
+ qobject_unref(qobj);
|
|
|
357786 |
visit_type_BlockdevCreateOptions(v, NULL, &create_options, &local_err);
|
|
|
357786 |
visit_free(v);
|
|
|
357786 |
|
|
|
357786 |
diff --git a/block/qcow2.c b/block/qcow2.c
|
|
|
357786 |
index fa06b41..ede52a8 100644
|
|
|
357786 |
--- a/block/qcow2.c
|
|
|
357786 |
+++ b/block/qcow2.c
|
|
|
357786 |
@@ -3067,7 +3067,7 @@ static int coroutine_fn qcow2_co_create_opts(const char *filename, QemuOpts *opt
|
|
|
357786 |
Error **errp)
|
|
|
357786 |
{
|
|
|
357786 |
BlockdevCreateOptions *create_options = NULL;
|
|
|
357786 |
- QDict *qdict = NULL;
|
|
|
357786 |
+ QDict *qdict;
|
|
|
357786 |
QObject *qobj;
|
|
|
357786 |
Visitor *v;
|
|
|
357786 |
BlockDriverState *bs = NULL;
|
|
|
357786 |
@@ -3140,14 +3140,13 @@ static int coroutine_fn qcow2_co_create_opts(const char *filename, QemuOpts *opt
|
|
|
357786 |
|
|
|
357786 |
/* Now get the QAPI type BlockdevCreateOptions */
|
|
|
357786 |
qobj = qdict_crumple_for_keyval_qiv(qdict, errp);
|
|
|
357786 |
- qobject_unref(qdict);
|
|
|
357786 |
- qdict = qobject_to(QDict, qobj);
|
|
|
357786 |
- if (qdict == NULL) {
|
|
|
357786 |
+ if (!qobj) {
|
|
|
357786 |
ret = -EINVAL;
|
|
|
357786 |
goto finish;
|
|
|
357786 |
}
|
|
|
357786 |
|
|
|
357786 |
- v = qobject_input_visitor_new_keyval(QOBJECT(qdict));
|
|
|
357786 |
+ v = qobject_input_visitor_new_keyval(qobj);
|
|
|
357786 |
+ qobject_unref(qobj);
|
|
|
357786 |
visit_type_BlockdevCreateOptions(v, NULL, &create_options, &local_err);
|
|
|
357786 |
visit_free(v);
|
|
|
357786 |
|
|
|
357786 |
diff --git a/block/qed.c b/block/qed.c
|
|
|
357786 |
index d8810f5..3818888 100644
|
|
|
357786 |
--- a/block/qed.c
|
|
|
357786 |
+++ b/block/qed.c
|
|
|
357786 |
@@ -722,7 +722,7 @@ static int coroutine_fn bdrv_qed_co_create_opts(const char *filename,
|
|
|
357786 |
Error **errp)
|
|
|
357786 |
{
|
|
|
357786 |
BlockdevCreateOptions *create_options = NULL;
|
|
|
357786 |
- QDict *qdict = NULL;
|
|
|
357786 |
+ QDict *qdict;
|
|
|
357786 |
QObject *qobj;
|
|
|
357786 |
Visitor *v;
|
|
|
357786 |
BlockDriverState *bs = NULL;
|
|
|
357786 |
@@ -764,14 +764,13 @@ static int coroutine_fn bdrv_qed_co_create_opts(const char *filename,
|
|
|
357786 |
qdict_put_str(qdict, "file", bs->node_name);
|
|
|
357786 |
|
|
|
357786 |
qobj = qdict_crumple_for_keyval_qiv(qdict, errp);
|
|
|
357786 |
- qobject_unref(qdict);
|
|
|
357786 |
- qdict = qobject_to(QDict, qobj);
|
|
|
357786 |
- if (qdict == NULL) {
|
|
|
357786 |
+ if (!qobj) {
|
|
|
357786 |
ret = -EINVAL;
|
|
|
357786 |
goto fail;
|
|
|
357786 |
}
|
|
|
357786 |
|
|
|
357786 |
- v = qobject_input_visitor_new_keyval(QOBJECT(qdict));
|
|
|
357786 |
+ v = qobject_input_visitor_new_keyval(qobj);
|
|
|
357786 |
+ qobject_unref(qobj);
|
|
|
357786 |
visit_type_BlockdevCreateOptions(v, NULL, &create_options, &local_err);
|
|
|
357786 |
visit_free(v);
|
|
|
357786 |
|
|
|
357786 |
diff --git a/block/vhdx.c b/block/vhdx.c
|
|
|
357786 |
index 32939c4..728d8b3 100644
|
|
|
357786 |
--- a/block/vhdx.c
|
|
|
357786 |
+++ b/block/vhdx.c
|
|
|
357786 |
@@ -1963,7 +1963,7 @@ static int coroutine_fn vhdx_co_create_opts(const char *filename,
|
|
|
357786 |
Error **errp)
|
|
|
357786 |
{
|
|
|
357786 |
BlockdevCreateOptions *create_options = NULL;
|
|
|
357786 |
- QDict *qdict = NULL;
|
|
|
357786 |
+ QDict *qdict;
|
|
|
357786 |
QObject *qobj;
|
|
|
357786 |
Visitor *v;
|
|
|
357786 |
BlockDriverState *bs = NULL;
|
|
|
357786 |
@@ -2004,14 +2004,13 @@ static int coroutine_fn vhdx_co_create_opts(const char *filename,
|
|
|
357786 |
qdict_put_str(qdict, "file", bs->node_name);
|
|
|
357786 |
|
|
|
357786 |
qobj = qdict_crumple_for_keyval_qiv(qdict, errp);
|
|
|
357786 |
- qobject_unref(qdict);
|
|
|
357786 |
- qdict = qobject_to(QDict, qobj);
|
|
|
357786 |
- if (qdict == NULL) {
|
|
|
357786 |
+ if (!qobj) {
|
|
|
357786 |
ret = -EINVAL;
|
|
|
357786 |
goto fail;
|
|
|
357786 |
}
|
|
|
357786 |
|
|
|
357786 |
- v = qobject_input_visitor_new_keyval(QOBJECT(qdict));
|
|
|
357786 |
+ v = qobject_input_visitor_new_keyval(qobj);
|
|
|
357786 |
+ qobject_unref(qobj);
|
|
|
357786 |
visit_type_BlockdevCreateOptions(v, NULL, &create_options, &local_err);
|
|
|
357786 |
visit_free(v);
|
|
|
357786 |
|
|
|
357786 |
diff --git a/block/vpc.c b/block/vpc.c
|
|
|
357786 |
index 16178e5..a9bb041 100644
|
|
|
357786 |
--- a/block/vpc.c
|
|
|
357786 |
+++ b/block/vpc.c
|
|
|
357786 |
@@ -1081,7 +1081,7 @@ static int coroutine_fn vpc_co_create_opts(const char *filename,
|
|
|
357786 |
QemuOpts *opts, Error **errp)
|
|
|
357786 |
{
|
|
|
357786 |
BlockdevCreateOptions *create_options = NULL;
|
|
|
357786 |
- QDict *qdict = NULL;
|
|
|
357786 |
+ QDict *qdict;
|
|
|
357786 |
QObject *qobj;
|
|
|
357786 |
Visitor *v;
|
|
|
357786 |
BlockDriverState *bs = NULL;
|
|
|
357786 |
@@ -1120,14 +1120,13 @@ static int coroutine_fn vpc_co_create_opts(const char *filename,
|
|
|
357786 |
qdict_put_str(qdict, "file", bs->node_name);
|
|
|
357786 |
|
|
|
357786 |
qobj = qdict_crumple_for_keyval_qiv(qdict, errp);
|
|
|
357786 |
- qobject_unref(qdict);
|
|
|
357786 |
- qdict = qobject_to(QDict, qobj);
|
|
|
357786 |
- if (qdict == NULL) {
|
|
|
357786 |
+ if (!qobj) {
|
|
|
357786 |
ret = -EINVAL;
|
|
|
357786 |
goto fail;
|
|
|
357786 |
}
|
|
|
357786 |
|
|
|
357786 |
- v = qobject_input_visitor_new_keyval(QOBJECT(qdict));
|
|
|
357786 |
+ v = qobject_input_visitor_new_keyval(qobj);
|
|
|
357786 |
+ qobject_unref(qobj);
|
|
|
357786 |
visit_type_BlockdevCreateOptions(v, NULL, &create_options, &local_err);
|
|
|
357786 |
visit_free(v);
|
|
|
357786 |
|
|
|
357786 |
--
|
|
|
357786 |
1.8.3.1
|
|
|
357786 |
|