[Linux-kernel-mentees] [PATCH] checkpatch: fix false positive for REPEATED_WORD warning

Lukas Bulwahn lukas.bulwahn at gmail.com
Wed Oct 21 06:12:29 UTC 2020



On Wed, 21 Oct 2020, Aditya wrote:

> On 21/10/20 10:30 am, 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.....
> > 
> > Here, it reports 'ff' to be repeated, but it is infact part of some

Aditya:

s/infact/in fact/

> > address or code, where it has to be repeated. Thus the warning seems
> > unnecessary in this case.
> >

"unnecessary in this case" is a bit weak.
You can say it stronger:

In this case, the intent of the warning to find stylistic issues in commit 
messages is not met and the warning is just completely wrong in this case.

> > 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.
> > 
> > Signed-off-by: Aditya Srivastava <yashsri421 at gmail.com>
> > ---
> >  scripts/checkpatch.pl | 4 +++-
> >  1 file changed, 3 insertions(+), 1 deletion(-)
> > 
> > diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
> > index 9b9ffd876e8a..181c95691715 100755
> > --- a/scripts/checkpatch.pl
> > +++ b/scripts/checkpatch.pl
> > @@ -3052,7 +3052,9 @@ sub process {
> >  
> >  # check for repeated words separated by a single space
> >  		if ($rawline =~ /^\+/ || $in_commit_log) {
> > -			while ($rawline =~ /\b($word_pattern) (?=($word_pattern))/g) {
> > +			# avoid repeating hex occurrences like 'ff ff fe 09 ...'
> > +			while ($rawline !~ /((\s)*[0-9a-z]{2}( )+){4,}/ &&
> > +				$rawline =~ /\b($word_pattern) (?=($word_pattern))/g) {
> >  
> >  				my $first = $1;
> >  				my $second = $2;
> > 
> 
> 
> Report of the impact of patch/changes(taken over v5.6..v5.8):
> 
> List of errors and warnings after applying the patch:
> https://github.com/AdityaSrivast/kernel-tasks/blob/master/Task3/summary.txt
> 
> Change in errors and warnings compared to previous patch:
> https://github.com/AdityaSrivast/kernel-tasks/blob/master/Task3/relative_summary/summary_relative.txt
> 
> Impact/Conclusion:
> It can be seen that a large amount of warning messages under
> REPEATED_WORD were because of such hex occurrences.
> The changes made reduces the warning count of REPEATED_WORD by more
> than 60%, ie. from 2797 to 1015 (over v5.6..v5.8)
>

Aditya, so can you share a quick export of all the warnings that were 
dropped?
Just to check that all of them are hex stuff and we did not silence 
another class of valid REPEATED_WORD warnings?

Dwaipayan, can you review this patch and comment if you would have 
implemented that the same way or if you see other options that you have 
considered during your review?

Aditya, once you address my stylistic comments on the commit message and 
once you got feedback from Dwaipayan, you can send the patch to the 
checkpatch maintainers and lkml and please CC me, Dwaipayan and the 
linux-kernel-mentees list.

Lukas


More information about the Linux-kernel-mentees mailing list