diff mbox series

[mptcp-next,v4,3/3] checkpatch: skip warnings for symbol links

Message ID 1628d78e12809ff0f4dd0526f6addbbf00dae66b.1715503185.git.tanggeliang@kylinos.cn (mailing list archive)
State Superseded, archived
Delegated to: Matthieu Baerts
Headers show
Series patches for new MPTCP subflow subtest | expand

Checks

Context Check Description
matttbe/build success Build and static analysis OK
matttbe/checkpatch success total: 0 errors, 0 warnings, 0 checks, 35 lines checked
matttbe/shellcheck success MPTCP selftests files have not been modified
matttbe/KVM_Validation__normal success Success! ✅
matttbe/KVM_Validation__debug success Success! ✅
matttbe/KVM_Validation__btf__only_bpftest_all_ success Success! ✅

Commit Message

Geliang Tang May 12, 2024, 8:41 a.m. UTC
From: Geliang Tang <tanggeliang@kylinos.cn>

If there is a symbol link in the given patch, checkpatch.pl reports two
inaccurate warnings:

$ cat 0001-selftests-bpf-Add-mptcp-pm_nl_ctl-link.patch

 ... ...

 '''
 # diff --git a/tools/testing/selftests/bpf/mptcp_pm_nl_ctl.c \
 #            b/tools/testing/selftests/bpf/mptcp_pm_nl_ctl.c
 # new file mode 120000
 # index 000000000000..5a08c255b278
 # --- /dev/null
 # +++ b/tools/testing/selftests/bpf/mptcp_pm_nl_ctl.c
 # @@ -0,0 +1 @@
 # +../net/mptcp/pm_nl_ctl.c
 # \ No newline at end of file
 '''

$ ./scripts/checkpatch.pl 0001-selftests-bpf-Add-mptcp-pm_nl_ctl-link.patch

 '''
 WARNING: Missing or malformed SPDX-License-Identifier tag in line 1
 #57: FILE: tools/testing/selftests/bpf/mptcp_pm_nl_ctl.c:1:
 +../net/mptcp/pm_nl_ctl.c

 WARNING: adding a line without newline at end of file
 #57: FILE: tools/testing/selftests/bpf/mptcp_pm_nl_ctl.c:1:
 +../net/mptcp/pm_nl_ctl.c

 total: 0 errors, 2 warnings, 16 lines checked
 '''

This patch fixes this by adding a new variable $symbol_link in checkpatch
script, set it if the new file mode is 120000. Skip these two checks
"missing SPDX-License-Identifier" and "adding a line without newline at
end of file" if this variable is set.

Signed-off-by: Geliang Tang <tanggeliang@kylinos.cn>
---
 scripts/checkpatch.pl | 11 +++++++++--
 1 file changed, 9 insertions(+), 2 deletions(-)

Comments

Matthieu Baerts May 13, 2024, 10:44 a.m. UTC | #1
Hi Geliang,

On 12/05/2024 10:41, Geliang Tang wrote:
> From: Geliang Tang <tanggeliang@kylinos.cn>
> 
> If there is a symbol link in the given patch, checkpatch.pl reports two
> inaccurate warnings:

Good idea to fix that!

Do you mind sending it as a separated patch to CheckPatch maintainers
directly?

It might be good to split it in 2, with 2 different Fixes tag, to help
with the backports.

Cheers,
Matt
Matthieu Baerts May 15, 2024, 4:43 p.m. UTC | #2
Hi Geliang,

