Skip to contentSkip to conversation

kbuild: fix headers_check.pl

PATCH Applied Amerigo Wang 4 participants 8 messages Jun 5, 2009 Kbuild

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 kbuild: fix headers_check.pl

'extern' checking information is not clear, refine it. Plus, fix a comment.

Cc Sam Ravnborg <[email protected]>

----

scripts/headers_check.pl +9 -5
index 56f90a4..3923888 100644
@@ -2,7 +2,7 @@
 #
 # headers_check.pl execute a number of trivial consistency checks
 #
-# Usage: headers_check.pl dir [files...]
+# Usage: headers_check.pl dir arch [files...]
 # dir:   dir to look for included files
 # arch:  architecture
 # files: list of files to check
@@ -37,7 +37,7 @@ foreach my $file (@files) {
 		&check_include();
 		&check_asm_types();
 		&check_sizetypes();
-		&check_prototypes();
+		&check_declarations();
 		# Dropped for now. Too much noise &check_config();
 	}
 	close FH;
@@ -61,10 +61,14 @@ sub check_include
 	}
 }
 
-sub check_prototypes
+sub check_declarations
 {
-	if ($line =~ m/^\s*extern\b/) {
-		printf STDERR "$filename:$lineno: extern's make no sense in userspace\n";
+	if ($line =~m/^\s*extern\b/) {
+		if ($line =~ m/^\s*extern\b.*\(.*\)/) {
+			printf STDERR "$filename:$lineno: extern's make no sense in userspace\n";
+		} else {
+			printf STDERR "$filename:$lineno: exporting global variable to userspace is suspicious\n";
+		}
 	}
 }
 
#1 lore raw

PATCH 1/1 kbuild: clean up scripts/headers.sh

'drop' variable is unused.

'ppc' and 'sparc64' directories don't exist in arch/, and I think their headers can be well exported now, so just remove them.

Cc Sam Ravnborg <[email protected]>

------

scripts/headers.sh +0 -7
index d33426f..0308ecc 100755
@@ -15,19 +15,12 @@ do_command()
 	fi
 }
 
-# Do not try this architecture
-drop="generic um ppc sparc64 cris"
-
 archs=$(ls ${srctree}/arch)
 
 for arch in ${archs}; do
 	case ${arch} in
 	um)        # no userspace export
 		;;
-	ppc)       # headers exported by powerpc
-		;;
-	sparc64)   # headers exported by sparc
-		;;
 	cris)      # headers export are known broken
 		;;
 	*)
Applied
#2 lore raw

Re: [Patch] kbuild: clean up scripts/headers.sh

Quoted 6 lines · Amerigo Wang

'drop' variable is unused.

'ppc' and 'sparc64' directories don't exist in arch/, and I think their headers can be well exported now, so just remove them.

Applied,
Sam

#3 lore raw
In reply to Amerigo Wang

scripts/headers_check.pl sub check_include · line 73

Quoted 13 lines · Amerigo Wang
scripts/headers_check.pl +7 -3
-sub check_prototypes
+sub check_declarations
 {
-       if ($line =~ m/^\s*extern\b/) {
-               printf STDERR "$filename:$lineno: extern's make no sense in userspace\n";
+       if ($line =~m/^\s*extern\b/) {
+               if ($line =~ m/^\s*extern\b.*\(.*\)/) {
+                       printf STDERR "$filename:$lineno: extern's make no sense in userspace\n";
+               } else {
+                       printf STDERR "$filename:$lineno: exporting global variable to userspace is suspicious\n";
+               }
        }
 }

I don't think we really need that distinction here, the old text applies to both. But please find a way to get rid of the "extern's".

http://angryflower.com/bobsqu.gif

	Arnd <><
#4 lore raw
Quoted 11 lines · Arnd Bergmann
Quoted 9 lines · Amerigo Wang
scripts/headers_check.pl +5 -3
-sub check_prototypes
+sub check_declarations
 {
-       if ($line =~ m/^\s*extern\b/) {
-               printf STDERR "$filename:$lineno: extern's make no sense in userspace\n";
+       if ($line =~m/^\s*extern\b/) {
+               if ($line =~ m/^\s*extern\b.*\(.*\)/) {
+                       printf STDERR "$filename:$lineno: extern's make no sense in userspace\n";
+               } else {
Quoted 8 lines

scripts/headers_check.pl sub check_include · line 73

Quoted 5 lines
scripts/headers_check.pl +2 -0
+                       printf STDERR "$filename:$lineno: exporting global variable to userspace is suspicious\n";
+               }
        }
 }

I don't think we really need that distinction here, the old text applies to both.

Even for function declarations?

Quoted 3 lines

But please find a way to get rid of
the "extern's".

Here, that one has already been removed by other patch ...

#5 lore raw
Quoted 6 lines · Amerigo Wang
Quoted 4 lines

I don't think we really need that distinction here, the old text applies to both.

Even for function declarations?

Yes. Any use of 'extern' in a kernel header file by definition refers to a symbol that is defined in the kernel and therefore not accessibly in user space. It is the same problem for variables and functions, with the complication that leaving out the 'extern' statement on a function declaration will hide it from this check, while leaving it out on a variable declaration turns it into a definition.

	Arnd <><
#6 lore raw
In reply to Arnd Bergmann
Quoted 19 lines · Arnd Bergmann

scripts/headers_check.pl sub check_include · line 73

Quoted 13 lines · Amerigo Wang
scripts/headers_check.pl +7 -3
-sub check_prototypes
+sub check_declarations
 {
-       if ($line =~ m/^\s*extern\b/) {
-               printf STDERR "$filename:$lineno: extern's make no sense in userspace\n";
+       if ($line =~m/^\s*extern\b/) {
+               if ($line =~ m/^\s*extern\b.*\(.*\)/) {
+                       printf STDERR "$filename:$lineno: extern's make no sense in userspace\n";
+               } else {
+                       printf STDERR "$filename:$lineno: exporting global variable to userspace is suspicious\n";
+               }
        }
 }

I don't think we really need that distinction here, the old text applies to both. But please find a way to get rid of the "extern's".

Quoted 1 line

http://angryflower.com/bobsqu.gif

Hehe, made me smile :-)