From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:43819) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZK8Xw-0006Fh-Ps for qemu-devel@nongnu.org; Tue, 28 Jul 2015 13:20:09 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZK8Xu-0000ey-De for qemu-devel@nongnu.org; Tue, 28 Jul 2015 13:20:08 -0400 Received: from mx1.redhat.com ([209.132.183.28]:51839) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZK8Xu-0000d6-6y for qemu-devel@nongnu.org; Tue, 28 Jul 2015 13:20:06 -0400 From: Markus Armbruster References: <1435782155-31412-1-git-send-email-armbru@redhat.com> <1435782155-31412-42-git-send-email-armbru@redhat.com> <55B16903.5080202@redhat.com> Date: Tue, 28 Jul 2015 13:59:09 +0200 In-Reply-To: <55B16903.5080202@redhat.com> (Eric Blake's message of "Thu, 23 Jul 2015 16:21:55 -0600") Message-ID: <878ua0wl0y.fsf@blackfin.pond.sub.org> MIME-Version: 1.0 Content-Type: text/plain Subject: Re: [Qemu-devel] [PATCH RFC v2 41/47] qom: Don't use 'gen': false for qom-get, qom-set, object-add List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Eric Blake Cc: kwolf@redhat.com, berto@igalia.com, qemu-devel@nongnu.org, mdroth@linux.vnet.ibm.com Eric Blake writes: > On 07/01/2015 02:22 PM, Markus Armbruster wrote: >> With the previous commit, the generated marshalers just work, and save >> us a bit of handwritten code. >> > > Generated code grows, because you are now generating the hook :) > > qmp-commands.h | 6 ++ > qmp-marshal.c | 144 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++ > 2 files changed, 150 insertions(+) > > >> Signed-off-by: Markus Armbruster >> --- >> include/monitor/monitor.h | 3 --- >> qapi-schema.json | 9 +++------ >> qmp-commands.hx | 6 +++--- >> qmp.c | 20 +++++++------------- >> scripts/qapi.py | 1 + >> 5 files changed, 14 insertions(+), 25 deletions(-) >> > >> +++ b/qmp.c >> @@ -229,11 +229,9 @@ ObjectPropertyInfoList *qmp_qom_list(const char *path, Error **errp) >> } >> >> /* FIXME: teach qapi about how to pass through Visitors */ >> -void qmp_qom_set(QDict *qdict, QObject **ret, Error **errp) >> +void qmp_qom_set(const char *path, const char *property, QObject *value, >> + Error **errp) > > The FIXME seems stale now. I'm not 100% sure I understand the intent of the FIXME, but my best guess is "do what this patch does". I'll drop it. >> -void qmp_object_add(QDict *qdict, QObject **ret, Error **errp) >> +void qmp_object_add(const char *type, const char *id, >> + bool has_props, QObject *props, Error **errp) >> { >> - const char *type = qdict_get_str(qdict, "qom-type"); >> - const char *id = qdict_get_str(qdict, "id"); >> - QObject *props = qdict_get(qdict, "props"); >> const QDict *pdict = NULL; >> QmpInputVisitor *qiv; >> > > Continuing: > > if (props) { > pdict = qobject_to_qdict(props); > if (!pdict) { > error_setg(errp, QERR_INVALID_PARAMETER_TYPE, "props", "dict"); > return; > } > } > > I know that we guarantee that all pointers are initialized to NULL in > our marshaler, so this is correct; but wouldn't it be more idiomatic to > write 'if (has_props)' as the condition? We do similar things elsewhere. Moreover: > (And it would make a nice followup project for someone to figure out how > to get rid of have_FOO arguments for strings and objects where NULL is a > nice witness; it is only integers and booleans that require them - but > doing that will touch a lot of the tree, and is a series of its own) Shouldn't be hard, and I really want it done. Will change all the places that test has_PTR to just PTR. More reason to simply test PTR now. > What I pointed out is minor, so you can fix it and add: > Reviewed-by: Eric Blake Thanks!