From patchwork Mon May 21 17:41:50 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Luiz Capitulino X-Patchwork-Id: 160406 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 48B38B6F62 for ; Tue, 22 May 2012 04:11:10 +1000 (EST) Received: from localhost ([::1]:51789 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SWX4V-0007ha-DJ for incoming@patchwork.ozlabs.org; Mon, 21 May 2012 14:11:07 -0400 Received: from eggs.gnu.org ([208.118.235.92]:57987) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SWX4E-0007Tp-U9 for qemu-devel@nongnu.org; Mon, 21 May 2012 14:10:53 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1SWX4C-0000ze-CH for qemu-devel@nongnu.org; Mon, 21 May 2012 14:10:50 -0400 Received: from mx1.redhat.com ([209.132.183.28]:25463) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SWX4C-0000zB-3e for qemu-devel@nongnu.org; Mon, 21 May 2012 14:10:48 -0400 Received: from int-mx11.intmail.prod.int.phx2.redhat.com (int-mx11.intmail.prod.int.phx2.redhat.com [10.5.11.24]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id q4LI8gc7017176 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Mon, 21 May 2012 14:10:42 -0400 Received: from localhost (ovpn-116-87.ams2.redhat.com [10.36.116.87]) by int-mx11.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id q4LHg8VY015588; Mon, 21 May 2012 13:42:09 -0400 From: Luiz Capitulino To: qemu-devel@nongnu.org Date: Mon, 21 May 2012 14:41:50 -0300 Message-Id: <1337622119-8416-8-git-send-email-lcapitulino@redhat.com> In-Reply-To: <1337622119-8416-1-git-send-email-lcapitulino@redhat.com> References: <1337622119-8416-1-git-send-email-lcapitulino@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.24 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 209.132.183.28 Cc: pbonzini@redhat.com, aliguori@us.ibm.com, lersek@redhat.com, mdroth@linux.vnet.ibm.com, armbru@redhat.com Subject: [Qemu-devel] [PATCH 07/16] 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 | 31 ++++++++++++++++++++----------- 1 file changed, 20 insertions(+), 11 deletions(-) diff --git a/qemu-option.c b/qemu-option.c index eee3b45..7af2b50 100644 --- a/qemu-option.c +++ b/qemu-option.c @@ -612,8 +612,8 @@ 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; @@ -629,8 +629,8 @@ static int opt_set(QemuOpts *opts, const char *name, const char *value, if (i == 0) { /* empty list -> allow any */; } else { - qerror_report(QERR_INVALID_PARAMETER, name); - return -1; + error_set(errp, QERR_INVALID_PARAMETER, name); + return; } } @@ -650,18 +650,23 @@ static int opt_set(QemuOpts *opts, const char *name, const char *value, } qemu_opt_parse(opt, &local_err); if (error_is_set(&local_err)) { - qerror_report_err(local_err); - error_free(local_err); + error_propagate(errp, local_err); qemu_opt_del(opt); - return -1; } - - return 0; } 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) @@ -847,6 +852,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, '='); @@ -878,7 +884,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; } }