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 X-Spam-Level: X-Spam-Status: No, score=-6.7 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE, SPF_PASS,URIBL_BLOCKED autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 7570DC55178 for ; Wed, 21 Oct 2020 15:19:02 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 23A002177B for ; Wed, 21 Oct 2020 15:19:02 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2444125AbgJUPTB (ORCPT ); Wed, 21 Oct 2020 11:19:01 -0400 Received: from smtprelay0048.hostedemail.com ([216.40.44.48]:45376 "EHLO smtprelay.hostedemail.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S2444103AbgJUPTA (ORCPT ); Wed, 21 Oct 2020 11:19:00 -0400 Received: from filter.hostedemail.com (clb03-v110.bra.tucows.net [216.40.38.60]) by smtprelay04.hostedemail.com (Postfix) with ESMTP id 7961A180A7FFA; Wed, 21 Oct 2020 15:18:59 +0000 (UTC) X-Session-Marker: 6A6F6540706572636865732E636F6D X-HE-Tag: tail45_2c0cd3027249 X-Filterd-Recvd-Size: 2737 Received: from XPS-9350.home (unknown [47.151.133.149]) (Authenticated sender: joe@perches.com) by omf12.hostedemail.com (Postfix) with ESMTPA; Wed, 21 Oct 2020 15:18:58 +0000 (UTC) Message-ID: Subject: Re: [PATCH] checkpatch: fix false positive for REPEATED_WORD warning From: Joe Perches To: Aditya Srivastava Cc: linux-kernel@vger.kernel.org, lukas.bulwahn@gmail.com, linux-kernel-mentees@lists.linuxfoundation.org, dwaipayanray1@gmail.com Date: Wed, 21 Oct 2020 08:18:57 -0700 In-Reply-To: <20201021150120.29920-1-yashsri421@gmail.com> References: <20201021150120.29920-1-yashsri421@gmail.com> Content-Type: text/plain; charset="ISO-8859-1" User-Agent: Evolution 3.36.4-0ubuntu1 MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, 2020-10-21 at 20:31 +0530, Aditya Srivastava wrote: > Presence of hexadecimal address or symbol results in false warning > message by checkpatch.pl. > > For example, running checkpatch on commit b8ad540dd4e4 ("mptcp: fix > memory leak in mptcp_subflow_create_socket()") results in warning: > > WARNING:REPEATED_WORD: Possible repeated word: 'ff' > 00 00 00 00 00 00 00 00 00 2f 30 0a 81 88 ff ff ........./0..... Right. > To avoid all such reports, add an additional regex check for a repeating > pattern of 4 or more 2-lettered words separated by space in a line. > A quick evaluation on v5.6..v5.8 showed that this fix reduces > REPEATED_WORD warnings from 2797 to 1043. Are many of the other 1043 false positives? Any pattern to them? > diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl [] > @@ -3050,8 +3050,10 @@ sub process { > } > } > > -# check for repeated words separated by a single space > - if ($rawline =~ /^\+/ || $in_commit_log) { > +# check for repeated words separated by a single space and > +# avoid repeating hex occurrences like 'ff ff fe 09 ...' > + if (($rawline =~ /^\+/ || $in_commit_log) && > + $rawline !~ /(\b[0-9a-f]{2}( )+){4,}/) { This might be better as \b$Hex to avoid FF FF and FFFFFFFF FFFFFFFF I might add that check to the line below where the repeated words are checked against long --- scripts/checkpatch.pl | 1 + 1 file changed, 1 insertion(+) diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl index fab38b493cef..929866999f81 100755 --- a/scripts/checkpatch.pl +++ b/scripts/checkpatch.pl @@ -3062,6 +3062,7 @@ sub process { next if ($first ne $second); next if ($first eq 'long'); + next if ($first =~ /^$Hex$/; if (WARN("REPEATED_WORD", "Possible repeated word: '$first'\n" . $herecurr) &&