On 12/05/2024 10:41, Geliang Tang wrote:
> From: Geliang Tang <tanggeliang@kylinos.cn>
> 
> If there is a symbol link in the given patch, checkpatch.pl reports two
> inaccurate warnings:
> 
> $ cat 0001-selftests-bpf-Add-mptcp-pm_nl_ctl-link.patch
> 
>  ... ...
> 
>  '''
>  # diff --git a/tools/testing/selftests/bpf/mptcp_pm_nl_ctl.c \
>  #            b/tools/testing/selftests/bpf/mptcp_pm_nl_ctl.c
>  # new file mode 120000
>  # index 000000000000..5a08c255b278
>  # --- /dev/null
>  # +++ b/tools/testing/selftests/bpf/mptcp_pm_nl_ctl.c
>  # @@ -0,0 +1 @@
>  # +../net/mptcp/pm_nl_ctl.c
>  # \ No newline at end of file
>  '''
> 
> $ ./scripts/checkpatch.pl 0001-selftests-bpf-Add-mptcp-pm_nl_ctl-link.patch
> 
>  '''
>  WARNING: Missing or malformed SPDX-License-Identifier tag in line 1
>  #57: FILE: tools/testing/selftests/bpf/mptcp_pm_nl_ctl.c:1:
>  +../net/mptcp/pm_nl_ctl.c
> 
>  WARNING: adding a line without newline at end of file
>  #57: FILE: tools/testing/selftests/bpf/mptcp_pm_nl_ctl.c:1:
>  +../net/mptcp/pm_nl_ctl.c
> 
>  total: 0 errors, 2 warnings, 16 lines checked
>  '''

With 'checkpatch.pl --strict', I also had these warnings:

> CHECK: spaces preferred around that '/' (ctx:VxV)
> #63: FILE: tools/testing/selftests/bpf/mptcp_pm_nl_ctl.c:1:
> +../net/mptcp/pm_nl_ctl.c
>    ^
> 
> CHECK: spaces preferred around that '/' (ctx:VxV)
> #63: FILE: tools/testing/selftests/bpf/mptcp_pm_nl_ctl.c:1:
> +../net/mptcp/pm_nl_ctl.c
>        ^
> 
> CHECK: spaces preferred around that '/' (ctx:VxV)
> #63: FILE: tools/testing/selftests/bpf/mptcp_pm_nl_ctl.c:1:
> +../net/mptcp/pm_nl_ctl.c
>              ^

I guess a similar fix could be done for this check as well :)

Cheers,
Matt
diff mbox series

Patch

diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
index 9c4c4a61bc83..b31f13d643a7 100755
--- a/scripts/checkpatch.pl
+++ b/scripts/checkpatch.pl
@@ -436,6 +436,7 @@  for my $key (keys %debug) {
 }
 
 my $rpt_cleaners = 0;
+my $symbol_link = 0;
 
 if ($terse) {
 	$emacs = 1;
@@ -3595,6 +3596,10 @@  sub process {
 				      "Do not include the paragraph about writing to the Free Software Foundation's mailing address from the sample GPL notice. The FSF has changed addresses in the past, and may do so again. Linux already includes a copy of the GPL.\n" . $herevet)
 		}
 
+		if ($line =~ /^new file mode 120000$/) {
+			$symbol_link = 1;
+		}
+
 # check for Kconfig help text having a real description
 # Only applies when adding the entry originally, after that we do not have
 # sufficient context to determine whether it is indeed long enough.
@@ -3756,7 +3761,8 @@  sub process {
 				}
 
 				if ($comment !~ /^$/ &&
-				    $rawline !~ m@^\+\Q$comment\E SPDX-License-Identifier: @) {
+				    $rawline !~ m@^\+\Q$comment\E SPDX-License-Identifier: @ &&
+				    $symbol_link =~ 1) {
 					WARN("SPDX_LICENSE_TAG",
 					     "Missing or malformed SPDX-License-Identifier tag in line $checklicenseline\n" . $herecurr);
 				} elsif ($rawline =~ /(SPDX-License-Identifier: .*)/) {
@@ -3867,7 +3873,8 @@  sub process {
 		}
 
 # check for adding lines without a newline.
-		if ($line =~ /^\+/ && defined $lines[$linenr] && $lines[$linenr] =~ /^\\ No newline at end of file/) {
+		if ($line =~ /^\+/ && defined $lines[$linenr] && $lines[$linenr] =~ /^\\ No newline at end of file/ &&
+		    $symbol_link =~ 1) {
 			if (WARN("MISSING_EOF_NEWLINE",
 			         "adding a line without newline at end of file\n" . $herecurr) &&
 			    $fix) {