qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Markus Armbruster <armbru@redhat.com>
To: qemu-devel@nongnu.org
Cc: mdroth@linux.vnet.ibm.com, lcapitulino@redhat.com,
	pbonzini@redhat.com, akong@redhat.com, vilanova@ac.upc.edu
Subject: [Qemu-devel] [PATCH v2 09/12] hmp: Call visit_end_struct() after visit_start_struct() succeeds
Date: Wed,  7 May 2014 09:53:51 +0200	[thread overview]
Message-ID: <1399449234-28501-10-git-send-email-armbru@redhat.com> (raw)
In-Reply-To: <1399449234-28501-1-git-send-email-armbru@redhat.com>

When visit_start_struct() succeeds, visit_end_struct() must be called.
hmp_object_add() doesn't when a member visit fails.  As far as I can
tell, the opts visitor copes okay with the misuse.  Fix it anyway.

Signed-off-by: Markus Armbruster <armbru@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
---
 hmp.c | 16 ++++++++--------
 1 file changed, 8 insertions(+), 8 deletions(-)

diff --git a/hmp.c b/hmp.c
index ad31ceb..a7cd59e 100644
--- a/hmp.c
+++ b/hmp.c
@@ -1384,6 +1384,7 @@ void hmp_netdev_del(Monitor *mon, const QDict *qdict)
 void hmp_object_add(Monitor *mon, const QDict *qdict)
 {
     Error *err = NULL;
+    Error *err_end = NULL;
     QemuOpts *opts;
     char *type = NULL;
     char *id = NULL;
@@ -1407,24 +1408,23 @@ void hmp_object_add(Monitor *mon, const QDict *qdict)
     qdict_del(pdict, "qom-type");
     visit_type_str(opts_get_visitor(ov), &type, "qom-type", &err);
     if (err) {
-        goto out_clean;
+        goto out_end;
     }
 
     qdict_del(pdict, "id");
     visit_type_str(opts_get_visitor(ov), &id, "id", &err);
     if (err) {
-        goto out_clean;
+        goto out_end;
     }
 
     object_add(type, id, pdict, opts_get_visitor(ov), &err);
-    if (err) {
-        goto out_clean;
-    }
-    visit_end_struct(opts_get_visitor(ov), &err);
-    if (err) {
+
+out_end:
+    visit_end_struct(opts_get_visitor(ov), &err_end);
+    if (!err && err_end) {
         qmp_object_del(id, NULL);
     }
-
+    error_propagate(&err, err_end);
 out_clean:
     opts_visitor_cleanup(ov);
 
-- 
1.8.1.4

  parent reply	other threads:[~2014-05-07  7:54 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-05-07  7:53 [Qemu-devel] [PATCH v2 00/12] qapi: Purge error_is_set() Markus Armbruster
2014-05-07  7:53 ` [Qemu-devel] [PATCH v2 01/12] qapi: Update qapi-code-gen.txt example to match current code Markus Armbruster
2014-05-07  7:53 ` [Qemu-devel] [PATCH v2 02/12] qapi: Normalize marshalling's visitor initialization and cleanup Markus Armbruster
2014-05-07  7:53 ` [Qemu-devel] [PATCH v2 03/12] qapi: Remove unused Visitor callbacks start_handle(), end_handle() Markus Armbruster
2014-05-07  7:53 ` [Qemu-devel] [PATCH v2 04/12] qapi: Replace start_optional()/end_optional() by optional() Markus Armbruster
2014-05-07  7:53 ` [Qemu-devel] [PATCH v2 05/12] qapi-visit.py: Clean up confusing push_indent() / pop_indent() use Markus Armbruster
2014-05-07  7:53 ` [Qemu-devel] [PATCH v2 06/12] qapi: Clean up shadowing of parameters and locals in inner scopes Markus Armbruster
2014-05-07  7:53 ` [Qemu-devel] [PATCH v2 07/12] qapi-visit.py: Clean up a sloppy use of field prefix Markus Armbruster
2014-05-07  7:53 ` [Qemu-devel] [PATCH v2 08/12] qapi: Un-inline visit of implicit struct Markus Armbruster
2014-05-07  7:53 ` Markus Armbruster [this message]
2014-05-07  7:53 ` [Qemu-devel] [PATCH v2 10/12] hw: Don't call visit_end_struct() after visit_start_struct() fails Markus Armbruster
2014-05-07  7:53 ` [Qemu-devel] [PATCH v2 11/12] tests: " Markus Armbruster
2014-05-07  7:53 ` [Qemu-devel] [PATCH v2 12/12] qapi: Replace uncommon use of the error API by the common one Markus Armbruster
2014-05-15 18:11 ` [Qemu-devel] [PATCH v2 00/12] qapi: Purge error_is_set() Luiz Capitulino

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=1399449234-28501-10-git-send-email-armbru@redhat.com \
    --to=armbru@redhat.com \
    --cc=akong@redhat.com \
    --cc=lcapitulino@redhat.com \
    --cc=mdroth@linux.vnet.ibm.com \
    --cc=pbonzini@redhat.com \
    --cc=qemu-devel@nongnu.org \
    --cc=vilanova@ac.upc.edu \
    /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).