From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 8FE69FA3744 for ; Tue, 1 Nov 2022 00:38:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:Content-Type: Content-Transfer-Encoding:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:In-Reply-To:From:References:Cc:To:Subject: MIME-Version:Date:Message-ID:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=O4+3grpjvTkcj3IcP75OscJ+Gj5eXSsgjfGgplQ/h6o=; b=dgnlko0ZanytpZ nmg1OfhBoj0zhFYx7H87A//qCybffrXKpxxyZbgKVZzdAyJRhUSu6sXhucOOP4NnxcO9m4QBBZskj BnWRiQbVWUfGxnKpsIND/Ju727vQYLa2OpyRRMjb2vzi3gdmX0sr1vBsikygdL6ufK/myZtQLwlvE +68Khzr5RWvIGxjyxBJRcfPx8hZOAwEl/6+KpAgYRreBNlvXZLJZuX5/pwRHyqEt1eYJA+aUH/O/8 hldSwTIv+tjlSL2snyxvrLbvC31hbbGdCSYigMIwxB4QopljuAVy7abZemfmAK7mgrOtK9ZvJl0BI 7uf+SupRaItPIEPmm6YA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1opfHF-00GwjD-VB; Tue, 01 Nov 2022 00:37:14 +0000 Received: from omta37.uswest2.a.cloudfilter.net ([35.89.44.36]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1opfHD-00Gwhr-K3 for linux-arm-kernel@lists.infradead.org; Tue, 01 Nov 2022 00:37:13 +0000 Received: from eig-obgw-6005a.ext.cloudfilter.net ([10.0.30.201]) by cmsmtp with ESMTP id pecXosh6VqEICpfGwoJYpk; Tue, 01 Nov 2022 00:36:54 +0000 Received: from gator4166.hostgator.com ([108.167.133.22]) by cmsmtp with ESMTP id pfGvo1GSLwguipfGvoEySo; Tue, 01 Nov 2022 00:36:54 +0000 X-Authority-Analysis: v=2.4 cv=ZfkOi+ZA c=1 sm=1 tr=0 ts=63606a26 a=1YbLdUo/zbTtOZ3uB5T3HA==:117 a=wTog8WU66it3cfrESHnF4A==:17 a=dLZJa+xiwSxG16/P+YVxDGlgEgI=:19 a=IkcTkHD0fZMA:10 a=Qawa6l4ZSaYA:10 a=wYkD_t78qR0A:10 a=TCL3t-gOmiXOs0atSnwA:9 a=QEXdDO2ut3YA:10 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=embeddedor.com; s=default; h=Content-Transfer-Encoding:Content-Type: In-Reply-To:From:References:Cc:To:Subject:MIME-Version:Date:Message-ID:Sender :Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help: List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=MLjpJH6sJtG3eyLqG+16mXrzIl/XBNVKLpM3ejMi4SQ=; b=BnPGvJJflWMNqJk68ts2+Vm40U vPCGZkq0B3jqkVA/xWogy8JsdvNwmlVHdDDJT93FZBt/JNV+xv+3g4GKEMhQlLXDz3UVieqIGBm9N zEGGOJ8fs8Yu1ZDCAmuYkZdpnAGgq4u0OIYeujIaJ9TrnicN4ug9IpDTSD7teJN9Yrn8OeQdjHv// 6JTR3qJB4+zmZl6WaCb7rU3bu0hrzXm+1sxAYDFWTqmq+iWLsPisGvkNRRUwCL+Mtv7lZw5qRDRW7 rTS4FW9vG4Qki2PRp7bxUo4wjOHNtgSwbR/RTVQv9fqWxqTRUG04T8uCsjVD27lJb++CkzZEgu85m AXg7JFbA==; Received: from 187-162-31-110.static.axtel.net ([187.162.31.110]:41634 helo=[192.168.15.7]) by gator4166.hostgator.com with esmtpsa (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.95) (envelope-from ) id 1opaOT-000xYN-EP; Mon, 31 Oct 2022 14:24:22 -0500 Message-ID: <89eca382-fca3-28f9-eac7-f855f2efb598@embeddedor.com> Date: Mon, 31 Oct 2022 13:23:54 -0500 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.2.2 Subject: Re: new checkpatch flexible array test ? (was Re: [PATCH v4 12/14] gunyah: rsc_mgr: Add RPC for console services) Content-Language: en-US To: Greg Kroah-Hartman , Joe Perches , "Gustavo A. R. Silva" Cc: Elliot Berman , Andrew Morton , Bjorn Andersson , Murali Nalajala , Trilok Soni , Srivatsa Vaddagiri , Carl van Schaik , Andy Gross , Dmitry Baryshkov , Jassi Brar , linux-arm-kernel@lists.infradead.org, Mark Rutland , Lorenzo Pieralisi , Sudeep Holla , Marc Zyngier , Rob Herring , Krzysztof Kozlowski , Jonathan Corbet , Will Deacon , Catalin Marinas , Arnd Bergmann , devicetree@vger.kernel.org, linux-doc@vger.kernel.org, linux-arm-msm@vger.kernel.org, linux-kernel@vger.kernel.org References: <20220928195633.2348848-1-quic_eberman@quicinc.com> <20220928195633.2348848-13-quic_eberman@quicinc.com> <04ade5f54bd3dc658cb8606c98b0b1fe34a97383.camel@perches.com> From: "Gustavo A. R. Silva" In-Reply-To: <04ade5f54bd3dc658cb8606c98b0b1fe34a97383.camel@perches.com> X-AntiAbuse: This header was added to track abuse, please include it with any abuse report X-AntiAbuse: Primary Hostname - gator4166.hostgator.com X-AntiAbuse: Original Domain - lists.infradead.org X-AntiAbuse: Originator/Caller UID/GID - [47 12] / [47 12] X-AntiAbuse: Sender Address Domain - embeddedor.com X-BWhitelist: no X-Source-IP: 187.162.31.110 X-Source-L: No X-Exim-ID: 1opaOT-000xYN-EP X-Source: X-Source-Args: X-Source-Dir: X-Source-Sender: 187-162-31-110.static.axtel.net ([192.168.15.7]) [187.162.31.110]:41634 X-Source-Auth: gustavo@embeddedor.com X-Email-Count: 0 X-Org: HG=hgshared;ORG=hostgator; X-Source-Cap: Z3V6aWRpbmU7Z3V6aWRpbmU7Z2F0b3I0MTY2Lmhvc3RnYXRvci5jb20= X-Local-Domain: yes X-CMAE-Envelope: MS4xfKmsY6CM4CXCQOhJI8LNATLm9JX56TFcA5tIlRctXmkHlZ09c5qPjR8tkMrzMqO34TlTJdFLmbh/Ml3eji4BywrV3NWC6GH2vbM8iUbRzPD+uzKUdYS/ WKgNvXRUPT6Oc+Yrr+Br0Bf+az4uBA7Dbj/pYWqaJ2R7SR5Jd+nLQfH1gUpGh7mNrbtEqIUt+wNuIx7db0Ofp7+ZeHv+v5Y0LZ+z8yrEiEEz0mEYyrXHNBly X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20221031_173711_810115_F31238AF X-CRM114-Status: GOOD ( 19.03 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset="us-ascii"; Format="flowed" Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org On 10/3/22 00:38, Joe Perches wrote: > On Mon, 2022-10-03 at 07:29 +0200, Greg Kroah-Hartman wrote: >> On Sun, Oct 02, 2022 at 06:46:30PM -0700, Joe Perches wrote: >>> On Fri, 2022-09-30 at 14:22 +0200, Greg Kroah-Hartman wrote: >>>> On Wed, Sep 28, 2022 at 12:56:31PM -0700, Elliot Berman wrote: >>>>> Gunyah resource manager defines a simple API for virtual machine log >>>>> sharing with the console service. >>> [] >>>>> diff --git a/include/linux/gunyah_rsc_mgr.h b/include/linux/gunyah_rsc_mgr.h >>> [] >>>>> +struct gh_rm_notif_vm_console_chars { >>>>> + u16 vmid; >>>>> + u16 num_bytes; >>>>> + u8 bytes[0]; >>>> >>>> Please do not use [0] for new structures, otherwise we will just have to >>>> fix them up again as we are trying to get rid of all of these from the >>>> kernel. Just use "bytes[];" instead. >>> >>> Maybe a checkpatch addition like: >>> --- > [] >>> diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl > [] >>> @@ -3948,6 +3948,17 @@ sub process { >>> } >>> } >>> >>> +# check for zero length array declarations in likely structs >>> + if ($line =~ /^\+\t($Declare\s*$Ident)\s*\[\s*0\s*\]\s*;\s*$/ && >>> + defined $lines[$linenr] && >>> + $lines[$linenr] =~ /^[\+ ]\}\s*(?:__\w+\s*(?:$balanced_parens)?)\s*;\s*$/) { This sounds great. We need the same for one-element arrays. :) Both zero-length and one-element arrays are deprecated. > > This should actually be: > > $lines[$linenr] =~ /^[\+ ]\}(?:\s*__\w+\s*(?:$balanced_parens)?)*\s*;\s*$/) { I agree. Thanks. > > as it was missing a * for uses like > > int foo[0]; > } __packed __aligned(4); > > and uses without any attribute at all > >>> + if (WARN("FLEXIBLE_ARRAY_ZERO", >>> + "Prefer flexible length array declarations with [] over [0]\n" . $herecurr) && >>> + $fix) { >>> + $fixed[$fixlinenr] =~ s/\[\s*0\s*\]/[]/; >>> + } >>> + } >>> + >>> # check for multiple consecutive blank lines >>> if ($prevline =~ /^[\+ ]\s*$/ && >>> $line =~ /^\+\s*$/ && >> >> This is a question for Gustavo, who did all the work here. Gustavo, >> does the above checkpatch change look good to you? Yep; the idea is great. :) Another alternative to stop those fake flex-arrays from entering the codebase is to run Coccinelle scripts during linux-next builds, as suggested by Elena Reshetova at LSSEU a couple of months ago. However, if these can be stopped with checkpatch it'd be really helpful, as well. Thanks -- Gustavo _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel