diff options
author | Amos Kong <akong@redhat.com> | 2014-04-28 13:53:49 +0800 |
---|---|---|
committer | Luiz Capitulino <lcapitulino@redhat.com> | 2014-05-08 14:19:58 -0400 |
commit | cb45de6798956975c4b13a6233f7a00d2239b61a (patch) | |
tree | e39974a4bb81e0158c40c46c8a43548a21320f3d /qapi | |
parent | a719a27c824ea5e70f5bf6f3c8d13a8c1d6b1bfe (diff) | |
download | qemu-cb45de6798956975c4b13a6233f7a00d2239b61a.zip qemu-cb45de6798956975c4b13a6233f7a00d2239b61a.tar.gz qemu-cb45de6798956975c4b13a6233f7a00d2239b61a.tar.bz2 |
qapi: treat all negative return of strtosz_suffix() as error
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 <akong@redhat.com>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
Diffstat (limited to 'qapi')
-rw-r--r-- | qapi/opts-visitor.c | 11 |
1 files 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); } |