Skip to content

Commit 8bf425d

Browse files
Geliang Tangintel-lab-lkp
Geliang Tang
authored andcommitted
checkpatch: skip warnings for symbol links
If there is a symbol link in the given patch, like the following one: $ 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 ''' checkpatch.pl reports two inaccurate warnings: ''' WARNING: Missing or malformed SPDX-License-Identifier tag in line 1 torvalds#65: 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 torvalds#65: FILE: tools/testing/selftests/bpf/mptcp_pm_nl_ctl.c:1: +../net/mptcp/pm_nl_ctl.c ''' And three checks if run it with strict option: ''' CHECK: spaces preferred around that '/' (ctx:VxV) torvalds#65: FILE: tools/testing/selftests/bpf/mptcp_pm_nl_ctl.c:1: +../net/mptcp/pm_nl_ctl.c ^ CHECK: spaces preferred around that '/' (ctx:VxV) torvalds#65: FILE: tools/testing/selftests/bpf/mptcp_pm_nl_ctl.c:1: +../net/mptcp/pm_nl_ctl.c ^ CHECK: spaces preferred around that '/' (ctx:VxV) torvalds#65: FILE: tools/testing/selftests/bpf/mptcp_pm_nl_ctl.c:1: +../net/mptcp/pm_nl_ctl.c ''' This patch fixes this by adding a new variable $symbol_link in checkpatch script, set it if the new file mode is 120000. Skip "missing or malformed SPDX-License-Identifier tag", "adding a line without newline at end of file" and "spaces preferred around that '/'" checks if this variable is set. Signed-off-by: Geliang Tang <[email protected]>
1 parent 13f8e00 commit 8bf425d

File tree

1 file changed

+12
-3
lines changed

1 file changed

+12
-3
lines changed

scripts/checkpatch.pl

+12-3
Original file line numberDiff line numberDiff line change
@@ -2694,6 +2694,8 @@ sub process {
26942694

26952695
my $checklicenseline = 1;
26962696

2697+
my $symbol_link = 0;
2698+
26972699
sanitise_line_reset();
26982700
my $line;
26992701
foreach my $rawline (@rawlines) {
@@ -3564,6 +3566,11 @@ sub process {
35643566
# ignore non-hunk lines and lines being removed
35653567
next if (!$hunk_line || $line =~ /^-/);
35663568

3569+
# Check for symbol links
3570+
if ($line =~ /^new file mode 120000$/) {
3571+
$symbol_link = 1;
3572+
}
3573+
35673574
#trailing whitespace
35683575
if ($line =~ /^\+.*\015/) {
35693576
my $herevet = "$here\n" . cat_vet($rawline) . "\n";
@@ -3756,7 +3763,8 @@ sub process {
37563763
}
37573764

37583765
if ($comment !~ /^$/ &&
3759-
$rawline !~ m@^\+\Q$comment\E SPDX-License-Identifier: @) {
3766+
$rawline !~ m@^\+\Q$comment\E SPDX-License-Identifier: @ &&
3767+
$symbol_link =~ 1) {
37603768
WARN("SPDX_LICENSE_TAG",
37613769
"Missing or malformed SPDX-License-Identifier tag in line $checklicenseline\n" . $herecurr);
37623770
} elsif ($rawline =~ /(SPDX-License-Identifier: .*)/) {
@@ -3867,7 +3875,8 @@ sub process {
38673875
}
38683876

38693877
# check for adding lines without a newline.
3870-
if ($line =~ /^\+/ && defined $lines[$linenr] && $lines[$linenr] =~ /^\\ No newline at end of file/) {
3878+
if ($line =~ /^\+/ && defined $lines[$linenr] && $lines[$linenr] =~ /^\\ No newline at end of file/ &&
3879+
$symbol_link =~ 1) {
38713880
if (WARN("MISSING_EOF_NEWLINE",
38723881
"adding a line without newline at end of file\n" . $herecurr) &&
38733882
$fix) {
@@ -5293,7 +5302,7 @@ sub process {
52935302
$op eq '*' or $op eq '/' or
52945303
$op eq '%')
52955304
{
5296-
if ($check) {
5305+
if ($check && $symbol_link =~ 1) {
52975306
if (defined $fix_elements[$n + 2] && $ctx !~ /[EW]x[EW]/) {
52985307
if (CHK("SPACING",
52995308
"spaces preferred around that '$op' $at\n" . $hereptr)) {

0 commit comments

Comments
 (0)