Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.2 required=3.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_SANE_1 autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 02230C433DF for ; Wed, 10 Jun 2020 19:17:31 +0000 (UTC) Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id C4BDB20656 for ; Wed, 10 Jun 2020 19:17:31 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org C4BDB20656 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=xen.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=xen-devel-bounces@lists.xenproject.org Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1jj6De-0006wx-FW; Wed, 10 Jun 2020 19:17:02 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1jj6Dc-0006ws-VL for xen-devel@lists.xenproject.org; Wed, 10 Jun 2020 19:17:00 +0000 X-Inumbo-ID: f50f06be-ab4e-11ea-bb8b-bc764e2007e4 Received: from deinos.phlegethon.org (unknown [2001:41d0:8:b1d7::1]) by us1-rack-iad1.inumbo.com (Halon) with ESMTPS id f50f06be-ab4e-11ea-bb8b-bc764e2007e4; Wed, 10 Jun 2020 19:17:00 +0000 (UTC) Received: from tjd by deinos.phlegethon.org with local (Exim 4.92.3 (FreeBSD)) (envelope-from ) id 1jj6DZ-000I6A-Uq; Wed, 10 Jun 2020 19:16:57 +0000 Date: Wed, 10 Jun 2020 20:16:57 +0100 From: Tim Deegan To: Olaf Hering Subject: Re: [PATCH v1] kdd: remove zero-length arrays Message-ID: <20200610191657.GA69414@deinos.phlegethon.org> References: <20200608203849.18341-1-olaf@aepfle.de> <005001d63e3b$c85059f0$58f10dd0$@xen.org> <20200609121549.GA90841@deinos.phlegethon.org> <20200609152233.039cfc86.olaf@aepfle.de> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline In-Reply-To: <20200609152233.039cfc86.olaf@aepfle.de> User-Agent: Mutt/1.11.1 (2018-12-01) X-SA-Known-Good: Yes X-SA-Exim-Connect-IP: X-SA-Exim-Mail-From: tim@xen.org X-SA-Exim-Scanned: No (on deinos.phlegethon.org); SAEximRunCond expanded to false X-BeenThere: xen-devel@lists.xenproject.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Cc: xen-devel@lists.xenproject.org, 'Ian Jackson' , 'Wei Liu' , paul@xen.org Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" At 15:22 +0200 on 09 Jun (1591716153), Olaf Hering wrote: > Am Tue, 9 Jun 2020 13:15:49 +0100 > schrieb Tim Deegan : > > > Olaf, can you try dropping the 'payload' field from the header and replacing the payload[0] in pkt with payload[] ? > > In file included from kdd.c:53: > kdd.h:325:17: error: flexible array member in union > 325 | uint8_t payload[]; How tedious. Well, the only place we actually allocate one of these we already leave enough space for a max-size packet, so how about this? kdd: stop using [0] arrays to access packet contents. GCC 10 is unhappy about this, and we already use 64k buffers in the only places where packets are allocated, so move the 64k size into the packet definition. Reported-by: Olaf Hering Signed-off-by: Tim Deegan --- tools/debugger/kdd/kdd.c | 4 ++-- tools/debugger/kdd/kdd.h | 3 +-- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git tools/debugger/kdd/kdd.c tools/debugger/kdd/kdd.c index 3ebda9b12c..a7d0976ea4 100644 --- tools/debugger/kdd/kdd.c +++ tools/debugger/kdd/kdd.c @@ -79,11 +79,11 @@ typedef struct { /* State of the debugger stub */ typedef struct { union { - uint8_t txb[sizeof (kdd_hdr) + 65536]; /* Marshalling area for tx */ + uint8_t txb[sizeof (kdd_pkt)]; /* Marshalling area for tx */ kdd_pkt txp; /* Also readable as a packet structure */ }; union { - uint8_t rxb[sizeof (kdd_hdr) + 65536]; /* Marshalling area for rx */ + uint8_t rxb[sizeof (kdd_pkt)]; /* Marshalling area for rx */ kdd_pkt rxp; /* Also readable as a packet structure */ }; unsigned int cur; /* Offset into rx where we'll put the next byte */ diff --git tools/debugger/kdd/kdd.h tools/debugger/kdd/kdd.h index bfb00ba5c5..b9a17440df 100644 --- tools/debugger/kdd/kdd.h +++ tools/debugger/kdd/kdd.h @@ -68,7 +68,6 @@ typedef struct { uint16_t len; /* Payload length, excl. header and trailing byte */ uint32_t id; /* Echoed in responses */ uint32_t sum; /* Unsigned sum of all payload bytes */ - uint8_t payload[0]; } PACKED kdd_hdr; #define KDD_PKT_CMD 0x0002 /* Debugger commands (and replies to them) */ @@ -323,7 +322,7 @@ typedef struct { kdd_msg msg; kdd_reg reg; kdd_stc stc; - uint8_t payload[0]; + uint8_t payload[65536]; }; } PACKED kdd_pkt; -- 2.26.2