qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
To: qemu-devel@nongnu.org
Cc: vsementsov@virtuozzo.com,
	"Daniel P. Berrangé" <berrange@redhat.com>,
	"Eduardo Habkost" <ehabkost@redhat.com>,
	armbru@redhat.com, "Paolo Bonzini" <pbonzini@redhat.com>,
	"Marc-André Lureau" <marcandre.lureau@redhat.com>
Subject: [PATCH v7 09/21] hw/core/qdev: cleanup Error ** variables
Date: Thu,  5 Dec 2019 18:20:07 +0300	[thread overview]
Message-ID: <20191205152019.8454-10-vsementsov@virtuozzo.com> (raw)
In-Reply-To: <20191205152019.8454-1-vsementsov@virtuozzo.com>

Rename Error ** parameter in check_only_migratable to common errp.

In device_set_realized:

 - Move "if (local_err != NULL)" closer to error setters.

 - Drop 'Error **local_errp': it doesn't save any LoCs, but it's very
   unusual.

Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Reviewed-by: Markus Armbruster <armbru@redhat.com>
---
 hw/core/qdev.c | 28 +++++++++++++---------------
 1 file changed, 13 insertions(+), 15 deletions(-)

diff --git a/hw/core/qdev.c b/hw/core/qdev.c
index cf1ba28fe3..82d3ee590a 100644
--- a/hw/core/qdev.c
+++ b/hw/core/qdev.c
@@ -820,12 +820,12 @@ static bool device_get_realized(Object *obj, Error **errp)
     return dev->realized;
 }
 
-static bool check_only_migratable(Object *obj, Error **err)
+static bool check_only_migratable(Object *obj, Error **errp)
 {
     DeviceClass *dc = DEVICE_GET_CLASS(obj);
 
     if (!vmstate_check_only_migratable(dc->vmsd)) {
-        error_setg(err, "Device %s is not migratable, but "
+        error_setg(errp, "Device %s is not migratable, but "
                    "--only-migratable was specified",
                    object_get_typename(obj));
         return false;
@@ -874,10 +874,9 @@ static void device_set_realized(Object *obj, bool value, Error **errp)
 
         if (dc->realize) {
             dc->realize(dev, &local_err);
-        }
-
-        if (local_err != NULL) {
-            goto fail;
+            if (local_err != NULL) {
+                goto fail;
+            }
         }
 
         DEVICE_LISTENER_CALL(realize, Forward, dev);
@@ -918,27 +917,26 @@ static void device_set_realized(Object *obj, bool value, Error **errp)
        }
 
     } else if (!value && dev->realized) {
-        Error **local_errp = NULL;
+        /* We want local_err to track only the first error */
         QLIST_FOREACH(bus, &dev->child_bus, sibling) {
-            local_errp = local_err ? NULL : &local_err;
             object_property_set_bool(OBJECT(bus), false, "realized",
-                                     local_errp);
+                                     local_err ? NULL : &local_err);
         }
         if (qdev_get_vmsd(dev)) {
             vmstate_unregister(dev, qdev_get_vmsd(dev), dev);
         }
         if (dc->unrealize) {
-            local_errp = local_err ? NULL : &local_err;
-            dc->unrealize(dev, local_errp);
+            dc->unrealize(dev, local_err ? NULL : &local_err);
         }
         dev->pending_deleted_event = true;
         DEVICE_LISTENER_CALL(unrealize, Reverse, dev);
-    }
 
-    if (local_err != NULL) {
-        goto fail;
+        if (local_err != NULL) {
+            goto fail;
+        }
     }
 
+    assert(local_err == NULL);
     dev->realized = value;
     return;
 
@@ -976,7 +974,7 @@ static bool device_get_hotpluggable(Object *obj, Error **errp)
                                 qbus_is_hotpluggable(dev->parent_bus));
 }
 
