From patchwork Mon Oct 3 01:46:30 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joe Perches X-Patchwork-Id: 612031 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 26DD8C4332F for ; Mon, 3 Oct 2022 01:46:46 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229451AbiJCBqo convert rfc822-to-8bit (ORCPT ); Sun, 2 Oct 2022 21:46:44 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56148 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229458AbiJCBqn (ORCPT ); Sun, 2 Oct 2022 21:46:43 -0400 Received: from relay.hostedemail.com (smtprelay0016.hostedemail.com [216.40.44.16]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6DBA127CC4; Sun, 2 Oct 2022 18:46:41 -0700 (PDT) Received: from omf02.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay10.hostedemail.com (Postfix) with ESMTP id 71710C0802; Mon, 3 Oct 2022 01:46:38 +0000 (UTC) Received: from [HIDDEN] (Authenticated sender: joe@perches.com) by omf02.hostedemail.com (Postfix) with ESMTPA id A5C348000E; Mon, 3 Oct 2022 01:46:31 +0000 (UTC) Message-ID: Subject: new checkpatch flexible array test ? (was Re: [PATCH v4 12/14] gunyah: rsc_mgr: Add RPC for console services) From: Joe Perches To: Greg Kroah-Hartman , Elliot Berman , Andrew Morton Cc: 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 Date: Sun, 02 Oct 2022 18:46:30 -0700 In-Reply-To: References: <20220928195633.2348848-1-quic_eberman@quicinc.com> <20220928195633.2348848-13-quic_eberman@quicinc.com> User-Agent: Evolution 3.44.4 (3.44.4-2.fc36) MIME-Version: 1.0 X-Stat-Signature: s8bxywehf4i6ap8qz4d4zh7cgy8f5nng X-Rspamd-Server: rspamout05 X-Rspamd-Queue-Id: A5C348000E X-Session-Marker: 6A6F6540706572636865732E636F6D X-Session-ID: U2FsdGVkX1+OfeghBDJYxV12c+mletSZVAMPeQeBrtw= X-HE-Tag: 1664761591-583478 Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@vger.kernel.org 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: --- scripts/checkpatch.pl | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl index 2737e4ced5745..187ed84c1f80a 100755 --- 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*$/) { + 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*$/ &&