Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp254153pxk; Thu, 1 Oct 2020 01:13:36 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwdytiI9L6PVd/wlwibCf/MFyEyigolakhZDj0JTkF7d3HQPh3bUo/PjTn1qI1fc6Iu18qZ X-Received: by 2002:a17:906:17c6:: with SMTP id u6mr6914917eje.95.1601540016522; Thu, 01 Oct 2020 01:13:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1601540016; cv=none; d=google.com; s=arc-20160816; b=ekRX/jnUAJQq59zpDzGyOGiF+tYYz4VYiWSvmQYi2CVhOE5/dXBLrSOKMvalpkGzSq yCOkDMPahiqwAb5skHaMTXrL0aOHLKvTu6wJe2ZjC0jYn5aD4CKGHGLuXPW5Vnlnt3ZY uShZKqqHCjIVpwkJr1vkj83Pf8a+C7k1J6+vWFHbhlv/cy9oDss+B5A5XHTnIRpsLLhn 6FOxRExKF7CA7V8hww8Hks3wmySLjwq6IE60LVm1WiiiRgZZOXZ052No3tFaVOjwTTuc EIJHhjT/ZcKaiDgfHwBF4rdLpU3LaFu73G3f67D3/PrFRV+bZ8Uy5vI4TdEg6BDoI8Os B/Pw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :organization:references:in-reply-to:message-id:subject:cc:to:from :date; bh=EfNXcvD4EkNXu8z+l4D4ENpWgcsGjvyOi4yB3wvcTH0=; b=QkEPVLnrOaUob5YpXMz1H9/QCe7AR9yJ00qpjEVDIWBilL5jLLsMhQkOfoL0neNReZ ietVDHH4mktudiLiIzqyLjii74ed7uz4/AN0lJ/VW5aOr7sFbSCxWdYEBcYRrwsBMiDy 58Vy1ZeOHlfeSdG/rXCj7i2nuot6fQa6j8EcSfrkw+hYcYlmNpejUJm7r7K6ZZYok0Zc S18Sd5vMBeZAvB5+GerXgQu2LoE/MzDdvd+rI2isGPbKFAFGXMfAVToERPz6LXtAUjI2 Oyyb0uAGnxvTAdA3sct3XppkYPM/HG5oAmb+59eG5k+5FZZNX2DbrgyGxCv80l/aQikM UeVQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id 16si2663086edv.551.2020.10.01.01.13.12; Thu, 01 Oct 2020 01:13:36 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1725921AbgJAIMM convert rfc822-to-8bit (ORCPT + 99 others); Thu, 1 Oct 2020 04:12:12 -0400 Received: from relay1-d.mail.gandi.net ([217.70.183.193]:56687 "EHLO relay1-d.mail.gandi.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725878AbgJAIMM (ORCPT ); Thu, 1 Oct 2020 04:12:12 -0400 X-Originating-IP: 91.224.148.103 Received: from xps13 (unknown [91.224.148.103]) (Authenticated sender: miquel.raynal@bootlin.com) by relay1-d.mail.gandi.net (Postfix) with ESMTPSA id ECF2124000D; Thu, 1 Oct 2020 08:12:07 +0000 (UTC) Date: Thu, 1 Oct 2020 10:12:06 +0200 From: Miquel Raynal To: Jann Horn Cc: "Gustavo A. R. Silva" , Stefan Agner , Lucas Stach , Richard Weinberger , Vignesh Raghavendra , Thierry Reding , Jonathan Hunter , linux-mtd@lists.infradead.org, linux-tegra@vger.kernel.org, kernel list , linux-hardening@vger.kernel.org Subject: Re: [PATCH][next] mtd: rawnand: Replace one-element array with flexible-array member Message-ID: <20201001101206.6e4beea7@xps13> In-Reply-To: References: <20200930210824.GA12277@embeddedor> <20200930213634.GA12855@embeddedor> Organization: Bootlin X-Mailer: Claws Mail 3.17.4 (GTK+ 2.24.32; x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8BIT Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Jann, Jann Horn wrote on Thu, 1 Oct 2020 00:32:24 +0200: > On Wed, Sep 30, 2020 at 11:30 PM Gustavo A. R. Silva > wrote: > > On Wed, Sep 30, 2020 at 11:10:43PM +0200, Jann Horn wrote: > > > On Wed, Sep 30, 2020 at 11:02 PM Gustavo A. R. Silva > > > wrote: > > > > There is a regular need in the kernel to provide a way to declare having > > > > a dynamically sized set of trailing elements in a structure. Kernel code > > > > should always use “flexible array members”[1] for these cases. The older > > > > style of one-element or zero-length arrays should no longer be used[2]. > > > > > > But this is not such a case, right? Isn't this a true fixed-size > > > array? It sounds like you're just changing it because it > > > pattern-matched on "array of length 1 at the end of a struct". > > > > Yeah; I should have changed that 'dynamically' part of the text above > > a bit. However, as I commented in the text below, in the case that more > > CS IDs are needed (let's wait for the maintainers to comment on this...) > > in the future, this change makes the code more maintainable, as for > > the allocation part, the developer would only have to update the CS_N > > macro to the number of CS IDs that are needed. > > But in that case, shouldn't you change it to "int cs[CS_N]" and get > rid of the struct_size() stuff? I do agree with Jann, I think it's best to consider this a fixed-size array for now. If we ever want to extend the number of supported CS, there is much more rework involved anyway. Thanks, Miquèl