[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-devel] [PATCH v6 16/16] qapi: Share gen_visit_fields()
From: |
Markus Armbruster |
Subject: |
Re: [Qemu-devel] [PATCH v6 16/16] qapi: Share gen_visit_fields() |
Date: |
Tue, 29 Sep 2015 16:38:33 +0200 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/24.5 (gnu/linux) |
Eric Blake <address@hidden> writes:
> Consolidate the code between visit, command marshalling, and
> event generation that iterates over the members of a struct.
> It reduces code duplication in the generator, so that a future
> patch can reduce the size of generated code while touching only
> one instead of three locations.
>
> There are no changes to generated marshal code.
>
> The visitor code is slightly more verbose, but semantically
Suggest "becomes slightly more verbose".
> equivalent, and actually easier to read as it follows a more
> common idiom:
>
> | visit_optional(v, &(*obj)->has_device, "device", &err);
> |- if (!err && (*obj)->has_device) {
> |- visit_type_str(v, &(*obj)->device, "device", &err);
> |- }
> | if (err) {
> | goto out;
> | }
> |+ if ((*obj)->has_device) {
> |+ visit_type_str(v, &(*obj)->device, "device", &err);
> |+ if (err) {
> |+ goto out;
> |+ }
> |+ }
>
> The event code is slightly more verbose, but arguably a bug
> fix (although the visitors are not well documented, use of an
> optional member should not be attempted unless guarded by a
> prior call to visit_optional()) - we were lucky that the output
> qmp visitor has a no-op visit_optional():
Suggest "becomes slightly more verbose, but this is arguably a bug fix:
although [...] prior call to visit_optional(). Works only because the
output qmp visitor [...]".
>
> |+ visit_optional(v, &has_offset, "offset", &err);
> |+ if (err) {
> |+ goto out;
> |+ }
> | if (has_offset) {
> | visit_type_int(v, &offset, "offset", &err);
>
> Signed-off-by: Eric Blake <address@hidden>
>
> ---
> v6: retitle 10/46, split gen_err_check() to its own patch,
> improve commit message, use named parameters in gen_visit_fields()
> to minimize effort of callers
Interdiff to v5 looks sane.
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- Re: [Qemu-devel] [PATCH v6 16/16] qapi: Share gen_visit_fields(),
Markus Armbruster <=