From patchwork Thu Nov 26 00:23:08 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eric Blake X-Patchwork-Id: 548876 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id CCE49140306 for ; Thu, 26 Nov 2015 11:31:00 +1100 (AEDT) Received: from localhost ([::1]:48479 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1a1kSg-0004Xn-Cj for incoming@patchwork.ozlabs.org; Wed, 25 Nov 2015 19:30:58 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:58534) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1a1kLU-00076G-IJ for qemu-devel@nongnu.org; Wed, 25 Nov 2015 19:23:33 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1a1kLT-0005t8-RE for qemu-devel@nongnu.org; Wed, 25 Nov 2015 19:23:32 -0500 Received: from mx1.redhat.com ([209.132.183.28]:34042) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1a1kLT-0005sd-Ki; Wed, 25 Nov 2015 19:23:31 -0500 Received: from int-mx13.intmail.prod.int.phx2.redhat.com (int-mx13.intmail.prod.int.phx2.redhat.com [10.5.11.26]) by mx1.redhat.com (Postfix) with ESMTPS id 3A3B48E22D; Thu, 26 Nov 2015 00:23:31 +0000 (UTC) Received: from red.redhat.com ([10.3.113.12]) by int-mx13.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id tAQ0NOdY020886; Wed, 25 Nov 2015 19:23:30 -0500 From: Eric Blake To: qemu-devel@nongnu.org Date: Wed, 25 Nov 2015 17:23:08 -0700 Message-Id: <1448497401-27784-12-git-send-email-eblake@redhat.com> In-Reply-To: <1448497401-27784-1-git-send-email-eblake@redhat.com> References: <1448497401-27784-1-git-send-email-eblake@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.26 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: Alexander Graf , "open list:sPAPR pseries" , armbru@redhat.com, David Gibson Subject: [Qemu-devel] [PATCH v6 11/23] ppc: Improve use of qapi visitors X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org The implementation of prop_get_fdt() is taking some shortcuts with the qapi visitor functions. Document them, and use error_abort rather than NULL to ensure that any changes to the visitors do not break our use of shortcuts. Signed-off-by: Eric Blake --- v6: new patch, split from RFC on v5 7/46 --- hw/ppc/spapr_drc.c | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/hw/ppc/spapr_drc.c b/hw/ppc/spapr_drc.c index 1846b4f..03a1879 100644 --- a/hw/ppc/spapr_drc.c +++ b/hw/ppc/spapr_drc.c @@ -276,21 +276,26 @@ static void prop_get_fdt(Object *obj, Visitor *v, void *opaque, case FDT_BEGIN_NODE: fdt_depth++; name = fdt_get_name(fdt, fdt_offset, &name_len); - visit_start_struct(v, NULL, NULL, name, 0, NULL); + visit_start_struct(v, NULL, "fdt", name, 0, &error_abort); break; case FDT_END_NODE: /* shouldn't ever see an FDT_END_NODE before FDT_BEGIN_NODE */ g_assert(fdt_depth > 0); - visit_end_struct(v, NULL); + visit_end_struct(v, &error_abort); fdt_depth--; break; case FDT_PROP: { int i; prop = fdt_get_property_by_offset(fdt, fdt_offset, &prop_len); name = fdt_string(fdt, fdt32_to_cpu(prop->nameoff)); - visit_start_list(v, name, NULL); + /* Note: since v is an output visitor, we can get away + * with just visiting a direct sequence of uint8 into the + * output array, instead of creating a uint8List and using + * visit_type_uint8List(). */ + visit_start_list(v, name, &error_abort); for (i = 0; i < prop_len; i++) { - visit_type_uint8(v, (uint8_t *)&prop->data[i], NULL, NULL); + visit_type_uint8(v, (uint8_t *)&prop->data[i], NULL, + &error_abort); } visit_end_list(v);