From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([208.118.235.92]:46863) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SpmiS-0002k8-Oa for qemu-devel@nongnu.org; Fri, 13 Jul 2012 16:43:57 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1SpmiR-0001r9-Mx for qemu-devel@nongnu.org; Fri, 13 Jul 2012 16:43:56 -0400 Received: from mx1.redhat.com ([209.132.183.28]:11531) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SpmiR-0001qw-Er for qemu-devel@nongnu.org; Fri, 13 Jul 2012 16:43:55 -0400 From: Luiz Capitulino Date: Fri, 13 Jul 2012 17:44:14 -0300 Message-Id: <1342212261-19903-2-git-send-email-lcapitulino@redhat.com> In-Reply-To: <1342212261-19903-1-git-send-email-lcapitulino@redhat.com> References: <1342212261-19903-1-git-send-email-lcapitulino@redhat.com> Subject: [Qemu-devel] [PATCH 1/8] qemu-option: qemu_opt_set_bool(): fix code duplication List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: jan.kiszka@siemens.com, aliguori@us.ibm.com, afaerber@suse.de, armbru@redhat.com Call qemu_opt_set() instead of duplicating opt_set(). Signed-off-by: Luiz Capitulino --- qemu-option.c | 28 +--------------------------- 1 file changed, 1 insertion(+), 27 deletions(-) diff --git a/qemu-option.c b/qemu-option.c index bb3886c..2cb2835 100644 --- a/qemu-option.c +++ b/qemu-option.c @@ -677,33 +677,7 @@ void qemu_opt_set_err(QemuOpts *opts, const char *name, const char *value, int qemu_opt_set_bool(QemuOpts *opts, const char *name, bool val) { - QemuOpt *opt; - const QemuOptDesc *desc = opts->list->desc; - int i; - - for (i = 0; desc[i].name != NULL; i++) { - if (strcmp(desc[i].name, name) == 0) { - break; - } - } - if (desc[i].name == NULL) { - if (i == 0) { - /* empty list -> allow any */; - } else { - qerror_report(QERR_INVALID_PARAMETER, name); - return -1; - } - } - - opt = g_malloc0(sizeof(*opt)); - opt->name = g_strdup(name); - opt->opts = opts; - QTAILQ_INSERT_TAIL(&opts->head, opt, next); - if (desc[i].name != NULL) { - opt->desc = desc+i; - } - opt->value.boolean = !!val; - return 0; + return qemu_opt_set(opts, name, val ? "on" : "off"); } int qemu_opt_foreach(QemuOpts *opts, qemu_opt_loopfunc func, void *opaque, -- 1.7.11.1.116.g8228a23