From nobody Mon Feb 9 10:29:10 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1594023682; cv=none; d=zohomail.com; s=zohoarc; b=GMLvnh/+IMOtYjWhUWQ8/xzTSclo6Bbj+M3WIVepXZZ7ueiiMJY0Kd1iwO7RO6c5AyGzS/+F7I+hhr3GhDyQHto/hWt9pz0/P888WCXGqMF5Vph+1Cgci7tSnQcUNPqxyX0nZewQzwkrPV+LUNIQurYjMTHYE5HuevgNKYUvL6s= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1594023682; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=l+rLohLgZnTu2IlzcsMOXdC76WUa2zsCZUV0lG6faCw=; b=M6UvSGqSivr15pttE3KZDLCvOyQ9lyRPWLFKzdD4kKBJTDVyTeygNb18WzkU/9zxo1CvHI5lHRYJHwWZdMr2/IF5Y4FQbIzD6Uu2rT8Od9yw4mTIh2b5aQ3gqf7QKAzfJK1luxUdwL89+ON/CFTvMsx+sP6EdWaH7Z1pYS9F8Lo= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1594023682018102.4236104864525; Mon, 6 Jul 2020 01:21:22 -0700 (PDT) Received: from localhost ([::1]:43934 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jsMNM-0007hk-KC for importer@patchew.org; Mon, 06 Jul 2020 04:21:20 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:57198) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jsMCk-0002K1-EL for qemu-devel@nongnu.org; Mon, 06 Jul 2020 04:10:22 -0400 Received: from us-smtp-2.mimecast.com ([207.211.31.81]:34054 helo=us-smtp-delivery-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1jsMCQ-0003F8-QO for qemu-devel@nongnu.org; Mon, 06 Jul 2020 04:10:21 -0400 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-297-BSIlcZ3MPrqKfo44uJyhCg-1; Mon, 06 Jul 2020 04:09:59 -0400 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id D2B45107ACCA; Mon, 6 Jul 2020 08:09:57 +0000 (UTC) Received: from blackfin.pond.sub.org (ovpn-112-143.ams2.redhat.com [10.36.112.143]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 70F1B28550; Mon, 6 Jul 2020 08:09:57 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id 715281135251; Mon, 6 Jul 2020 10:09:51 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1594023000; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=l+rLohLgZnTu2IlzcsMOXdC76WUa2zsCZUV0lG6faCw=; b=b9pcoNK5rBwRpuuqb7UwCKX2DN3JPeVXHw2djMDXkNaYfWWtKeMNB7nST7zt+L5vNOS0kx vjCoJURadA2dYi8atTtlES6UiX+dfVBHfTKYgEywwPL4wnhofDAUPwdUWJxT0XqIQYlyrD +jmTs5yo351gcoWoV18E9Zxbzk9RzO0= X-MC-Unique: BSIlcZ3MPrqKfo44uJyhCg-1 From: Markus Armbruster To: qemu-devel@nongnu.org Subject: [PATCH v3 38/44] qapi: Smooth another visitor error checking pattern Date: Mon, 6 Jul 2020 10:09:44 +0200 Message-Id: <20200706080950.403087-39-armbru@redhat.com> In-Reply-To: <20200706080950.403087-1-armbru@redhat.com> References: <20200706080950.403087-1-armbru@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=armbru@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=207.211.31.81; envelope-from=armbru@redhat.com; helo=us-smtp-delivery-1.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/07/06 01:39:15 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -30 X-Spam_score: -3.1 X-Spam_bar: --- X-Spam_report: (-3.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-1, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H3=-0.01, RCVD_IN_MSPIKE_WL=-0.01, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=_AUTOLEARN X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: peter.maydell@linaro.org, vsementsov@virtuozzo.com, berrange@redhat.com, ehabkost@redhat.com, qemu-block@nongnu.org, groug@kaod.org, pbonzini@redhat.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" Convert visit_type_FOO(v, ..., &ptr, &err); ... if (err) { ... } to visit_type_FOO(v, ..., &ptr, errp); ... if (!ptr) { ... } for functions that set @ptr to non-null / null on success / error. Eliminate error_propagate() that are now unnecessary. Delete @err that are now unused. Signed-off-by: Markus Armbruster Reviewed-by: Eric Blake --- block/nfs.c | 7 ++----- block/parallels.c | 7 ++----- block/qcow.c | 7 ++----- block/qcow2.c | 7 ++----- block/qed.c | 7 ++----- block/rbd.c | 7 ++----- block/sheepdog.c | 6 ++---- block/ssh.c | 7 ++----- block/vdi.c | 7 ++----- block/vhdx.c | 7 ++----- block/vpc.c | 7 ++----- hw/acpi/core.c | 5 ++--- hw/block/xen-block.c | 6 ++---- hw/core/numa.c | 7 +++---- monitor/monitor.c | 21 +++++++-------------- 15 files changed, 36 insertions(+), 79 deletions(-) diff --git a/block/nfs.c b/block/nfs.c index b1718d125a..61a249a9fc 100644 --- a/block/nfs.c +++ b/block/nfs.c @@ -563,18 +563,15 @@ static BlockdevOptionsNfs *nfs_options_qdict_to_qapi(= QDict *options, BlockdevOptionsNfs *opts =3D NULL; Visitor *v; const QDictEntry *e; - Error *local_err =3D NULL; =20 v =3D qobject_input_visitor_new_flat_confused(options, errp); if (!v) { return NULL; } =20 - visit_type_BlockdevOptionsNfs(v, NULL, &opts, &local_err); + visit_type_BlockdevOptionsNfs(v, NULL, &opts, errp); visit_free(v); - - if (local_err) { - error_propagate(errp, local_err); + if (!opts) { return NULL; } =20 diff --git a/block/parallels.c b/block/parallels.c index cb5259ac44..f489c0d4ba 100644 --- a/block/parallels.c +++ b/block/parallels.c @@ -625,7 +625,6 @@ static int coroutine_fn parallels_co_create_opts(BlockD= river *drv, Error **errp) { BlockdevCreateOptions *create_options =3D NULL; - Error *local_err =3D NULL; BlockDriverState *bs =3D NULL; QDict *qdict; Visitor *v; @@ -668,11 +667,9 @@ static int coroutine_fn parallels_co_create_opts(Block= Driver *drv, goto done; } =20 - visit_type_BlockdevCreateOptions(v, NULL, &create_options, &local_err); + visit_type_BlockdevCreateOptions(v, NULL, &create_options, errp); visit_free(v); - - if (local_err) { - error_propagate(errp, local_err); + if (!create_options) { ret =3D -EINVAL; goto done; } diff --git a/block/qcow.c b/block/qcow.c index dca2a1fe7d..c22d1bf6b8 100644 --- a/block/qcow.c +++ b/block/qcow.c @@ -943,7 +943,6 @@ static int coroutine_fn qcow_co_create_opts(BlockDriver= *drv, QDict *qdict; Visitor *v; const char *val; - Error *local_err =3D NULL; int ret; =20 static const QDictRenames opt_renames[] =3D { @@ -995,11 +994,9 @@ static int coroutine_fn qcow_co_create_opts(BlockDrive= r *drv, goto fail; } =20 - visit_type_BlockdevCreateOptions(v, NULL, &create_options, &local_err); + visit_type_BlockdevCreateOptions(v, NULL, &create_options, errp); visit_free(v); - - if (local_err) { - error_propagate(errp, local_err); + if (!create_options) { ret =3D -EINVAL; goto fail; } diff --git a/block/qcow2.c b/block/qcow2.c index a9137a535b..9ed2396c88 100644 --- a/block/qcow2.c +++ b/block/qcow2.c @@ -3683,7 +3683,6 @@ static int coroutine_fn qcow2_co_create_opts(BlockDri= ver *drv, Visitor *v; BlockDriverState *bs =3D NULL; BlockDriverState *data_bs =3D NULL; - Error *local_err =3D NULL; const char *val; int ret; =20 @@ -3779,11 +3778,9 @@ static int coroutine_fn qcow2_co_create_opts(BlockDr= iver *drv, goto finish; } =20 - visit_type_BlockdevCreateOptions(v, NULL, &create_options, &local_err); + visit_type_BlockdevCreateOptions(v, NULL, &create_options, errp); visit_free(v); - - if (local_err) { - error_propagate(errp, local_err); + if (!create_options) { ret =3D -EINVAL; goto finish; } diff --git a/block/qed.c b/block/qed.c index e369fd360a..7fa7f880f6 100644 --- a/block/qed.c +++ b/block/qed.c @@ -729,7 +729,6 @@ static int coroutine_fn bdrv_qed_co_create_opts(BlockDr= iver *drv, QDict *qdict; Visitor *v; BlockDriverState *bs =3D NULL; - Error *local_err =3D NULL; int ret; =20 static const QDictRenames opt_renames[] =3D { @@ -771,11 +770,9 @@ static int coroutine_fn bdrv_qed_co_create_opts(BlockD= river *drv, goto fail; } =20 - visit_type_BlockdevCreateOptions(v, NULL, &create_options, &local_err); + visit_type_BlockdevCreateOptions(v, NULL, &create_options, errp); visit_free(v); - - if (local_err) { - error_propagate(errp, local_err); + if (!create_options) { ret =3D -EINVAL; goto fail; } diff --git a/block/rbd.c b/block/rbd.c index 617553b022..688074c64b 100644 --- a/block/rbd.c +++ b/block/rbd.c @@ -681,7 +681,6 @@ static int qemu_rbd_convert_options(QDict *options, Blo= ckdevOptionsRbd **opts, Error **errp) { Visitor *v; - Error *local_err =3D NULL; =20 /* Convert the remaining options into a QAPI object */ v =3D qobject_input_visitor_new_flat_confused(options, errp); @@ -689,11 +688,9 @@ static int qemu_rbd_convert_options(QDict *options, Bl= ockdevOptionsRbd **opts, return -EINVAL; } =20 - visit_type_BlockdevOptionsRbd(v, NULL, opts, &local_err); + visit_type_BlockdevOptionsRbd(v, NULL, opts, errp); visit_free(v); - - if (local_err) { - error_propagate(errp, local_err); + if (!opts) { return -EINVAL; } =20 diff --git a/block/sheepdog.c b/block/sheepdog.c index a6a91442c9..6c487c8322 100644 --- a/block/sheepdog.c +++ b/block/sheepdog.c @@ -2193,11 +2193,9 @@ static int coroutine_fn sd_co_create_opts(BlockDrive= r *drv, goto fail; } =20 - visit_type_BlockdevCreateOptions(v, NULL, &create_options, &local_err); + visit_type_BlockdevCreateOptions(v, NULL, &create_options, errp); visit_free(v); - - if (local_err) { - error_propagate(errp, local_err); + if (!create_options) { ret =3D -EINVAL; goto fail; } diff --git a/block/ssh.c b/block/ssh.c index f00b89684a..ebe3d8b631 100644 --- a/block/ssh.c +++ b/block/ssh.c @@ -616,7 +616,6 @@ static BlockdevOptionsSsh *ssh_parse_options(QDict *opt= ions, Error **errp) { BlockdevOptionsSsh *result =3D NULL; QemuOpts *opts =3D NULL; - Error *local_err =3D NULL; const QDictEntry *e; Visitor *v; =20 @@ -636,11 +635,9 @@ static BlockdevOptionsSsh *ssh_parse_options(QDict *op= tions, Error **errp) goto fail; } =20 - visit_type_BlockdevOptionsSsh(v, NULL, &result, &local_err); + visit_type_BlockdevOptionsSsh(v, NULL, &result, errp); visit_free(v); - - if (local_err) { - error_propagate(errp, local_err); + if (!result) { goto fail; } =20 diff --git a/block/vdi.c b/block/vdi.c index 2f506a01ba..0a60be773e 100644 --- a/block/vdi.c +++ b/block/vdi.c @@ -907,7 +907,6 @@ static int coroutine_fn vdi_co_create_opts(BlockDriver = *drv, uint64_t block_size =3D DEFAULT_CLUSTER_SIZE; bool is_static =3D false; Visitor *v; - Error *local_err =3D NULL; int ret; =20 /* Parse options and convert legacy syntax. @@ -958,11 +957,9 @@ static int coroutine_fn vdi_co_create_opts(BlockDriver= *drv, ret =3D -EINVAL; goto done; } - visit_type_BlockdevCreateOptions(v, NULL, &create_options, &local_err); + visit_type_BlockdevCreateOptions(v, NULL, &create_options, errp); visit_free(v); - - if (local_err) { - error_propagate(errp, local_err); + if (!create_options) { ret =3D -EINVAL; goto done; } diff --git a/block/vhdx.c b/block/vhdx.c index ac5a9094c4..eed9c3b860 100644 --- a/block/vhdx.c +++ b/block/vhdx.c @@ -2067,7 +2067,6 @@ static int coroutine_fn vhdx_co_create_opts(BlockDriv= er *drv, QDict *qdict; Visitor *v; BlockDriverState *bs =3D NULL; - Error *local_err =3D NULL; int ret; =20 static const QDictRenames opt_renames[] =3D { @@ -2108,11 +2107,9 @@ static int coroutine_fn vhdx_co_create_opts(BlockDri= ver *drv, goto fail; } =20 - visit_type_BlockdevCreateOptions(v, NULL, &create_options, &local_err); + visit_type_BlockdevCreateOptions(v, NULL, &create_options, errp); visit_free(v); - - if (local_err) { - error_propagate(errp, local_err); + if (!create_options) { ret =3D -EINVAL; goto fail; } diff --git a/block/vpc.c b/block/vpc.c index c8cf3957bc..77043c2424 100644 --- a/block/vpc.c +++ b/block/vpc.c @@ -1096,7 +1096,6 @@ static int coroutine_fn vpc_co_create_opts(BlockDrive= r *drv, QDict *qdict; Visitor *v; BlockDriverState *bs =3D NULL; - Error *local_err =3D NULL; int ret; =20 static const QDictRenames opt_renames[] =3D { @@ -1135,11 +1134,9 @@ static int coroutine_fn vpc_co_create_opts(BlockDriv= er *drv, goto fail; } =20 - visit_type_BlockdevCreateOptions(v, NULL, &create_options, &local_err); + visit_type_BlockdevCreateOptions(v, NULL, &create_options, errp); visit_free(v); - - if (local_err) { - error_propagate(errp, local_err); + if (!create_options) { ret =3D -EINVAL; goto fail; } diff --git a/hw/acpi/core.c b/hw/acpi/core.c index 8b240c3e09..f6d9ec4f13 100644 --- a/hw/acpi/core.c +++ b/hw/acpi/core.c @@ -239,7 +239,6 @@ static void acpi_table_install(const char unsigned *blo= b, size_t bloblen, void acpi_table_add(const QemuOpts *opts, Error **errp) { AcpiTableOptions *hdrs =3D NULL; - Error *err =3D NULL; char **pathnames =3D NULL; char **cur; size_t bloblen =3D 0; @@ -249,11 +248,11 @@ void acpi_table_add(const QemuOpts *opts, Error **err= p) Visitor *v; =20 v =3D opts_visitor_new(opts); - visit_type_AcpiTableOptions(v, NULL, &hdrs, &err); + visit_type_AcpiTableOptions(v, NULL, &hdrs, errp); visit_free(v); } =20 - if (err) { + if (!hdrs) { goto out; } if (hdrs->has_file =3D=3D hdrs->has_data) { diff --git a/hw/block/xen-block.c b/hw/block/xen-block.c index 96c6c009c7..a775fba7c0 100644 --- a/hw/block/xen-block.c +++ b/hw/block/xen-block.c @@ -682,11 +682,9 @@ static char *xen_block_blockdev_add(const char *id, QD= ict *qdict, trace_xen_block_blockdev_add(node_name); =20 v =3D qobject_input_visitor_new(QOBJECT(qdict)); - visit_type_BlockdevOptions(v, NULL, &options, &local_err); + visit_type_BlockdevOptions(v, NULL, &options, errp); visit_free(v); - - if (local_err) { - error_propagate(errp, local_err); + if (!options) { goto fail; } =20 diff --git a/hw/core/numa.c b/hw/core/numa.c index d208fd5008..c83f1f01c4 100644 --- a/hw/core/numa.c +++ b/hw/core/numa.c @@ -516,10 +516,10 @@ static int parse_numa(void *opaque, QemuOpts *opts, E= rror **errp) Error *err =3D NULL; Visitor *v =3D opts_visitor_new(opts); =20 - visit_type_NumaOptions(v, NULL, &object, &err); + visit_type_NumaOptions(v, NULL, &object, errp); visit_free(v); - if (err) { - goto end; + if (!object) { + return -1; } =20 /* Fix up legacy suffix-less format */ @@ -530,7 +530,6 @@ static int parse_numa(void *opaque, QemuOpts *opts, Err= or **errp) =20 set_numa_options(ms, object, &err); =20 -end: qapi_free_NumaOptions(object); if (err) { error_propagate(errp, err); diff --git a/monitor/monitor.c b/monitor/monitor.c index 125494410a..47167ac2a3 100644 --- a/monitor/monitor.c +++ b/monitor/monitor.c @@ -656,25 +656,18 @@ int monitor_init_opts(QemuOpts *opts, Error **errp) { Visitor *v; MonitorOptions *options; - Error *local_err =3D NULL; + int ret; =20 v =3D opts_visitor_new(opts); - visit_type_MonitorOptions(v, NULL, &options, &local_err); + visit_type_MonitorOptions(v, NULL, &options, errp); visit_free(v); - - if (local_err) { - goto out; - } - - monitor_init(options, true, &local_err); - qapi_free_MonitorOptions(options); - -out: - if (local_err) { - error_propagate(errp, local_err); + if (!options) { return -1; } - return 0; + + ret =3D monitor_init(options, true, errp); + qapi_free_MonitorOptions(options); + return ret; } =20 QemuOptsList qemu_mon_opts =3D { --=20 2.26.2