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

Dwaipayan Ray dwaipayanray1 at gmail.com
Wed Oct 21 12:59:04 UTC 2020


>  # 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 ...'

Hey,
Probably one more change you could do here:

> +                       while ($rawline !~ /(\b[0-9a-f]{2}( )+){4,}/ &&
> +                               $rawline =~ /\b($word_pattern) (?=($word_pattern))/g) {

The hex check is performed everytime a duplicate word is found
in the line. A line with multiple duplicate words will lead to
unnecessary re run of the hex check.

Example:

"This is is the the repeated word"
Two repeated words: 'is' and 'the', and two runs
of the hex check on the same line.


Probably move it here?
 +               if (($rawline =~ /^\+/ || $in_commit_log) &&
 +                    $rawline !~ /(\b[0-9a-f]{2}( )+){4,}/) {

Thanks,
Dwaipayan.


More information about the Linux-kernel-mentees mailing list