From d99a4158c4483c7f47274937deb142cd8c461b77 Mon Sep 17 00:00:00 2001 From: Gerhard Engleder Date: Wed, 4 Jan 2023 21:15:24 +0100 Subject: checkpatch: ignore ETHTOOL_LINK_MODE_ enum values Since commit 4104a20646 ("checkpatch: ignore generated CamelCase defines and enum values") enum values like ETHTOOL_LINK_MODE_Asym_Pause_BIT are ignored. But there are other enums like ETHTOOL_LINK_MODE_1000baseT_Full_BIT, which are not ignored because of the not matching '1000baseT' substring. Add regex to match all ETHTOOL_LINK_MODE enums. Link: https://lkml.kernel.org/r/20230104201524.28078-1-gerhard@engleder-embedded.com Signed-off-by: Gerhard Engleder Cc: Andy Whitcroft Cc: Dwaipayan Ray Cc: Gerhard Engleder Cc: Joe Perches Cc: Lukas Bulwahn Signed-off-by: Andrew Morton --- scripts/checkpatch.pl | 2 ++ 1 file changed, 2 insertions(+) (limited to 'scripts/checkpatch.pl') diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl index bd44d12965c9..c7cd0750b41e 100755 --- a/scripts/checkpatch.pl +++ b/scripts/checkpatch.pl @@ -5809,6 +5809,8 @@ sub process { $var !~ /^(?:[A-Z]+_){1,5}[A-Z]{1,3}[a-z]/ && #Ignore Page variants $var !~ /^(?:Clear|Set|TestClear|TestSet|)Page[A-Z]/ && +#Ignore ETHTOOL_LINK_MODE_ variants + $var !~ /^ETHTOOL_LINK_MODE_/ && #Ignore SI style variants like nS, mV and dB #(ie: max_uV, regulator_min_uA_show, RANGE_mA_VALUE) $var !~ /^(?:[a-z0-9_]*|[A-Z0-9_]*)?_?[a-z][A-Z](?:_[a-z0-9_]+|_[A-Z0-9_]+)?$/ && -- cgit From c917a872cee480d1fc8461da9be93e27e7977877 Mon Sep 17 00:00:00 2001 From: Matthieu Baerts Date: Mon, 3 Apr 2023 18:23:47 +0200 Subject: checkpatch: don't print the next line if not defined MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit When checking if "Reported-by" tag is followed by "Link:", there is no need to print the next line if there is no next line. While at it, also mention in this case that the "Link:" tag should be followed by a URL, similar to the next warning. By doing that, the code is now similar to what is done above when checking if the Co-developed-by tag is properly used. Link: https://lkml.kernel.org/r/20230314-doc-checkpatch-closes-tag-v4-2-d26d1fa66f9f@tessares.net Fixes: d7f1d71e5ef6 ("checkpatch: warn when Reported-by: is not followed by Link:") Signed-off-by: Matthieu Baerts Acked-by: Joe Perches Cc: Andy Whitcroft Cc: Bagas Sanjaya Cc: Daniel Vetter Cc: David Airlie Cc: Dwaipayan Ray Cc: Jonathan Corbet Cc: Kai Wasserbäch Cc: Konstantin Ryabitsev Cc: Linus Torvalds Cc: Lukas Bulwahn Cc: Thorsten Leemhuis Signed-off-by: Andrew Morton --- scripts/checkpatch.pl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'scripts/checkpatch.pl') diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl index c7cd0750b41e..8e22eb45ab2d 100755 --- a/scripts/checkpatch.pl +++ b/scripts/checkpatch.pl @@ -3162,7 +3162,7 @@ sub process { if ($sign_off =~ /^reported(?:|-and-tested)-by:$/i) { if (!defined $lines[$linenr]) { WARN("BAD_REPORTED_BY_LINK", - "Reported-by: should be immediately followed by Link: to the report\n" . $herecurr . $rawlines[$linenr] . "\n"); + "Reported-by: should be immediately followed by Link: with a URL to the report\n" . $herecurr . "\n"); } elsif ($rawlines[$linenr] !~ m{^link:\s*https?://}i) { WARN("BAD_REPORTED_BY_LINK", "Reported-by: should be immediately followed by Link: with a URL to the report\n" . $herecurr . $rawlines[$linenr] . "\n"); -- cgit From f94e40ea272b9847833de1114677eb5ad8b12a0a Mon Sep 17 00:00:00 2001 From: Matthieu Baerts Date: Mon, 3 Apr 2023 18:23:48 +0200 Subject: checkpatch: use a list of "link" tags MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The following commit will allow the use of a similar "link" tag. Because there is a possibility that other similar tags will be added in the future and to reduce the number of places where the code will be modified to allow this new tag, a list with all these "link" tags is now used. Two variables are created from it: one to search for such tags and one to print all tags in a warning message. Link: https://lkml.kernel.org/r/20230314-doc-checkpatch-closes-tag-v4-3-d26d1fa66f9f@tessares.net Signed-off-by: Matthieu Baerts Suggested-by: Joe Perches Acked-by: Joe Perches Cc: Andy Whitcroft Cc: Bagas Sanjaya Cc: Daniel Vetter Cc: David Airlie Cc: Dwaipayan Ray Cc: Jonathan Corbet Cc: Kai Wasserbäch Cc: Konstantin Ryabitsev Cc: Linus Torvalds Cc: Lukas Bulwahn Cc: Thorsten Leemhuis Signed-off-by: Andrew Morton --- scripts/checkpatch.pl | 24 ++++++++++++++++++++---- 1 file changed, 20 insertions(+), 4 deletions(-) (limited to 'scripts/checkpatch.pl') diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl index 8e22eb45ab2d..209898b8f0b6 100755 --- a/scripts/checkpatch.pl +++ b/scripts/checkpatch.pl @@ -620,6 +620,22 @@ our $signature_tags = qr{(?xi: Cc: )}; +our @link_tags = qw(Link); + +#Create a search and print patterns for all these strings to be used directly below +our $link_tags_search = ""; +our $link_tags_print = ""; +foreach my $entry (@link_tags) { + if ($link_tags_search ne "") { + $link_tags_search .= '|'; + $link_tags_print .= ' or '; + } + $entry .= ':'; + $link_tags_search .= $entry; + $link_tags_print .= "'$entry'"; +} +$link_tags_search = "(?:${link_tags_search})"; + our $tracing_logging_tags = qr{(?xi: [=-]*> | <[=-]* | @@ -3250,8 +3266,8 @@ sub process { # file delta changes $line =~ /^\s*(?:[\w\.\-\+]*\/)++[\w\.\-\+]+:/ || # filename then : - $line =~ /^\s*(?:Fixes:|Link:|$signature_tags)/i || - # A Fixes: or Link: line or signature tag line + $line =~ /^\s*(?:Fixes:|$link_tags_search|$signature_tags)/i || + # A Fixes:, link or signature tag line $commit_log_possible_stack_dump)) { WARN("COMMIT_LOG_LONG_LINE", "Possible unwrapped commit description (prefer a maximum 75 chars per line)\n" . $herecurr); @@ -3266,13 +3282,13 @@ sub process { # Check for odd tags before a URI/URL if ($in_commit_log && - $line =~ /^\s*(\w+):\s*http/ && $1 ne 'Link') { + $line =~ /^\s*(\w+:)\s*http/ && $1 !~ /^$link_tags_search$/) { if ($1 =~ /^v(?:ersion)?\d+/i) { WARN("COMMIT_LOG_VERSIONING", "Patch version information should be after the --- line\n" . $herecurr); } else { WARN("COMMIT_LOG_USE_LINK", - "Unknown link reference '$1:', use 'Link:' instead\n" . $herecurr); + "Unknown link reference '$1', use $link_tags_print instead\n" . $herecurr); } } -- cgit From 44c31888098a590b8ec5ba37009e5a983f7c4b46 Mon Sep 17 00:00:00 2001 From: Matthieu Baerts Date: Mon, 3 Apr 2023 18:23:49 +0200 Subject: checkpatch: allow Closes tags with links MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit As a follow-up of a previous patch modifying the documentation to allow using the "Closes:" tag, checkpatch.pl is updated accordingly. checkpatch.pl now no longer complain when the "Closes:" tag is used by itself: commit 76f381bb77a0 ("checkpatch: warn when unknown tags are used for links") ... or after the "Reported-by:" tag: commit d7f1d71e5ef6 ("checkpatch: warn when Reported-by: is not followed by Link:") Closes: https://github.com/multipath-tcp/mptcp_net-next/issues/373 Link: https://lkml.kernel.org/r/20230314-doc-checkpatch-closes-tag-v4-4-d26d1fa66f9f@tessares.net Signed-off-by: Matthieu Baerts Acked-by: Joe Perches Cc: Andy Whitcroft Cc: Bagas Sanjaya Cc: Daniel Vetter Cc: David Airlie Cc: Dwaipayan Ray Cc: Jonathan Corbet Cc: Kai Wasserbäch Cc: Konstantin Ryabitsev Cc: Linus Torvalds Cc: Lukas Bulwahn Cc: Thorsten Leemhuis Signed-off-by: Andrew Morton --- scripts/checkpatch.pl | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'scripts/checkpatch.pl') diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl index 209898b8f0b6..922428ee3be5 100755 --- a/scripts/checkpatch.pl +++ b/scripts/checkpatch.pl @@ -620,7 +620,7 @@ our $signature_tags = qr{(?xi: Cc: )}; -our @link_tags = qw(Link); +our @link_tags = qw(Link Closes); #Create a search and print patterns for all these strings to be used directly below our $link_tags_search = ""; @@ -3174,14 +3174,14 @@ sub process { } } -# check if Reported-by: is followed by a Link: +# check if Reported-by: is followed by a Closes: tag if ($sign_off =~ /^reported(?:|-and-tested)-by:$/i) { if (!defined $lines[$linenr]) { WARN("BAD_REPORTED_BY_LINK", - "Reported-by: should be immediately followed by Link: with a URL to the report\n" . $herecurr . "\n"); - } elsif ($rawlines[$linenr] !~ m{^link:\s*https?://}i) { + "Reported-by: should be immediately followed by Closes: with a URL to the report\n" . $herecurr . "\n"); + } elsif ($rawlines[$linenr] !~ m{^closes:\s*https?://}i) { WARN("BAD_REPORTED_BY_LINK", - "Reported-by: should be immediately followed by Link: with a URL to the report\n" . $herecurr . $rawlines[$linenr] . "\n"); + "Reported-by: should be immediately followed by Closes: with a URL to the report\n" . $herecurr . $rawlines[$linenr] . "\n"); } } } -- cgit From d6ccdd678e459fdcfe675a45c76b3f1a75b9a8e8 Mon Sep 17 00:00:00 2001 From: Matthieu Baerts Date: Mon, 3 Apr 2023 18:23:50 +0200 Subject: checkpatch: check for misuse of the link tags MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit "Link:" and "Closes:" tags have to be used with public URLs. It is difficult to make sure the link is public but at least we can verify the tag is followed by 'http(s)://'. With that, we avoid such a tag that is not allowed [1]: Closes: Now that we check the "link" tags are followed by a URL, we can relax the check linked to "Reported-by being followed by a link tag" to only verify if a "link" tag is present after the "Reported-by" one. Link: https://lore.kernel.org/linux-doc/CAHk-=wh0v1EeDV3v8TzK81nDC40=XuTdY2MCr0xy3m3FiBV3+Q@mail.gmail.com/ [1] Link: https://lkml.kernel.org/r/20230314-doc-checkpatch-closes-tag-v4-5-d26d1fa66f9f@tessares.net Signed-off-by: Matthieu Baerts Acked-by: Joe Perches Cc: Andy Whitcroft Cc: Bagas Sanjaya Cc: Daniel Vetter Cc: David Airlie Cc: Dwaipayan Ray Cc: Jonathan Corbet Cc: Kai Wasserbäch Cc: Konstantin Ryabitsev Cc: Linus Torvalds Cc: Lukas Bulwahn Cc: Thorsten Leemhuis Signed-off-by: Andrew Morton --- scripts/checkpatch.pl | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) (limited to 'scripts/checkpatch.pl') diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl index 922428ee3be5..3e6f5a8614d3 100755 --- a/scripts/checkpatch.pl +++ b/scripts/checkpatch.pl @@ -3179,7 +3179,7 @@ sub process { if (!defined $lines[$linenr]) { WARN("BAD_REPORTED_BY_LINK", "Reported-by: should be immediately followed by Closes: with a URL to the report\n" . $herecurr . "\n"); - } elsif ($rawlines[$linenr] !~ m{^closes:\s*https?://}i) { + } elsif ($rawlines[$linenr] !~ /^closes:\s*/i) { WARN("BAD_REPORTED_BY_LINK", "Reported-by: should be immediately followed by Closes: with a URL to the report\n" . $herecurr . $rawlines[$linenr] . "\n"); } @@ -3292,6 +3292,17 @@ sub process { } } +# Check for misuse of the link tags + if ($in_commit_log && + $line =~ /^\s*(\w+:)\s*(\S+)/) { + my $tag = $1; + my $value = $2; + if ($tag =~ /^$link_tags_search$/ && $value !~ m{^https?://}) { + WARN("COMMIT_LOG_WRONG_LINK", + "'$tag' should be followed by a public http(s) link\n" . $herecurr); + } + } + # Check for lines starting with a # if ($in_commit_log && $line =~ /^#/) { if (WARN("COMMIT_COMMENT_SYMBOL", -- cgit From a04bb4c24a4846232a81047784d5eff2848e45bd Mon Sep 17 00:00:00 2001 From: Dmitry Rokosov Date: Tue, 4 Apr 2023 22:17:15 +0300 Subject: checkpatch: introduce proper bindings license check All headers from 'include/dt-bindings/' must be verified by checkpatch together with Documentation bindings, because all of them are part of the whole DT bindings system. The requirement is dual licensed and matching patterns: * Schemas: /GPL-2\.0(?:-only)? OR BSD-2-Clause/ * Headers: /GPL-2\.0(?:-only)? OR \S+/ Above patterns suggested by Rob at: https://lore.kernel.org/all/CAL_Jsq+-YJsBO+LuPJ=ZQ=eb-monrwzuCppvReH+af7hYZzNaQ@mail.gmail.com The issue was found during patch review: https://lore.kernel.org/all/20230313201259.19998-4-ddrokosov@sberdevices.ru/ Link: https://lkml.kernel.org/r/20230404191715.7319-1-ddrokosov@sberdevices.ru Signed-off-by: Dmitry Rokosov Reviewed-by: Rob Herring Cc: Andy Whitcroft Cc: Dwaipayan Ray Cc: Joe Perches Cc: Krzysztof Kozlowski Cc: Lukas Bulwahn Signed-off-by: Andrew Morton --- scripts/checkpatch.pl | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'scripts/checkpatch.pl') diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl index 3e6f5a8614d3..23bb211de4ce 100755 --- a/scripts/checkpatch.pl +++ b/scripts/checkpatch.pl @@ -3763,7 +3763,7 @@ sub process { "'$spdx_license' is not supported in LICENSES/...\n" . $herecurr); } if ($realfile =~ m@^Documentation/devicetree/bindings/@ && - not $spdx_license =~ /GPL-2\.0.*BSD-2-Clause/) { + $spdx_license !~ /GPL-2\.0(?:-only)? OR BSD-2-Clause/) { my $msg_level = \&WARN; $msg_level = \&CHK if ($file); if (&{$msg_level}("SPDX_LICENSE_TAG", @@ -3773,6 +3773,11 @@ sub process { $fixed[$fixlinenr] =~ s/SPDX-License-Identifier: .*/SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)/; } } + if ($realfile =~ m@^include/dt-bindings/@ && + $spdx_license !~ /GPL-2\.0(?:-only)? OR \S+/) { + WARN("SPDX_LICENSE_TAG", + "DT binding headers should be licensed (GPL-2.0-only OR .*)\n" . $herecurr); + } } } } -- cgit