From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1NnIQN-0000YI-1x for qemu-devel@nongnu.org; Thu, 04 Mar 2010 16:17:39 -0500 Received: from [199.232.76.173] (port=60879 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1NnIQM-0000Xi-Hf for qemu-devel@nongnu.org; Thu, 04 Mar 2010 16:17:38 -0500 Received: from Debian-exim by monty-python.gnu.org with spam-scanned (Exim 4.60) (envelope-from ) id 1NnIQL-0001Op-81 for qemu-devel@nongnu.org; Thu, 04 Mar 2010 16:17:38 -0500 Received: from mx1.redhat.com ([209.132.183.28]:9136) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1NnIQK-0001Of-EV for qemu-devel@nongnu.org; Thu, 04 Mar 2010 16:17:36 -0500 Received: from int-mx03.intmail.prod.int.phx2.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.16]) by mx1.redhat.com (8.13.8/8.13.8) with ESMTP id o24LHYaG029749 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Thu, 4 Mar 2010 16:17:34 -0500 Date: Thu, 4 Mar 2010 18:17:28 -0300 From: Luiz Capitulino Message-ID: <20100304181728.6f775a40@redhat.com> In-Reply-To: References: <1267718231-13303-1-git-send-email-armbru@redhat.com> <1267718231-13303-46-git-send-email-armbru@redhat.com> <20100304175506.33a6456c@redhat.com> Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Subject: [Qemu-devel] Re: [PATCH 45/50] qemu-option: Functions to convert to/from QDict List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Markus Armbruster Cc: qemu-devel@nongnu.org On Thu, 04 Mar 2010 22:12:01 +0100 Markus Armbruster wrote: > Luiz Capitulino writes: > > > On Thu, 4 Mar 2010 16:57:06 +0100 > > Markus Armbruster wrote: > > > >> The functions are somewhat restricted. Good enough for the job at > >> hand. We'll extend them when we need more. > >> > >> Signed-off-by: Markus Armbruster > >> --- > >> qemu-option.c | 79 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++ > >> qemu-option.h | 3 ++ > >> 2 files changed, 82 insertions(+), 0 deletions(-) > >> > >> diff --git a/qemu-option.c b/qemu-option.c > >> index ab488e4..24bb19b 100644 > >> --- a/qemu-option.c > >> +++ b/qemu-option.c > [...] > >> +/* > >> + * Convert from QemuOpts to QDict. > >> + * The QDict values are of type QString. > >> + * TODO We'll want to use types appropriate for opt->desc->type, but > >> + * this is enough for now. > >> + */ > >> +QDict *qemu_opts_to_qdict(QemuOpts *opts, QDict *qdict) > >> +{ > >> + QemuOpt *opt; > >> + QObject *val; > >> + > >> + if (!qdict) { > >> + qdict = qdict_new(); > >> + } > >> + if (opts->id) { > >> + qdict_put(qdict, "id", qstring_from_str(opts->id)); > >> + } > >> + QTAILQ_FOREACH(opt, &opts->head, next) { > >> + val = QOBJECT(qstring_from_str(opt->str)); > >> + qdict_put_obj(qdict, opt->name, val); > >> + } > > > > Why not just do: > > > > qdict_put(qdict, opt->name, qstring_from_str(opt->str)); > > I got a version without the TODO. Looks like this: > > QTAILQ_FOREACH(opt, &opts->head, next) { > switch (opt->desc ? opt->desc->type : QEMU_OPT_STRING) { > case QEMU_OPT_BOOL: > val = QOBJECT(qbool_from_int(opt->value.boolean)); > break; > case QEMU_OPT_NUMBER: > case QEMU_OPT_SIZE: > // FIXME opts only uint64_t, qint only int64_t > val = QOBJECT(qint_from_int(opt->value.uint)); > break; > default: > val = QOBJECT(qstring_from_str(opt->str)); > break; > } > qdict_put_obj(qdict, opt->name, val); > } > > I dumbed it down to keep this series as simple as possible, and missed > the simplification opportunity. Okay to leave it as is? Yes, although it's worth changing in case you resend the series with other modifications (assuming you'll cleanup soon, of course).