From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:52944) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Zgw3E-0003Oe-Ev for qemu-devel@nongnu.org; Tue, 29 Sep 2015 10:38:41 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Zgw3B-0006yC-4s for qemu-devel@nongnu.org; Tue, 29 Sep 2015 10:38:40 -0400 Received: from mx1.redhat.com ([209.132.183.28]:50648) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Zgw3A-0006y5-VP for qemu-devel@nongnu.org; Tue, 29 Sep 2015 10:38:37 -0400 From: Markus Armbruster References: <1443497249-15361-1-git-send-email-eblake@redhat.com> <1443497249-15361-17-git-send-email-eblake@redhat.com> Date: Tue, 29 Sep 2015 16:38:33 +0200 In-Reply-To: <1443497249-15361-17-git-send-email-eblake@redhat.com> (Eric Blake's message of "Mon, 28 Sep 2015 21:27:29 -0600") Message-ID: <87pp11guja.fsf@blackfin.pond.sub.org> MIME-Version: 1.0 Content-Type: text/plain Subject: Re: [Qemu-devel] [PATCH v6 16/16] qapi: Share gen_visit_fields() List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Eric Blake Cc: marcandre.lureau@redhat.com, qemu-devel@nongnu.org, ehabkost@redhat.com, Michael Roth Eric Blake 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 > > --- > 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.