From patchwork Thu Mar 29 17:26:36 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Luiz Capitulino X-Patchwork-Id: 149451 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 361F0B6EF4 for ; Fri, 30 Mar 2012 04:48:53 +1100 (EST) Received: from localhost ([::1]:42617 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SDJ8h-0001gn-Ar for incoming@patchwork.ozlabs.org; Thu, 29 Mar 2012 13:27:59 -0400 Received: from eggs.gnu.org ([208.118.235.92]:41784) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SDJ7g-0007di-5d for qemu-devel@nongnu.org; Thu, 29 Mar 2012 13:27:01 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1SDJ7a-0003UK-VR for qemu-devel@nongnu.org; Thu, 29 Mar 2012 13:26:55 -0400 Received: from mx1.redhat.com ([209.132.183.28]:50890) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SDJ7a-0003Tw-Nb for qemu-devel@nongnu.org; Thu, 29 Mar 2012 13:26:50 -0400 Received: from int-mx12.intmail.prod.int.phx2.redhat.com (int-mx12.intmail.prod.int.phx2.redhat.com [10.5.11.25]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id q2THQl8t005937 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Thu, 29 Mar 2012 13:26:47 -0400 Received: from localhost (ovpn-113-102.phx2.redhat.com [10.3.113.102]) by int-mx12.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id q2THQkUe031637; Thu, 29 Mar 2012 13:26:47 -0400 From: Luiz Capitulino To: qemu-devel@nongnu.org Date: Thu, 29 Mar 2012 14:26:36 -0300 Message-Id: <1333042003-15490-7-git-send-email-lcapitulino@redhat.com> In-Reply-To: <1333042003-15490-1-git-send-email-lcapitulino@redhat.com> References: <1333042003-15490-1-git-send-email-lcapitulino@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.25 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 209.132.183.28 Cc: mdroth@linux.vnet.ibm.com, aliguori@us.ibm.com, kraxel@redhat.com, stefanha@linux.vnet.ibm.com, armbru@redhat.com Subject: [Qemu-devel] [PATCH 06/13] qemu-option: opt_set(): use error_set() X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org The functions qemu_opt_set() and opts_do_parse() both call opt_set(), but their callers expect QError semantics. Thus, both functions call qerro_report_err() to keep the expected semantics. Signed-off-by: Luiz Capitulino --- qemu-option.c | 38 +++++++++++++++++++++----------------- 1 file changed, 21 insertions(+), 17 deletions(-) diff --git a/qemu-option.c b/qemu-option.c index 4829de5..38461d4 100644 --- a/qemu-option.c +++ b/qemu-option.c @@ -615,12 +615,11 @@ static void qemu_opt_del(QemuOpt *opt) g_free(opt); } -static int opt_set(QemuOpts *opts, const char *name, const char *value, - bool prepend) +static void opt_set(QemuOpts *opts, const char *name, const char *value, + bool prepend, Error **errp) { QemuOpt *opt; const QemuOptDesc *desc = opts->list->desc; - Error *local_err = NULL; int i; for (i = 0; desc[i].name != NULL; i++) { @@ -632,8 +631,8 @@ static int opt_set(QemuOpts *opts, const char *name, const char *value, if (i == 0) { /* empty list -> allow any */; } else { - error_set(&local_err, QERR_INVALID_PARAMETER, name); - goto exit_err; + error_set(errp, QERR_INVALID_PARAMETER, name); + return; } } @@ -651,23 +650,24 @@ static int opt_set(QemuOpts *opts, const char *name, const char *value, if (value) { opt->str = g_strdup(value); } - qemu_opt_parse(opt, &local_err); - if (error_is_set(&local_err)) { + qemu_opt_parse(opt, errp); + if (error_is_set(errp)) { qemu_opt_del(opt); - goto exit_err; } - - return 0; - -exit_err: - qerror_report_err(local_err); - error_free(local_err); - return -1; } int qemu_opt_set(QemuOpts *opts, const char *name, const char *value) { - return opt_set(opts, name, value, false); + Error *local_err = NULL; + + opt_set(opts, name, value, false, &local_err); + if (error_is_set(&local_err)) { + qerror_report_err(local_err); + error_free(local_err); + return -1; + } + + return 0; } int qemu_opt_set_bool(QemuOpts *opts, const char *name, bool val) @@ -853,6 +853,7 @@ static int opts_do_parse(QemuOpts *opts, const char *params, { char option[128], value[1024]; const char *p,*pe,*pc; + Error *local_err = NULL; for (p = params; *p != '\0'; p++) { pe = strchr(p, '='); @@ -884,7 +885,10 @@ static int opts_do_parse(QemuOpts *opts, const char *params, } if (strcmp(option, "id") != 0) { /* store and parse */ - if (opt_set(opts, option, value, prepend) == -1) { + opt_set(opts, option, value, prepend, &local_err); + if (error_is_set(&local_err)) { + qerror_report_err(local_err); + error_free(local_err); return -1; } }