From patchwork Tue Jun 5 17:24:55 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Luiz Capitulino X-Patchwork-Id: 163136 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 40B8EB6F13 for ; Wed, 6 Jun 2012 04:34:13 +1000 (EST) Received: from localhost ([::1]:37979 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SbxWK-0003v9-8K for incoming@patchwork.ozlabs.org; Tue, 05 Jun 2012 13:26:16 -0400 Received: from eggs.gnu.org ([208.118.235.92]:54441) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SbxVu-0003Go-3W for qemu-devel@nongnu.org; Tue, 05 Jun 2012 13:25:55 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1SbxVp-0001Be-Cb for qemu-devel@nongnu.org; Tue, 05 Jun 2012 13:25:49 -0400 Received: from mx1.redhat.com ([209.132.183.28]:64609) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SbxVp-0001B7-3D for qemu-devel@nongnu.org; Tue, 05 Jun 2012 13:25:45 -0400 Received: from int-mx01.intmail.prod.int.phx2.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id q55HPhAq028208 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Tue, 5 Jun 2012 13:25:43 -0400 Received: from localhost (ovpn-116-79.ams2.redhat.com [10.36.116.79]) by int-mx01.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id q55HPfar016390; Tue, 5 Jun 2012 13:25:42 -0400 From: Luiz Capitulino To: qemu-devel@nongnu.org Date: Tue, 5 Jun 2012 14:24:55 -0300 Message-Id: <1338917108-3965-17-git-send-email-lcapitulino@redhat.com> In-Reply-To: <1338917108-3965-1-git-send-email-lcapitulino@redhat.com> References: <1338917108-3965-1-git-send-email-lcapitulino@redhat.com> X-Scanned-By: MIMEDefang 2.67 on 10.5.11.11 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 209.132.183.28 Cc: aliguori@us.ibm.com Subject: [Qemu-devel] [PATCH 16/29] qemu-option: parse_option_size(): 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 Signed-off-by: Luiz Capitulino Reviewed-By: Laszlo Ersek --- qemu-option.c | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/qemu-option.c b/qemu-option.c index b5da116..42bb685 100644 --- a/qemu-option.c +++ b/qemu-option.c @@ -203,7 +203,8 @@ static void parse_option_number(const char *name, const char *value, } } -static int parse_option_size(const char *name, const char *value, uint64_t *ret) +static void parse_option_size(const char *name, const char *value, + uint64_t *ret, Error **errp) { char *postfix; double sizef; @@ -229,16 +230,14 @@ static int parse_option_size(const char *name, const char *value, uint64_t *ret) *ret = (uint64_t) sizef; break; default: - qerror_report(QERR_INVALID_PARAMETER_VALUE, name, "a size"); + error_set(errp, QERR_INVALID_PARAMETER_VALUE, name, "a size"); error_printf_unless_qmp("You may use k, M, G or T suffixes for " "kilobytes, megabytes, gigabytes and terabytes.\n"); - return -1; + return; } } else { - qerror_report(QERR_INVALID_PARAMETER_VALUE, name, "a size"); - return -1; + error_set(errp, QERR_INVALID_PARAMETER_VALUE, name, "a size"); } - return 0; } /* @@ -290,8 +289,7 @@ int set_option_parameter(QEMUOptionParameter *list, const char *name, break; case OPT_SIZE: - if (parse_option_size(name, value, &list->value.n) == -1) - return -1; + parse_option_size(name, value, &list->value.n, &local_err); break; default: @@ -602,7 +600,8 @@ static int qemu_opt_parse(QemuOpt *opt) &local_err); break; case QEMU_OPT_SIZE: - return parse_option_size(opt->name, opt->str, &opt->value.uint); + parse_option_size(opt->name, opt->str, &opt->value.uint, &local_err); + break; default: abort(); }