Received: by 2002:a25:c205:0:0:0:0:0 with SMTP id s5csp6700312ybf; Fri, 6 Mar 2020 02:54:25 -0800 (PST) X-Google-Smtp-Source: ADFU+vtosdOG0383ppcWfP/qszta5bh+dZqV7+HBvfJUzQAubvNgriDLrg4svFGbqPVZwkM3Ddtf X-Received: by 2002:aca:abd4:: with SMTP id u203mr2035981oie.104.1583492064993; Fri, 06 Mar 2020 02:54:24 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1583492064; cv=none; d=google.com; s=arc-20160816; b=mShmQRxYwOncKK6tpEeEgiAS8JmaeeUy53yiNQugGk/I0Ua/nkhxMebgjoMMGKImmg kt2M1i+RNVFtM7046DIrVpy3IjgX9aSinp4shD0tnav93Qc9FMrWoaToOfCwNQETLQsf ZVelPxBNRnmpCOChlADBmgvqHqjevb0g47zlQg8n2AlO25ZLu8nqajnbBlNjzdF3hWy1 lXTeqwBxsG7q5qQ6Mr1Rzp+DeoOP+EBN3zjYOGVrM0SJEw/AJJ1MBJs69VvzHstqmOIV ff0LJr+qezRDS4BtZFmx92NKQGJixl57pcd/wlJ3aMMw+z+5ePqpjWnPB476v/b8TKOv hPFA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:in-reply-to:content-disposition :mime-version:references:mail-followup-to:message-id:subject:cc:to :from:date:dkim-signature; bh=8x4FtQ0d/oXsHbBXZA0a8FImN+v9SImsm+MT1st6RXw=; b=FDQr59jdQ8z2qRF5DBNt4zDzKnyFYim8M8XBeDuOa2i05g8/gKb2f+qv6tjicyyPM3 0BOfbM9VI1Kznk7aQMm19GUuFqZoqwyXgjMWGyHujfr7MK5pYKe0smDYP23YI6xGXdOJ CBlsBqe4foOfQcgLpoi8UXZ/oGjhvdKdU3TKEaFKeKFNdVxFqzJUw5NJ4hQlWO2MZgap lXgBbh2D/QmKOEZW5x8tt3pur0YbhAWRuwX/Tv48CZklqcKio6PTt5nURZ4bNR/0j4OG DednbDfVT8VM1qBjo+9HFx/RWrDmeJXCaoaXS/OTvfGnTms1XfctNjAgOkZekEeePKtK r9MA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ffwll.ch header.s=google header.b="MYor/+16"; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id j74si1379901otj.246.2020.03.06.02.54.13; Fri, 06 Mar 2020 02:54:24 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@ffwll.ch header.s=google header.b="MYor/+16"; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726185AbgCFKwZ (ORCPT + 99 others); Fri, 6 Mar 2020 05:52:25 -0500 Received: from mail-wm1-f66.google.com ([209.85.128.66]:39995 "EHLO mail-wm1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726054AbgCFKwZ (ORCPT ); Fri, 6 Mar 2020 05:52:25 -0500 Received: by mail-wm1-f66.google.com with SMTP id e26so1848633wme.5 for ; Fri, 06 Mar 2020 02:52:23 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ffwll.ch; s=google; h=date:from:to:cc:subject:message-id:mail-followup-to:references :mime-version:content-disposition:in-reply-to; bh=8x4FtQ0d/oXsHbBXZA0a8FImN+v9SImsm+MT1st6RXw=; b=MYor/+16j73bXX7/uGT0c3cBr72JfnsMFC9zRoQ8tKBqGaSnpuyBtQ/Pc2pT+i/T6+ CadE482Jsn71oGcSH5NclZrfr7GH+WANRp/Nf85yOg0G8anIbUpha/p6B8Mwxcqx5yJ+ dFkah+87JAvoVMiwxnQYqq5DlvArwxiNaUMmI= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id :mail-followup-to:references:mime-version:content-disposition :in-reply-to; bh=8x4FtQ0d/oXsHbBXZA0a8FImN+v9SImsm+MT1st6RXw=; b=ivN6mK62zzJY5QZWgO+XnXEo45w5eW9piozE5ebxizpSNk9ynzVki23QtHeLwzzPte TGQdevBkFvhgZNcvtguDZJAXDwVj6RZ3vEOqIOcXFEZpAkaouDxOOZPPRT27DpWj1N07 aD9xUHe8V+T7jti04kycvW8l09EyGTt0ZGOVlgeXrLVOx51fOm6qcf1OZPzkVRUK4lMl VMv17wDixF7OYf+fLVUnfTvL0+XO/R0HXWY0KJjJnpUceYVK68N+uemZBReNprwbA0wb hTYhQVoCaHGriMz21OHCxg0y6AFqX/HdUPUAcesI8b/fhg7SZEV89ZpogFhrMWFNy0NS agKw== X-Gm-Message-State: ANhLgQ02YGlYJsPjvjTlNUH4Acd2lsuABjgpr/wMvwUY5I67fQPChUaZ WULfk8mTEOKX+1AVysjUZo/UFA== X-Received: by 2002:a1c:7419:: with SMTP id p25mr3261622wmc.129.1583491942868; Fri, 06 Mar 2020 02:52:22 -0800 (PST) Received: from phenom.ffwll.local ([2a02:168:57f4:0:efd0:b9e5:5ae6:c2fa]) by smtp.gmail.com with ESMTPSA id f6sm13125791wmc.9.2020.03.06.02.52.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 06 Mar 2020 02:52:22 -0800 (PST) Date: Fri, 6 Mar 2020 11:52:20 +0100 From: Daniel Vetter To: "Gustavo A. R. Silva" Cc: David Airlie , Daniel Vetter , dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH][next] drm/bridge/mhl.h: Replace zero-length array with flexible-array member Message-ID: <20200306105220.GX2363188@phenom.ffwll.local> Mail-Followup-To: "Gustavo A. R. Silva" , David Airlie , dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org References: <20200305110011.GA21056@embeddedor> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200305110011.GA21056@embeddedor> X-Operating-System: Linux phenom 5.3.0-3-amd64 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Mar 05, 2020 at 05:00:11AM -0600, Gustavo A. R. Silva wrote: > The current codebase makes use of the zero-length array language > extension to the C90 standard, but the preferred mechanism to declare > variable-length types such as these ones is a flexible array member[1][2], > introduced in C99: > > struct foo { > int stuff; > struct boo array[]; > }; > > By making use of the mechanism above, we will get a compiler warning > in case the flexible array does not occur last in the structure, which > will help us prevent some kind of undefined behavior bugs from being > inadvertently introduced[3] to the codebase from now on. > > Also, notice that, dynamic memory allocations won't be affected by > this change: > > "Flexible array members have incomplete type, and so the sizeof operator > may not be applied. As a quirk of the original implementation of > zero-length arrays, sizeof evaluates to zero."[1] > > This issue was found with the help of Coccinelle. > > [1] https://gcc.gnu.org/onlinedocs/gcc/Zero-Length.html > [2] https://github.com/KSPP/linux/issues/21 > [3] commit 76497732932f ("cxgb3/l2t: Fix undefined behaviour") > > Signed-off-by: Gustavo A. R. Silva Applied to drm-misc-next, thanks for your patch. -Daniel > --- > include/drm/bridge/mhl.h | 4 ++-- > 1 file changed, 2 insertions(+), 2 deletions(-) > > diff --git a/include/drm/bridge/mhl.h b/include/drm/bridge/mhl.h > index 1cc77bf38324..d96626a0e3fa 100644 > --- a/include/drm/bridge/mhl.h > +++ b/include/drm/bridge/mhl.h > @@ -327,13 +327,13 @@ struct mhl_burst_bits_per_pixel_fmt { > struct { > u8 stream_id; > u8 pixel_format; > - } __packed desc[0]; > + } __packed desc[]; > } __packed; > > struct mhl_burst_emsc_support { > struct mhl3_burst_header hdr; > u8 num_entries; > - __be16 burst_id[0]; > + __be16 burst_id[]; > } __packed; > > struct mhl_burst_audio_descr { > -- > 2.25.0 > -- Daniel Vetter Software Engineer, Intel Corporation http://blog.ffwll.ch