From: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
To: qemu-devel@nongnu.org
Cc: stefanha@redhat.com, michael.roth@amd.com, armbru@redhat.com,
vsementsov@virtuozzo.com, jsnow@redhat.com, hreitz@redhat.com,
kwolf@redhat.com, pbonzini@redhat.com
Subject: [PATCH v6 2/7] qapi/commands: refactor error handling code
Date: Wed, 26 Jan 2022 17:11:25 +0100 [thread overview]
Message-ID: <20220126161130.3240892-3-vsementsov@virtuozzo.com> (raw)
In-Reply-To: <20220126161130.3240892-1-vsementsov@virtuozzo.com>
Move error_propagate() to if (err) and make "if (err)" block mandatory.
This is to simplify further commit, which will bring trace events
generation for QMP commands.
Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>
---
docs/devel/qapi-code-gen.rst | 2 +-
scripts/qapi/commands.py | 10 +++++++---
2 files changed, 8 insertions(+), 4 deletions(-)
diff --git a/docs/devel/qapi-code-gen.rst b/docs/devel/qapi-code-gen.rst
index a3b5473089..feafed79b5 100644
--- a/docs/devel/qapi-code-gen.rst
+++ b/docs/devel/qapi-code-gen.rst
@@ -1690,8 +1690,8 @@ Example::
}
retval = qmp_my_command(arg.arg1, &err);
- error_propagate(errp, err);
if (err) {
+ error_propagate(errp, err);
goto out;
}
diff --git a/scripts/qapi/commands.py b/scripts/qapi/commands.py
index 21001bbd6b..17e5ed2414 100644
--- a/scripts/qapi/commands.py
+++ b/scripts/qapi/commands.py
@@ -74,14 +74,18 @@ def gen_call(name: str,
ret = mcgen('''
%(lhs)sqmp_%(c_name)s(%(args)s&err);
- error_propagate(errp, err);
''',
c_name=c_name(name), args=argstr, lhs=lhs)
- if ret_type:
- ret += mcgen('''
+
+ ret += mcgen('''
if (err) {
+ error_propagate(errp, err);
goto out;
}
+''')
+
+ if ret_type:
+ ret += mcgen('''
qmp_marshal_output_%(c_name)s(retval, ret, errp);
''',
--
2.31.1
next prev parent reply other threads:[~2022-01-26 16:15 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-01-26 16:11 [PATCH v6 0/7] trace qmp commands Vladimir Sementsov-Ogievskiy
2022-01-26 16:11 ` [PATCH v6 1/7] qapi/gen: Add FOO.trace-events output module Vladimir Sementsov-Ogievskiy
2022-01-26 16:11 ` Vladimir Sementsov-Ogievskiy [this message]
2022-01-26 16:11 ` [PATCH v6 3/7] qapi/commands: Optionally generate trace for QMP commands Vladimir Sementsov-Ogievskiy
2022-01-27 7:24 ` Markus Armbruster
2022-01-27 9:42 ` Vladimir Sementsov-Ogievskiy
2022-01-26 16:11 ` [PATCH v6 4/7] meson: generate trace events for qmp commands Vladimir Sementsov-Ogievskiy
2022-01-26 16:11 ` [PATCH v6 5/7] docs/qapi-code-gen: update to cover trace events code generation Vladimir Sementsov-Ogievskiy
2022-01-27 8:20 ` Stefan Hajnoczi
2022-01-26 16:11 ` [PATCH v6 6/7] meson: document, why we don't generate trace events for tests/ and qga/ Vladimir Sementsov-Ogievskiy
2022-01-27 6:50 ` Markus Armbruster
2022-01-27 9:26 ` Vladimir Sementsov-Ogievskiy
2022-01-27 6:51 ` Markus Armbruster
2022-01-27 8:21 ` Stefan Hajnoczi
2022-01-26 16:11 ` [PATCH v6 7/7] qapi: generate trace events by default Vladimir Sementsov-Ogievskiy
2022-01-27 7:32 ` [PATCH v6 0/7] trace qmp commands Markus Armbruster
2022-01-27 9:41 ` Vladimir Sementsov-Ogievskiy
2022-01-27 11:10 ` Markus Armbruster
2022-01-27 8:21 ` Stefan Hajnoczi
2022-01-27 9:41 ` Vladimir Sementsov-Ogievskiy
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=20220126161130.3240892-3-vsementsov@virtuozzo.com \
--to=vsementsov@virtuozzo.com \
--cc=armbru@redhat.com \
--cc=hreitz@redhat.com \
--cc=jsnow@redhat.com \
--cc=kwolf@redhat.com \
--cc=michael.roth@amd.com \
--cc=pbonzini@redhat.com \
--cc=qemu-devel@nongnu.org \
--cc=stefanha@redhat.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).