[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-devel] [PATCH v2] qapi: treat all negative return of strtosz_s
From: |
Luiz Capitulino |
Subject: |
Re: [Qemu-devel] [PATCH v2] qapi: treat all negative return of strtosz_suffix() as error |
Date: |
Mon, 5 May 2014 16:10:17 -0400 |
On Mon, 28 Apr 2014 13:53:49 +0800
Amos Kong <address@hidden> wrote:
> strtosz_suffix() might return negative error, this patch fixes
> the error handling.
>
> This patch also changes to handle error in the if statement
> rather than handle success specially, this will make this use
> of strtosz_suffix consistent with all other uses.
>
> Signed-off-by: Amos Kong <address@hidden>
> Reviewed-by: Michael S. Tsirkin <address@hidden>
Applied to the qmp branch, thanks.
> ---
> qapi/opts-visitor.c | 11 ++++++-----
> 1 file changed, 6 insertions(+), 5 deletions(-)
>
> diff --git a/qapi/opts-visitor.c b/qapi/opts-visitor.c
> index 5d830a2..87c1c78 100644
> --- a/qapi/opts-visitor.c
> +++ b/qapi/opts-visitor.c
> @@ -472,13 +472,14 @@ opts_type_size(Visitor *v, uint64_t *obj, const char
> *name, Error **errp)
>
> val = strtosz_suffix(opt->str ? opt->str : "", &endptr,
> STRTOSZ_DEFSUFFIX_B);
> - if (val != -1 && *endptr == '\0') {
> - *obj = val;
> - processed(ov, name);
> + if (val < 0 || *endptr) {
> + error_set(errp, QERR_INVALID_PARAMETER_VALUE, opt->name,
> + "a size value representible as a non-negative int64");
> return;
> }
> - error_set(errp, QERR_INVALID_PARAMETER_VALUE, opt->name,
> - "a size value representible as a non-negative int64");
> +
> + *obj = val;
> + processed(ov, name);
> }
>
>
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- Re: [Qemu-devel] [PATCH v2] qapi: treat all negative return of strtosz_suffix() as error,
Luiz Capitulino <=