From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([208.118.235.92]:48676) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SV1mt-0000tP-UQ for qemu-devel@nongnu.org; Thu, 17 May 2012 10:34:45 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1SV1mr-00021Y-Ih for qemu-devel@nongnu.org; Thu, 17 May 2012 10:34:43 -0400 Received: from mx1.redhat.com ([209.132.183.28]:49865) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SV1mr-00020w-At for qemu-devel@nongnu.org; Thu, 17 May 2012 10:34:41 -0400 From: Luiz Capitulino Date: Thu, 17 May 2012 11:33:32 -0300 Message-Id: <1337265221-7136-8-git-send-email-lcapitulino@redhat.com> In-Reply-To: <1337265221-7136-1-git-send-email-lcapitulino@redhat.com> References: <1337265221-7136-1-git-send-email-lcapitulino@redhat.com> Subject: [Qemu-devel] [PATCH 07/16] qemu-option: opt_set(): use error_set() List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: pbonzini@redhat.com, aliguori@us.ibm.com, lersek@redhat.com, mdroth@linux.vnet.ibm.com, armbru@redhat.com 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 3a9a5f8..c54bb21 100644 --- a/qemu-option.c +++ b/qemu-option.c @@ -615,8 +615,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; @@ -632,8 +632,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; } } @@ -653,18 +653,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) @@ -850,6 +855,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, '='); @@ -881,7 +887,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; } } -- 1.7.9.2.384.g4a92a