Received: by 2002:a25:c205:0:0:0:0:0 with SMTP id s5csp6690890ybf; Fri, 6 Mar 2020 02:41:19 -0800 (PST) X-Google-Smtp-Source: ADFU+vuCktU3ccOVFd5mnNv8CE7ZNxielHbYMbi9wFHjJ2OVH7HmBDY3Xwf4WYelZ9WR0WGGVgH7 X-Received: by 2002:a9d:70ce:: with SMTP id w14mr2008475otj.194.1583491279655; Fri, 06 Mar 2020 02:41:19 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1583491279; cv=none; d=google.com; s=arc-20160816; b=jgJ4femB+QnfjlMIjrJBsf/Opfl6uWITBzA7EBE2lKXSMRJUd1aunXHUsrecwQlRv3 W0/CVKrKJYi6wOif9EtmfuPF5NN7HYu0P4CCw0V0DhTebwCHtXjohWRmvxnfuKiRv9s3 hwwRZhff2LyZM4pnUpEXzAGIYZkMbg+1ZzLnecywt706Za7Ie187liYmIkDsaoVD4IJA MM3GQm5CYKBKFDCgvG3LnGBFq3qeItK4Tiv+hi1PCMilETvtzD7UU6+EKw8NSshZjQwJ EV/fNMTL/QPnlH5NoyRdf78JuN7KCQyvD3+SwJ+BOolkRzh02+5I2Hlqu7gtAr0/oWT5 WNqQ== 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=3uwQmoeCVMR1OjRUyFcSdUC36g6Oo2T6mj6l89+Qx08=; b=mTfAkeOsRZdz/qCAWihlf85JHvGL+6Rzvzkw0WF83GfqerGLbiC5BdFjzIvrk+h9BP ix+ROWBXyC9ETqjpKajk386fa3A4Qwd35CuvBnZCB+y6PDcHek5f8v4iFcztEF3LJ7BU xhan4gIF+itDmecUbp9sSS0WFgyRppB53Ka2IIPXFKSruXUEOI1D5m+mV1Gxb5D5hcQb V1qjS2MJbyyGZS0Ahd5IwPeKCeVgCfH81Ax5+mlZ1hVA2PGSjAEWrXbCLHYaCYD0/0cI eKn0dck00OqYJjKBiBv6FD59zdTvrw5PtypUzMmyZxe+R4fNPIstiVEaBJfU0IrPtG5i VXTQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ffwll.ch header.s=google header.b=Iw0ZWJAT; 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 i1si1205377oiy.42.2020.03.06.02.41.08; Fri, 06 Mar 2020 02:41:19 -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=Iw0ZWJAT; 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 S1726891AbgCFKko (ORCPT + 99 others); Fri, 6 Mar 2020 05:40:44 -0500 Received: from mail-wr1-f68.google.com ([209.85.221.68]:44461 "EHLO mail-wr1-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726231AbgCFKkn (ORCPT ); Fri, 6 Mar 2020 05:40:43 -0500 Received: by mail-wr1-f68.google.com with SMTP id n7so1728522wrt.11 for ; Fri, 06 Mar 2020 02:40:42 -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=3uwQmoeCVMR1OjRUyFcSdUC36g6Oo2T6mj6l89+Qx08=; b=Iw0ZWJATxL79py60HW/tvolmLUL5DiTJF3n+O9KSkscsoVaDd1sC+1a99B/XaFEnvD pufFlRVL3+f+wG50aKPpypMk0JrVexnVpCKewc0I7WHWdopgdwRd8hv6V7g5QwBmbzwS QJ68Po5jb2PQb1aJ9Oo25pmODM/axP3qzitM0= 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=3uwQmoeCVMR1OjRUyFcSdUC36g6Oo2T6mj6l89+Qx08=; b=PWzwYnD/biv5fYm6meoCWb0D5oVDIIfG68kK4GAdXc8SFXScYgB7FkGVMt7XmLw44c ZstlZUe0GTGHrsZGwpVL1iGCD6C9gZSfgA6r2itLFFoVVfjljiJaN+gp5LngIGwSNA/9 5060oddlxos/P1gF9cTXemlCdG5yEM+aCr5H8u2vptjKnDl2Xcb8UEq3wwrQsx6KeXGo 4dnM/MtNc/8wYdO0QaF+ht66i3tCbAr4sTrgDYCyRLI5VWhzgBNFDtZccrDkSoKQ4bXz LRtDoL+Sbzlf8x+pZEt8MbKJnT5QcihwdvnLBPkhWnAaIjjg27Y6V8bhLfDDSqwHksEf 1IFw== X-Gm-Message-State: ANhLgQ3LeksVPeS1CAWlhhjFDeXmNnacN3X1baiCqLJaW8cJCKWxgS7+ 22uW95/11iK1dUhAiQF2xxFcRA== X-Received: by 2002:a05:6000:4:: with SMTP id h4mr2203376wrx.14.1583491241522; Fri, 06 Mar 2020 02:40:41 -0800 (PST) Received: from phenom.ffwll.local ([2a02:168:57f4:0:efd0:b9e5:5ae6:c2fa]) by smtp.gmail.com with ESMTPSA id t14sm16353673wrp.63.2020.03.06.02.40.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 06 Mar 2020 02:40:40 -0800 (PST) Date: Fri, 6 Mar 2020 11:40:39 +0100 From: Daniel Vetter To: "Gustavo A. R. Silva" Cc: Patrik Jakobsson , David Airlie , Daniel Vetter , dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH][next] drm/gma500/intel_bios.h: Replace zero-length array with flexible-array member Message-ID: <20200306104039.GU2363188@phenom.ffwll.local> Mail-Followup-To: "Gustavo A. R. Silva" , Patrik Jakobsson , David Airlie , dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org References: <20200305105306.GA18788@embeddedor> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200305105306.GA18788@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 04:53:06AM -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 > --- > drivers/gpu/drm/gma500/intel_bios.h | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/drivers/gpu/drm/gma500/intel_bios.h b/drivers/gpu/drm/gma500/intel_bios.h > index a1f9ce9465a5..0e6facf21e33 100644 > --- a/drivers/gpu/drm/gma500/intel_bios.h > +++ b/drivers/gpu/drm/gma500/intel_bios.h > @@ -227,7 +227,7 @@ struct bdb_general_definitions { > * number = (block_size - sizeof(bdb_general_definitions))/ > * sizeof(child_device_config); > */ > - struct child_device_config devices[0]; > + struct child_device_config devices[]; > }; > > struct bdb_lvds_options { > -- > 2.25.0 > -- Daniel Vetter Software Engineer, Intel Corporation http://blog.ffwll.ch