qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Qemu-devel] [PATCH v9 09/37] qapi: Prefer type_int64 over type_int


From: Markus Armbruster
Subject: Re: [Qemu-devel] [PATCH v9 09/37] qapi: Prefer type_int64 over type_int in visitors
Date: Wed, 20 Jan 2016 18:07:04 +0100
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/24.5 (gnu/linux)

Eric Blake <address@hidden> writes:

> The qapi builtin type 'int' is basically shorthand for the type
> 'int64'.  In fact, since no visitor was providing the optional
> type_int64() callback, visit_type_int64() was just always falling
> back to type_int(), cementing the equivalence between the types.
>
> However, some visitors are providing a type_uint64() callback.
> For purposes of code consistency, it is nicer if all visitors
> use the paired type_int64/type_uint64 names rather than the
> mismatched type_int/type_uint64.  So this patch just renames
> the signed int callbacks in place, dropping the type_int()
> callback as redundant, and a later patch will focus on the
> unsigned int callbacks.
>
> Add some FIXMEs to questionable reuse of errp in code touched
> by the rename, while at it (the reuse works as long as the
> callbacks don't modify value when setting an error, but it's not
> a good example to set) - a later patch will then fix those.
>
> No change in functionality here, although further cleanups are
> in the pipeline.
>
> Signed-off-by: Eric Blake <address@hidden>
[...]
> diff --git a/qapi/qapi-visit-core.c b/qapi/qapi-visit-core.c
> index 6d63e40..6295fa8 100644
> --- a/qapi/qapi-visit-core.c
> +++ b/qapi/qapi-visit-core.c
> @@ -97,7 +97,7 @@ void visit_type_enum(Visitor *v, int *obj, const char * 
> const strings[],
>
>  void visit_type_int(Visitor *v, int64_t *obj, const char *name, Error **errp)
>  {
> -    v->type_int(v, obj, name, errp);
> +    v->type_int64(v, obj, name, errp);
>  }
>
>  void visit_type_uint8(Visitor *v, uint8_t *obj, const char *name, Error 
> **errp)
> @@ -108,8 +108,10 @@ void visit_type_uint8(Visitor *v, uint8_t *obj, const 
> char *name, Error **errp)
>          v->type_uint8(v, obj, name, errp);
>      } else {
>          value = *obj;
> -        v->type_int(v, &value, name, errp);
> +        v->type_int64(v, &value, name, errp);
>          if (value < 0 || value > UINT8_MAX) {
> +            /* FIXME questionable reuse of errp if type_int64() changes
> +               value on error */
>              error_setg(errp, QERR_INVALID_PARAMETER_VALUE,
>                         name ? name : "null", "uint8_t");

Changing value on error would be in bad taste, and could be outlawed in
the contract.  But you demonstrate in PATCH 11 that there's no need to
depend on it not being changed.

>              return;
[...]



reply via email to

[Prev in Thread] Current Thread [Next in Thread]