linux-kernel-mentees.lists.linuxfoundation.org archive mirror
 help / color / mirror / Atom feed
From: Joe Perches <joe@perches.com>
To: Aditya Srivastava <yashsri421@gmail.com>
Cc: linux-kernel-mentees@lists.linuxfoundation.org,
	linux-kernel@vger.kernel.org, dwaipayanray1@gmail.com
Subject: Re: [Linux-kernel-mentees] [PATCH] checkpatch: fix false positive for REPEATED_WORD warning
Date: Wed, 21 Oct 2020 08:18:57 -0700	[thread overview]
Message-ID: <f073750511750336de5f82600600ba6cb3ddbec0.camel@perches.com> (raw)
In-Reply-To: <20201021150120.29920-1-yashsri421@gmail.com>

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) &&


_______________________________________________
Linux-kernel-mentees mailing list
Linux-kernel-mentees@lists.linuxfoundation.org
https://lists.linuxfoundation.org/mailman/listinfo/linux-kernel-mentees

  parent reply	other threads:[~2020-10-21 15:19 UTC|newest]

Thread overview: 28+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-10-21 15:01 [Linux-kernel-mentees] [PATCH] checkpatch: fix false positive for REPEATED_WORD warning Aditya Srivastava
2020-10-21 15:08 ` Lukas Bulwahn
2020-10-21 15:18 ` Joe Perches [this message]
2020-10-21 15:28   ` Joe Perches
2020-10-21 16:50     ` Joe Perches
2020-10-21 16:59       ` Dwaipayan Ray
2020-10-21 17:17         ` Joe Perches
2020-10-21 17:55       ` Aditya
2020-10-21 18:05         ` Joe Perches
2020-10-21 18:25           ` Aditya
2020-10-21 19:12             ` Lukas Bulwahn
2020-10-22 14:21               ` Aditya
2020-10-22 14:35                 ` Joe Perches
2020-10-21 19:10   ` Aditya
2020-10-21 19:26     ` Joe Perches
2020-10-21 20:36       ` Joe Perches
  -- strict thread matches above, loose matches on Subject: below --
2020-10-21 14:44 Aditya Srivastava
2020-10-21 14:50 ` Lukas Bulwahn
2020-10-21  5:00 Aditya Srivastava
2020-10-21  5:15 ` Aditya
2020-10-21  6:12   ` Lukas Bulwahn
2020-10-21  8:20     ` Dwaipayan Ray
2020-10-21  8:35       ` Aditya
2020-10-21  8:52       ` Lukas Bulwahn
2020-10-21 12:09         ` Aditya
2020-10-21 12:53           ` Aditya
2020-10-21 12:58           ` Lukas Bulwahn
2020-10-21 12:59           ` Dwaipayan Ray

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=f073750511750336de5f82600600ba6cb3ddbec0.camel@perches.com \
    --to=joe@perches.com \
    --cc=dwaipayanray1@gmail.com \
    --cc=linux-kernel-mentees@lists.linuxfoundation.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=yashsri421@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).