qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Eric Blake <eblake@redhat.com>
To: qemu-devel@nongnu.org
Cc: armbru@redhat.com, Michael Roth <mdroth@linux.vnet.ibm.com>
Subject: [Qemu-devel] [PATCH v4 02/10] qapi: Fix command with named empty argument type
Date: Sat,  5 Mar 2016 09:16:27 -0700	[thread overview]
Message-ID: <1457194595-16189-3-git-send-email-eblake@redhat.com> (raw)
In-Reply-To: <1457194595-16189-1-git-send-email-eblake@redhat.com>

The generator special-cased

 { 'command':'foo', 'data': {} }

to avoid emitting a visitor variable, but failed to see that

 { 'struct':'NamedEmptyType, 'data': {} }
 { 'command':'foo', 'data':'NamedEmptyType' }

needs the same treatment.  There, the generator happily generates a
visitor to get no arguments, and a visitor to destroy no arguments;
and the compiler isn't happy with that, as demonstrated by the updated
qapi-schema-test.json:

  tests/test-qmp-marshal.c: In function ‘qmp_marshal_user_def_cmd0’:
  tests/test-qmp-marshal.c:264:14: error: variable ‘v’ set but not used [-Werror=unused-but-set-variable]
       Visitor *v;
                ^

No change to generated code except for the testsuite addition.

Signed-off-by: Eric Blake <eblake@redhat.com>

---
v4: move earlier in series, rebase without is_empty, drop R-b
[no v3]
v2: no change
v1: enhance commit message
Previously posted as part of qapi cleanup subset E:
v9: no change
v8: no change
v7: no change
v6: new patch
---
 scripts/qapi-commands.py                | 4 ++--
 tests/test-qmp-commands.c               | 5 +++++
 tests/qapi-schema/qapi-schema-test.json | 2 ++
 tests/qapi-schema/qapi-schema-test.out  | 2 ++
 4 files changed, 11 insertions(+), 2 deletions(-)

diff --git a/scripts/qapi-commands.py b/scripts/qapi-commands.py
index edcbd10..3784f33 100644
--- a/scripts/qapi-commands.py
+++ b/scripts/qapi-commands.py
@@ -66,7 +66,7 @@ def gen_marshal_vars(arg_type, ret_type):
 ''',
                      c_type=ret_type.c_type())

-    if arg_type:
+    if arg_type and arg_type.members:
         ret += mcgen('''
     QmpInputVisitor *qiv = qmp_input_visitor_new_strict(QOBJECT(args));
     QapiDeallocVisitor *qdv;
@@ -98,7 +98,7 @@ def gen_marshal_vars(arg_type, ret_type):
 def gen_marshal_input_visit(arg_type, dealloc=False):
     ret = ''

-    if not arg_type:
+    if not arg_type or not arg_type.members:
         return ret

     if dealloc:
diff --git a/tests/test-qmp-commands.c b/tests/test-qmp-commands.c
index d6171f2..650ba46 100644
--- a/tests/test-qmp-commands.c
+++ b/tests/test-qmp-commands.c
@@ -13,6 +13,11 @@ void qmp_user_def_cmd(Error **errp)
 {
 }

+Empty2 *qmp_user_def_cmd0(Error **errp)
+{
+    return g_new0(Empty2, 1);
+}
+
 void qmp_user_def_cmd1(UserDefOne * ud1, Error **errp)
 {
 }
diff --git a/tests/qapi-schema/qapi-schema-test.json b/tests/qapi-schema/qapi-schema-test.json
index 728659e..e722748 100644
--- a/tests/qapi-schema/qapi-schema-test.json
+++ b/tests/qapi-schema/qapi-schema-test.json
@@ -18,6 +18,8 @@
 { 'struct': 'Empty1', 'data': { } }
 { 'struct': 'Empty2', 'base': 'Empty1', 'data': { } }

+{ 'command': 'user_def_cmd0', 'data': 'Empty2', 'returns': 'Empty2' }
+
 # for testing override of default naming heuristic
 { 'enum': 'QEnumTwo',
   'prefix': 'QENUM_TWO',
diff --git a/tests/qapi-schema/qapi-schema-test.out b/tests/qapi-schema/qapi-schema-test.out
index f5e2a73..f531961 100644
--- a/tests/qapi-schema/qapi-schema-test.out
+++ b/tests/qapi-schema/qapi-schema-test.out
@@ -203,6 +203,8 @@ command guest-sync :obj-guest-sync-arg -> any
    gen=True success_response=True
 command user_def_cmd None -> None
    gen=True success_response=True
+command user_def_cmd0 Empty2 -> Empty2
+   gen=True success_response=True
 command user_def_cmd1 :obj-user_def_cmd1-arg -> None
    gen=True success_response=True
 command user_def_cmd2 :obj-user_def_cmd2-arg -> UserDefTwo
-- 
2.5.0

  parent reply	other threads:[~2016-03-05 16:16 UTC|newest]

Thread overview: 36+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-03-05 16:16 [Qemu-devel] [PATCH v4 00/10] easier unboxed visits/qapi implicit types Eric Blake
2016-03-05 16:16 ` [Qemu-devel] [PATCH v4 01/10] qapi: Assert in places where variants are not handled Eric Blake
2016-03-08 10:12   ` Markus Armbruster
2016-03-08 15:49     ` Eric Blake
2016-03-08 17:46       ` Markus Armbruster
2016-03-05 16:16 ` Eric Blake [this message]
2016-03-05 16:16 ` [Qemu-devel] [PATCH v4 03/10] qapi: Make c_type() more OO-like Eric Blake
2016-03-08 10:54   ` Markus Armbruster
2016-03-08 15:50     ` Eric Blake
2016-03-05 16:16 ` [Qemu-devel] [PATCH v4 04/10] qapi: Emit implicit structs in generated C Eric Blake
2016-03-08 14:24   ` Markus Armbruster
2016-03-08 16:03     ` Eric Blake
2016-03-08 19:09       ` Markus Armbruster
2016-03-09  5:42         ` Eric Blake
2016-03-09  7:23           ` Markus Armbruster
2016-03-05 16:16 ` [Qemu-devel] [PATCH v4 05/10] qapi: Utilize implicit struct visits Eric Blake
2016-03-08 15:10   ` Markus Armbruster
2016-03-08 16:11     ` Eric Blake
2016-03-08 18:09       ` Markus Armbruster
2016-03-08 18:28         ` Eric Blake
2016-03-08 19:21           ` Markus Armbruster
2016-03-09 23:28       ` Eric Blake
2016-03-05 16:16 ` [Qemu-devel] [PATCH v4 06/10] qapi-commands: Inline single-use helpers of gen_marshal() Eric Blake
2016-03-05 16:16 ` [Qemu-devel] [PATCH v4 07/10] qapi: Don't special-case simple union wrappers Eric Blake
2016-03-08 15:59   ` Markus Armbruster
2016-03-08 16:16     ` Eric Blake
2016-03-08 18:10       ` Markus Armbruster
2016-03-05 16:16 ` [Qemu-devel] [PATCH v4 08/10] qapi: Allow anonymous base for flat union Eric Blake
2016-03-08 16:23   ` Markus Armbruster
2016-03-08 16:29     ` Eric Blake
2016-03-08 18:14       ` Markus Armbruster
2016-03-05 16:16 ` [Qemu-devel] [PATCH v4 09/10] qapi: Use anonymous bases in QMP flat unions Eric Blake
2016-03-05 16:16 ` [Qemu-devel] [PATCH v4 10/10] qapi: Populate info['name'] for each entity Eric Blake
2016-03-08 16:46   ` Markus Armbruster
2016-03-08 16:59     ` Eric Blake
2016-03-08 19:14       ` 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=1457194595-16189-3-git-send-email-eblake@redhat.com \
    --to=eblake@redhat.com \
    --cc=armbru@redhat.com \
    --cc=mdroth@linux.vnet.ibm.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).