-static bool device_get_hotplugged(Object *obj, Error **err)
+static bool device_get_hotplugged(Object *obj, Error **errp)
 {
     DeviceState *dev = DEVICE(obj);
 
-- 
2.21.0



  parent reply	other threads:[~2019-12-05 15:47 UTC|newest]

Thread overview: 41+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-12-05 15:19 [PATCH v7 00/21] error: prepare for auto propagated local_err Vladimir Sementsov-Ogievskiy
2019-12-05 15:19 ` [PATCH v7 01/21] hw/core/loader-fit: fix freeing errp in fit_load_fdt Vladimir Sementsov-Ogievskiy
2019-12-05 15:20 ` [PATCH v7 02/21] net/net: Clean up variable shadowing in net_client_init() Vladimir Sementsov-Ogievskiy
2019-12-05 15:20 ` [PATCH v7 03/21] error: rename errp to errp_in where it is IN-argument Vladimir Sementsov-Ogievskiy
2019-12-05 17:03   ` Greg Kurz
2019-12-05 15:20 ` [PATCH v7 04/21] hmp: drop Error pointer indirection in hmp_handle_error Vladimir Sementsov-Ogievskiy
2019-12-05 15:20 ` [PATCH v7 05/21] vnc: drop Error pointer indirection in vnc_client_io_error Vladimir Sementsov-Ogievskiy
2019-12-05 15:20 ` [PATCH v7 06/21] qdev-monitor: well form error hint helpers Vladimir Sementsov-Ogievskiy
2019-12-05 16:58   ` Eric Blake
2019-12-05 17:02     ` Vladimir Sementsov-Ogievskiy
2019-12-05 15:20 ` [PATCH v7 07/21] ppc: well form kvmppc_hint_smt_possible error hint helper Vladimir Sementsov-Ogievskiy
2019-12-05 17:15   ` Greg Kurz
2019-12-06  0:02   ` David Gibson
2019-12-06 10:28     ` Vladimir Sementsov-Ogievskiy
2019-12-05 15:20 ` [PATCH v7 08/21] 9pfs: well form error hint helpers Vladimir Sementsov-Ogievskiy
2019-12-05 17:08   ` Greg Kurz
2019-12-05 17:13     ` Greg Kurz
2019-12-05 15:20 ` Vladimir Sementsov-Ogievskiy [this message]
2019-12-05 15:20 ` [PATCH v7 10/21] block/snapshot: rename Error ** parameter to more common errp Vladimir Sementsov-Ogievskiy
2019-12-05 15:20 ` [PATCH v7 11/21] hw/i386/amd_iommu: " Vladimir Sementsov-Ogievskiy
2019-12-05 15:20 ` [PATCH v7 12/21] qga: " Vladimir Sementsov-Ogievskiy
2019-12-05 15:20 ` [PATCH v7 13/21] monitor/qmp-cmds: " Vladimir Sementsov-Ogievskiy
2019-12-05 15:20 ` [PATCH v7 14/21] hw/s390x: " Vladimir Sementsov-Ogievskiy
2019-12-05 15:20 ` [PATCH v7 15/21] hw/sd: drop extra whitespace in sdhci_sysbus_realize() header Vladimir Sementsov-Ogievskiy
2019-12-05 15:20 ` [PATCH v7 16/21] hw/tpm: rename Error ** parameter to more common errp Vladimir Sementsov-Ogievskiy
2019-12-05 15:20 ` [PATCH v7 17/21] hw/usb: " Vladimir Sementsov-Ogievskiy
2019-12-05 15:20 ` [PATCH v7 18/21] include/qom/object.h: " Vladimir Sementsov-Ogievskiy
2019-12-05 15:20 ` [PATCH v7 19/21] backends/cryptodev: drop local_err from cryptodev_backend_complete() Vladimir Sementsov-Ogievskiy
2019-12-05 15:20 ` [PATCH v7 20/21] hw/vfio/ap: drop local_err from vfio_ap_realize Vladimir Sementsov-Ogievskiy
2019-12-05 16:09   ` Cornelia Huck
2019-12-05 15:20 ` [PATCH v7 21/21] nbd: assert that Error** is not NULL in nbd_iter_channel_error Vladimir Sementsov-Ogievskiy
2019-12-05 17:14   ` Eric Blake
2019-12-05 17:39     ` Vladimir Sementsov-Ogievskiy
2019-12-05 17:49       ` Eric Blake
2019-12-05 18:09         ` Vladimir Sementsov-Ogievskiy
2019-12-05 19:56           ` Eric Blake
2019-12-06  8:54       ` Markus Armbruster
2019-12-06 10:26         ` Vladimir Sementsov-Ogievskiy
2019-12-05 15:26 ` [PATCH v7 00/21] error: prepare for auto propagated local_err Cornelia Huck
2019-12-05 16:03   ` Vladimir Sementsov-Ogievskiy
2019-12-06  8:44     ` Markus Armbruster

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=20191205152019.8454-10-vsementsov@virtuozzo.com \
    --to=vsementsov@virtuozzo.com \
    --cc=armbru@redhat.com \
    --cc=berrange@redhat.com \
    --cc=ehabkost@redhat.com \
    --cc=marcandre.lureau@redhat.com \
    --cc=pbonzini@redhat.com \
    --cc=qemu-devel@nongnu.org \
    /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).