From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:39107) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1W5yiS-0002nX-S0 for qemu-devel@nongnu.org; Wed, 22 Jan 2014 09:23:45 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1W5yiN-000671-V2 for qemu-devel@nongnu.org; Wed, 22 Jan 2014 09:23:40 -0500 Received: from mx1.redhat.com ([209.132.183.28]:40250) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1W5yiN-00066o-MT for qemu-devel@nongnu.org; Wed, 22 Jan 2014 09:23:35 -0500 Date: Wed, 22 Jan 2014 14:25:54 +0100 From: Kevin Wolf Message-ID: <20140122132554.GG10065@dhcp-200-207.str.redhat.com> References: <1390227608-7225-1-git-send-email-cyliu@suse.com> <1390227608-7225-2-git-send-email-cyliu@suse.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1390227608-7225-2-git-send-email-cyliu@suse.com> Subject: Re: [Qemu-devel] [v19 01/25] add def_value_str to QemuOptDesc List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Chunyan Liu Cc: Dong Xu Wang , qemu-devel@nongnu.org, stefanha@redhat.com Am 20.01.2014 um 15:19 hat Chunyan Liu geschrieben: > Add def_value_str (default value) to QemuOptDesc, to replace function of the > default value in QEMUOptionParameter. And improved related functions. > > Signed-off-by: Dong Xu Wang > Signed-off-by: Chunyan Liu It would be worth mentioning that qemu_opts_print() is unused, so changing the prototype and behaviour is fine. > -int qemu_opts_print(QemuOpts *opts, void *dummy) > +void qemu_opts_print(QemuOpts *opts) > { > QemuOpt *opt; > + QemuOptDesc *desc = opts->list->desc; > > - fprintf(stderr, "%s: %s:", opts->list->name, > - opts->id ? opts->id : ""); > - QTAILQ_FOREACH(opt, &opts->head, next) { > - fprintf(stderr, " %s=\"%s\"", opt->name, opt->str); > + if (desc[0].name == NULL) { I think 'if (opts_accepts_any(opts))' would be more readable. > + QTAILQ_FOREACH(opt, &opts->head, next) { > + printf("%s=\"%s\" ", opt->name, opt->str); > + } > + return; > + } > + for (; desc && desc->name; desc++) { > + const char *value = desc->def_value_str; > + QemuOpt *opt; > + > + opt = qemu_opt_find(opts, desc->name); > + if (opt) { > + value = opt->str; > + } > + > + if (!value) { > + continue; > + } > + > + if (desc->type == QEMU_OPT_STRING) { > + printf("%s='%s' ", desc->name, value); > + } else if (desc->type == QEMU_OPT_SIZE && opt) { > + printf("%s=%" PRIu64 " ", desc->name, opt->value.uint); This is so that a value like '64k' gets expanded to '65536'? Perhaps add a comment? > + } else { > + printf("%s=%s ", desc->name, value); > + } > } > - fprintf(stderr, "\n"); > - return 0; > } Kevin