Skip to contentSkip to conversation

False positive EXPORT_SYMBOL warning with NS variants

PATCH Applied Ian Pilcher 2 participants 4 messages Sep 3, 2021 – Oct 7, 2021 Checkpatch

lore
Share & tools
lore
#0 lore raw
$ cat foo.c
// SPDX-License-Identifier: GPL-2.0-only
void (*foo)(void);
EXPORT_SYMBOL_NS(foo, FOO);
$ scripts/checkpatch.pl -f foo.c
WARNING: EXPORT_SYMBOL(foo); should immediately follow its function/variable
#3: FILE: foo.c:3:
+EXPORT_SYMBOL_NS(foo, FOO);

The non-NS EXPORT_SYMBOL variants don't trigger this warning.

Signature · 3 lines
========================================================================
                 In Soviet Russia, Google searches you!
========================================================================
maintainer
#1 lore raw
Quoted 5 lines · Ian Pilcher
$ cat foo.c
// SPDX-License-Identifier: GPL-2.0-only
void (*foo)(void);
EXPORT_SYMBOL_NS(foo, FOO);
Quoted 7 lines
$ scripts/checkpatch.pl -f foo.c
WARNING: EXPORT_SYMBOL(foo); should immediately follow its function/variable
#3: FILE: foo.c:3:
+EXPORT_SYMBOL_NS(foo, FOO);

The non-NS EXPORT_SYMBOL variants don't trigger this warning.

Try this:

---
 scripts/checkpatch.pl | 1 +
 1 file changed, 1 insertion(+)
scripts/checkpatch.pl +1 -0
index 88cb294dc4472..91798b07c6cb5 100755
@@ -4449,6 +4449,7 @@ sub process {
 			#   XXX(foo);
 			#   EXPORT_SYMBOL(something_foo);
 			my $name = $1;
+			$name =~ s/^\s*($Ident).*/$1/;
 			if ($stat =~ /^(?:.\s*}\s*\n)?.([A-Z_]+)\s*\(\s*($Ident)/ &&
 			    $name =~ /^${Ident}_$2/) {
 #print "FOO C name<$name>\n";
#2 lore raw
Quoted 25 lines · Joe Perches
Quoted 5 lines · Ian Pilcher
$ cat foo.c
// SPDX-License-Identifier: GPL-2.0-only
void (*foo)(void);
EXPORT_SYMBOL_NS(foo, FOO);
Quoted 7 lines
$ scripts/checkpatch.pl -f foo.c
WARNING: EXPORT_SYMBOL(foo); should immediately follow its function/variable
#3: FILE: foo.c:3:
+EXPORT_SYMBOL_NS(foo, FOO);

The non-NS EXPORT_SYMBOL variants don't trigger this warning.

Try this:

---
  scripts/checkpatch.pl | 1 +
  1 file changed, 1 insertion(+)
scripts/checkpatch.pl +0 -0
index 88cb294dc4472..91798b07c6cb5 100755

scripts/checkpatch.pl sub process { · line 4455

Quoted 7 lines
scripts/checkpatch.pl +1 -0
@@ -4449,6 +4449,7 @@ sub process {
  			#   XXX(foo);
  			#   EXPORT_SYMBOL(something_foo);
  			my $name = $1;
+			$name =~ s/^\s*($Ident).*/$1/;
  			if ($stat =~ /^(?:.\s*}\s*\n)?.([A-Z_]+)\s*\(\s*($Ident)/ &&
  			    $name =~ /^${Ident}_$2/) {
  #print "FOO C name<$name>\n";

Seems to work

Signature · 3 lines
========================================================================
                 In Soviet Russia, Google searches you!
========================================================================
maintainer
#3 lore raw

PATCH 1/1 checkpatch: Improve EXPORT_SYMBOL test for EXPORT_SYMBOL_NS uses

In reply to Ian Pilcher

The EXPORT_SYMBOL test expects a single argument but definitions of EXPORT_SYMBOL_NS have multiple arguments.

Update the test to extract only the first argument from any EXPORT_SYMBOL related definition.

---
 scripts/checkpatch.pl | 1 +
 1 file changed, 1 insertion(+)
scripts/checkpatch.pl +1 -0
index 88cb294dc4472..91798b07c6cb5 100755
@@ -4449,6 +4449,7 @@ sub process {
 			#   XXX(foo);
 			#   EXPORT_SYMBOL(something_foo);
 			my $name = $1;
+			$name =~ s/^\s*($Ident).*/$1/;
 			if ($stat =~ /^(?:.\s*}\s*\n)?.([A-Z_]+)\s*\(\s*($Ident)/ &&
 			    $name =~ /^${Ident}_$2/) {
 #print "FOO C name<$name>\n";