checkpatch: fix false positive for REPEATED_WORD warning
PATCH 1/1 checkpatch: fix false positive for REPEATED_WORD warning
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 in fact part of some address or code, where it has to be repeated.
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.
A quick evaluation on v5.6..v5.8 showed that this fix reduces REPEATED_WORD warnings from 2797 to 1043.
A quick manual check found all cases are related to hex output in commit messages.
--- scripts/checkpatch.pl | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
scripts/checkpatch.pl +4 -2
@@ -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,}/) { while ($rawline =~ /\b($word_pattern) (?=($word_pattern))/g) { my $first = $1;
Signature · 6 lines
2.17.1 _______________________________________________ Linux-kernel-mentees mailing list [email protected] https://lists.linuxfoundation.org/mailman/listinfo/linux-kernel-mentees
Quoted 15 lines · Aditya Srivastava
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 inmptcp_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 in fact part of some address or code, where it has to be repeated.
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.
Quoted 9 lines
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_WORDwarnings from 2797 to 1043.A quick manual check found all cases are related to hex output in commit messages.
Looks good to me. Send it to the general mailing list and Joe Perches to get more feedback and finally an Acked-by.
Merge window is currently ongoing; so, Joe probably has time, but Andrew Morton who picks up the patch will probably need a week or two.
Please also CC this mailing list, Dwaipayan and me.
Lukas
Quoted 26 lines
Signed-off-by Aditya Srivastava <[email protected]>--- scripts/checkpatch.pl | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)scripts/checkpatch.pl +4
-2@@ -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,}/) { while ($rawline =~ /\b($word_pattern) (?=($word_pattern))/g) { my $first = $1;Signature · 1 line
2.17.1
_______________________________________________
Linux-kernel-mentees mailing list
[email protected]
https://lists.linuxfoundation.org/mailman/listinfo/linux-kernel-mentees