qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Markus Armbruster <armbru@redhat.com>
To: qemu-devel@nongnu.org
Cc: peter.maydell@linaro.org, vsementsov@virtuozzo.com,
	berrange@redhat.com, ehabkost@redhat.com, qemu-block@nongnu.org,
	pbonzini@redhat.com
Subject: [PATCH 19/46] block: Avoid unnecessary error_propagate() after error_setg()
Date: Wed, 24 Jun 2020 18:43:17 +0200	[thread overview]
Message-ID: <20200624164344.3778251-20-armbru@redhat.com> (raw)
In-Reply-To: <20200624164344.3778251-1-armbru@redhat.com>

The previous commit enables another round of the transformation from
recent commit "error: Avoid unnecessary error_propagate() after
error_setg()".

Signed-off-by: Markus Armbruster <armbru@redhat.com>
---
 block/quorum.c      | 16 +++++++---------
 block/replication.c | 12 +++++-------
 block/vxhs.c        | 10 ++++------
 3 files changed, 16 insertions(+), 22 deletions(-)

diff --git a/block/quorum.c b/block/quorum.c
index 9ed20e1998..6df9449fc2 100644
--- a/block/quorum.c
+++ b/block/quorum.c
@@ -910,13 +910,12 @@ static int quorum_open(BlockDriverState *bs, QDict *options, int flags,
     /* count how many different children are present */
     s->num_children = qdict_array_entries(options, "children.");
     if (s->num_children < 0) {
-        error_setg(&local_err, "Option children is not a valid array");
+        error_setg(errp, "Option children is not a valid array");
         ret = -EINVAL;
         goto exit;
     }
     if (s->num_children < 1) {
-        error_setg(&local_err,
-                   "Number of provided children must be 1 or more");
+        error_setg(errp, "Number of provided children must be 1 or more");
         ret = -EINVAL;
         goto exit;
     }
@@ -929,7 +928,7 @@ static int quorum_open(BlockDriverState *bs, QDict *options, int flags,
 
     s->threshold = qemu_opt_get_number(opts, QUORUM_OPT_VOTE_THRESHOLD, 0);
     /* and validate it against s->num_children */
-    ret = quorum_valid_threshold(s->threshold, s->num_children, &local_err);
+    ret = quorum_valid_threshold(s->threshold, s->num_children, errp);
     if (ret < 0) {
         goto exit;
     }
@@ -942,7 +941,7 @@ static int quorum_open(BlockDriverState *bs, QDict *options, int flags,
                               -EINVAL, NULL);
     }
     if (ret < 0) {
-        error_setg(&local_err, "Please set read-pattern as fifo or quorum");
+        error_setg(errp, "Please set read-pattern as fifo or quorum");
         goto exit;
     }
     s->read_pattern = ret;
@@ -950,7 +949,7 @@ static int quorum_open(BlockDriverState *bs, QDict *options, int flags,
     if (s->read_pattern == QUORUM_READ_PATTERN_QUORUM) {
         s->is_blkverify = qemu_opt_get_bool(opts, QUORUM_OPT_BLKVERIFY, false);
         if (s->is_blkverify && (s->num_children != 2 || s->threshold != 2)) {
-            error_setg(&local_err, "blkverify=on can only be set if there are "
+            error_setg(errp, "blkverify=on can only be set if there are "
                        "exactly two files and vote-threshold is 2");
             ret = -EINVAL;
             goto exit;
@@ -959,7 +958,7 @@ static int quorum_open(BlockDriverState *bs, QDict *options, int flags,
         s->rewrite_corrupted = qemu_opt_get_bool(opts, QUORUM_OPT_REWRITE,
                                                  false);
         if (s->rewrite_corrupted && s->is_blkverify) {
-            error_setg(&local_err,
+            error_setg(errp,
                        "rewrite-corrupted=on cannot be used with blkverify=on");
             ret = -EINVAL;
             goto exit;
@@ -979,6 +978,7 @@ static int quorum_open(BlockDriverState *bs, QDict *options, int flags,
                                          &child_of_bds, BDRV_CHILD_DATA, false,
                                          &local_err);
         if (local_err) {
+            error_propagate(errp, local_err);
             ret = -EINVAL;
             goto close_exit;
         }
@@ -1004,8 +1004,6 @@ close_exit:
     g_free(opened);
 exit:
     qemu_opts_del(opts);
-    /* propagate error */
-    error_propagate(errp, local_err);
     return ret;
 }
 
diff --git a/block/replication.c b/block/replication.c
index 7f4ab357a4..0c70215784 100644
--- a/block/replication.c
+++ b/block/replication.c
@@ -85,7 +85,6 @@ static int replication_open(BlockDriverState *bs, QDict *options,
 {
     int ret;
     BDRVReplicationState *s = bs->opaque;
-    Error *local_err = NULL;
     QemuOpts *opts = NULL;
     const char *mode;
     const char *top_id;
@@ -105,7 +104,7 @@ static int replication_open(BlockDriverState *bs, QDict *options,
 
     mode = qemu_opt_get(opts, REPLICATION_MODE);
     if (!mode) {
-        error_setg(&local_err, "Missing the option mode");
+        error_setg(errp, "Missing the option mode");
         goto fail;
     }
 
@@ -113,7 +112,8 @@ static int replication_open(BlockDriverState *bs, QDict *options,
         s->mode = REPLICATION_MODE_PRIMARY;
         top_id = qemu_opt_get(opts, REPLICATION_TOP_ID);
         if (top_id) {
-            error_setg(&local_err, "The primary side does not support option top-id");
+            error_setg(errp,
+                       "The primary side does not support option top-id");
             goto fail;
         }
     } else if (!strcmp(mode, "secondary")) {
@@ -121,11 +121,11 @@ static int replication_open(BlockDriverState *bs, QDict *options,
         top_id = qemu_opt_get(opts, REPLICATION_TOP_ID);
         s->top_id = g_strdup(top_id);
         if (!s->top_id) {
-            error_setg(&local_err, "Missing the option top-id");
+            error_setg(errp, "Missing the option top-id");
             goto fail;
         }
     } else {
-        error_setg(&local_err,
+        error_setg(errp,
                    "The option mode's value should be primary or secondary");
         goto fail;
     }
@@ -136,8 +136,6 @@ static int replication_open(BlockDriverState *bs, QDict *options,
 
 fail:
     qemu_opts_del(opts);
-    error_propagate(errp, local_err);
-
     return ret;
 }
 
diff --git a/block/vxhs.c b/block/vxhs.c
index 20513a43f4..ef2848fb60 100644
--- a/block/vxhs.c
+++ b/block/vxhs.c
@@ -300,7 +300,6 @@ static int vxhs_open(BlockDriverState *bs, QDict *options,
     QemuOpts *opts = NULL;
     QemuOpts *tcp_opts = NULL;
     char *of_vsa_addr = NULL;
-    Error *local_err = NULL;
     const char *vdisk_id_opt;
     const char *server_host_opt;
     int ret = 0;
@@ -326,14 +325,14 @@ static int vxhs_open(BlockDriverState *bs, QDict *options,
     /* vdisk-id is the disk UUID */
     vdisk_id_opt = qemu_opt_get(opts, VXHS_OPT_VDISK_ID);
     if (!vdisk_id_opt) {
-        error_setg(&local_err, QERR_MISSING_PARAMETER, VXHS_OPT_VDISK_ID);
+        error_setg(errp, QERR_MISSING_PARAMETER, VXHS_OPT_VDISK_ID);
         ret = -EINVAL;
         goto out;
     }
 
     /* vdisk-id may contain a leading '/' */
     if (strlen(vdisk_id_opt) > UUID_FMT_LEN + 1) {
-        error_setg(&local_err, "vdisk-id cannot be more than %d characters",
+        error_setg(errp, "vdisk-id cannot be more than %d characters",
                    UUID_FMT_LEN);
         ret = -EINVAL;
         goto out;
@@ -352,14 +351,14 @@ static int vxhs_open(BlockDriverState *bs, QDict *options,
 
     server_host_opt = qemu_opt_get(tcp_opts, VXHS_OPT_HOST);
     if (!server_host_opt) {
-        error_setg(&local_err, QERR_MISSING_PARAMETER,
+        error_setg(errp, QERR_MISSING_PARAMETER,
                    VXHS_OPT_SERVER"."VXHS_OPT_HOST);
         ret = -EINVAL;
         goto out;
     }
 
     if (strlen(server_host_opt) > MAXHOSTNAMELEN) {
-        error_setg(&local_err, "server.host cannot be more than %d characters",
+        error_setg(errp, "server.host cannot be more than %d characters",
                    MAXHOSTNAMELEN);
         ret = -EINVAL;
         goto out;
@@ -412,7 +411,6 @@ out:
 
     if (ret < 0) {
         vxhs_unref();
-        error_propagate(errp, local_err);
         g_free(s->vdisk_hostinfo.host);
         g_free(s->vdisk_guid);
         g_free(s->tlscredsid);
-- 
2.26.2



  parent reply	other threads:[~2020-06-24 17:15 UTC|newest]

Thread overview: 157+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-06-24 16:42 [PATCH 00/46] Less clumsy error checking Markus Armbruster
2020-06-24 16:42 ` [PATCH 01/46] error: Improve examples in error.h's big comment Markus Armbruster
2020-06-24 16:59   ` Eric Blake
2020-06-25 14:43   ` Vladimir Sementsov-Ogievskiy
2020-06-25 14:44   ` Greg Kurz
2020-06-25 15:28     ` Markus Armbruster
2020-06-24 16:43 ` [PATCH 02/46] error: Document Error API usage rules Markus Armbruster
2020-06-24 17:51   ` Eric Blake
2020-06-25  7:16   ` Vladimir Sementsov-Ogievskiy
2020-06-25 11:23     ` Markus Armbruster
2020-06-25 11:46       ` Vladimir Sementsov-Ogievskiy
2020-06-25 15:17   ` Greg Kurz
2020-06-25 15:30     ` Markus Armbruster
2020-06-24 16:43 ` [PATCH 03/46] qdev: Smooth error checking of qdev_realize() & friends Markus Armbruster
2020-06-24 18:03   ` Eric Blake
2020-06-25 11:36     ` Markus Armbruster
2020-06-25 12:39   ` Markus Armbruster
2020-06-25 19:00   ` Vladimir Sementsov-Ogievskiy
2020-06-26  6:19     ` Markus Armbruster
2020-07-02 14:56       ` Markus Armbruster
2020-07-03 10:41     ` Markus Armbruster
2020-06-29 10:40   ` Greg Kurz
2020-06-24 16:43 ` [PATCH 04/46] macio: Tidy up error handling in macio_newworld_realize() Markus Armbruster
2020-06-24 21:52   ` Eric Blake
2020-06-24 23:54   ` David Gibson
2020-06-25 19:09   ` Vladimir Sementsov-Ogievskiy
2020-06-24 16:43 ` [PATCH 05/46] virtio-crypto-pci: Tidy up virtio_crypto_pci_realize() Markus Armbruster
2020-06-24 21:52   ` Eric Blake
2020-06-25 19:12   ` Vladimir Sementsov-Ogievskiy
2020-06-28  0:50   ` Gonglei (Arei)
2020-06-24 16:43 ` [PATCH 06/46] error: Avoid error_propagate() when error is not used here Markus Armbruster
2020-06-24 18:17   ` Eric Blake
2020-06-25 12:39     ` Markus Armbruster
2020-06-26 14:36   ` Vladimir Sementsov-Ogievskiy
2020-06-27 11:57     ` Markus Armbruster
2020-06-24 16:43 ` [PATCH 07/46] error: Avoid more " Markus Armbruster
2020-06-24 18:21   ` Eric Blake
2020-06-25 12:50     ` Markus Armbruster
2020-06-25 14:41       ` Eric Blake
2020-06-26 17:21   ` Vladimir Sementsov-Ogievskiy
2020-06-27 12:18     ` Markus Armbruster
2020-07-02 12:54       ` Markus Armbruster
2020-06-24 16:43 ` [PATCH 08/46] error: Avoid unnecessary error_propagate() after error_setg() Markus Armbruster
2020-06-24 18:32   ` Eric Blake
2020-06-25 13:05     ` Markus Armbruster
2020-06-26 18:22   ` Vladimir Sementsov-Ogievskiy
2020-06-27 11:56     ` Markus Armbruster
2020-06-24 16:43 ` [PATCH 09/46] error: Avoid error_propagate() after migrate_add_blocker() Markus Armbruster
2020-06-24 19:34   ` Eric Blake
2020-06-29  8:29   ` Vladimir Sementsov-Ogievskiy
2020-06-24 16:43 ` [PATCH 10/46] qemu-option: Check return value instead of @err where convenient Markus Armbruster
2020-06-24 19:36   ` Eric Blake
2020-06-29  9:11   ` Vladimir Sementsov-Ogievskiy
2020-07-01  8:02     ` Markus Armbruster
2020-07-02  9:28       ` Vladimir Sementsov-Ogievskiy
2020-06-24 16:43 ` [PATCH 11/46] qemu-option: Make uses of find_desc_by_name() more similar Markus Armbruster
2020-06-24 19:37   ` Eric Blake
2020-06-29  9:25   ` Vladimir Sementsov-Ogievskiy
2020-06-29  9:36   ` Vladimir Sementsov-Ogievskiy
2020-06-29  9:47     ` Vladimir Sementsov-Ogievskiy
2020-07-01  8:07       ` Markus Armbruster
2020-06-24 16:43 ` [PATCH 12/46] qemu-option: Factor out helper find_default_by_name() Markus Armbruster
2020-06-24 19:38   ` Eric Blake
2020-06-29  9:46   ` Vladimir Sementsov-Ogievskiy
2020-06-24 16:43 ` [PATCH 13/46] qemu-option: Simplify around find_default_by_name() Markus Armbruster
2020-06-24 19:46   ` Eric Blake
2020-06-25 13:12     ` Markus Armbruster
2020-06-29 10:02       ` Vladimir Sementsov-Ogievskiy
2020-06-24 16:43 ` [PATCH 14/46] qemu-option: Factor out helper opt_create() Markus Armbruster
2020-06-24 19:47   ` Eric Blake
2020-06-29 10:09   ` Vladimir Sementsov-Ogievskiy
2020-07-01  8:13     ` Markus Armbruster
2020-06-24 16:43 ` [PATCH 15/46] qemu-option: Tidy up opt_set() not to free arguments on failure Markus Armbruster
2020-06-24 19:50   ` Eric Blake
2020-06-29 10:37   ` Vladimir Sementsov-Ogievskiy
2020-07-01  9:01     ` Markus Armbruster
2020-06-24 16:43 ` [PATCH 16/46] qemu-option: Make functions taking Error ** return bool, not void Markus Armbruster
2020-06-24 19:55   ` Eric Blake
2020-06-29 11:15   ` Vladimir Sementsov-Ogievskiy
2020-06-24 16:43 ` [PATCH 17/46] qemu-option: Smooth error checking with Coccinelle Markus Armbruster
2020-06-24 20:08   ` Eric Blake
2020-06-25 13:33     ` Markus Armbruster
2020-06-29 13:58   ` Vladimir Sementsov-Ogievskiy
2020-06-24 16:43 ` [PATCH 18/46] qemu-option: Smooth error checking manually Markus Armbruster
2020-06-24 20:10   ` Eric Blake
2020-06-25 13:46     ` Markus Armbruster
2020-06-24 16:43 ` Markus Armbruster [this message]
2020-06-24 20:12   ` [PATCH 19/46] block: Avoid unnecessary error_propagate() after error_setg() Eric Blake
2020-06-24 16:43 ` [PATCH 20/46] block: Avoid error accumulation in bdrv_img_create() Markus Armbruster
2020-06-24 20:14   ` Eric Blake
2020-06-25 13:47     ` Markus Armbruster
2020-06-24 16:43 ` [PATCH 21/46] hmp: Eliminate a variable in hmp_migrate_set_parameter() Markus Armbruster
2020-06-24 20:15   ` Eric Blake
2020-06-24 16:43 ` [PATCH 22/46] qapi: Make visitor functions taking Error ** return bool, not void Markus Armbruster
2020-06-24 20:43   ` Eric Blake
2020-06-25 14:56     ` Markus Armbruster
2020-06-24 16:43 ` [PATCH 23/46] qapi: Smooth error checking with Coccinelle Markus Armbruster
2020-06-24 20:50   ` Eric Blake
2020-06-25 15:03     ` Markus Armbruster
2020-06-24 16:43 ` [PATCH 24/46] qapi: Smooth error checking manually Markus Armbruster
2020-06-24 20:53   ` Eric Blake
2020-06-24 16:43 ` [PATCH 25/46] qapi: Smooth visitor error checking in generated code Markus Armbruster
2020-06-24 20:58   ` Eric Blake
2020-06-24 16:43 ` [PATCH 26/46] qapi: Smooth another visitor error checking pattern Markus Armbruster
2020-06-24 21:02   ` Eric Blake
2020-06-24 16:43 ` [PATCH 27/46] qapi: Purge error_propagate() from QAPI core Markus Armbruster
2020-06-24 21:03   ` Eric Blake
2020-06-24 16:43 ` [PATCH 28/46] block/parallels: Simplify parallels_open() after previous commit Markus Armbruster
2020-06-24 21:03   ` Eric Blake
2020-06-24 16:43 ` [PATCH 29/46] acpi: Avoid unnecessary error_propagate() after error_setg() Markus Armbruster
2020-06-24 21:04   ` Eric Blake
2020-06-24 16:43 ` [PATCH 30/46] s390x/pci: Fix harmless mistake in zpci's property fid's setter Markus Armbruster
2020-06-24 19:31   ` Matthew Rosato
2020-06-25  7:03   ` Cornelia Huck
2020-06-24 16:43 ` [PATCH 31/46] qom: Use error_reportf_err() instead of g_printerr() in examples Markus Armbruster
2020-06-24 21:05   ` Eric Blake
2020-06-24 16:43 ` [PATCH 32/46] qom: Rename qdev_get_type() to object_get_type() Markus Armbruster
2020-06-24 21:06   ` Eric Blake
2020-06-25  6:33   ` Philippe Mathieu-Daudé
2020-06-24 16:43 ` [PATCH 33/46] qom: Crash more nicely on object_property_get_link() failure Markus Armbruster
2020-06-24 21:07   ` Eric Blake
2020-06-25 15:05     ` Markus Armbruster
2020-07-02 12:11       ` Markus Armbruster
2020-06-24 16:43 ` [PATCH 34/46] qom: Don't handle impossible " Markus Armbruster
2020-06-24 21:13   ` Eric Blake
2020-06-25  6:36   ` Philippe Mathieu-Daudé
2020-06-25 15:09     ` Markus Armbruster
2020-06-29 14:38       ` Philippe Mathieu-Daudé
2020-07-01  9:15         ` Markus Armbruster
2020-06-24 16:43 ` [PATCH 35/46] qom: Use return values to check for error where that's simpler Markus Armbruster
2020-06-24 21:24   ` Eric Blake
2020-06-24 16:43 ` [PATCH 36/46] qom: Put name parameter before value / visitor parameter Markus Armbruster
2020-06-24 21:27   ` Eric Blake
2020-06-25 15:14     ` Markus Armbruster
2020-06-24 16:43 ` [PATCH 37/46] qom: Make functions taking Error ** return bool, not void Markus Armbruster
2020-06-24 21:32   ` Eric Blake
2020-06-25 15:14     ` Markus Armbruster
2020-06-24 16:43 ` [PATCH 38/46] qom: Smooth error checking with Coccinelle Markus Armbruster
2020-06-24 21:35   ` Eric Blake
2020-06-24 16:43 ` [PATCH 39/46] qom: Smooth error checking manually Markus Armbruster
2020-06-24 21:38   ` Eric Blake
2020-06-24 16:43 ` [PATCH 40/46] qom: Make functions taking Error ** return bool, not 0/-1 Markus Armbruster
2020-06-24 21:40   ` Eric Blake
2020-06-24 16:43 ` [PATCH 41/46] qdev: Make functions taking Error ** return bool, not void Markus Armbruster
2020-06-24 21:40   ` Eric Blake
2020-06-24 16:43 ` [PATCH 42/46] qdev: Smooth error checking with Coccinelle Markus Armbruster
2020-06-24 21:41   ` Eric Blake
2020-06-24 16:43 ` [PATCH 43/46] qdev: Smooth error checking manually Markus Armbruster
2020-06-24 21:42   ` Eric Blake
2020-06-25 15:15     ` Markus Armbruster
2020-06-24 16:43 ` [PATCH 44/46] qemu-img: Ignore Error objects where the return value suffices Markus Armbruster
2020-06-24 21:49   ` Eric Blake
2020-06-24 16:43 ` [PATCH 45/46] qdev: " Markus Armbruster
2020-06-24 21:50   ` Eric Blake
2020-06-24 16:43 ` [PATCH 46/46] hmp: " Markus Armbruster
2020-06-24 21:51   ` Eric Blake
2020-06-24 16:58 ` [PATCH 00/46] Less clumsy error checking Paolo Bonzini

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20200624164344.3778251-20-armbru@redhat.com \
    --to=armbru@redhat.com \
    --cc=berrange@redhat.com \
    --cc=ehabkost@redhat.com \
    --cc=pbonzini@redhat.com \
    --cc=peter.maydell@linaro.org \
    --cc=qemu-block@nongnu.org \
    --cc=qemu-devel@nongnu.org \
    --cc=vsementsov@virtuozzo.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).