Skip to contentSkip to conversation

headers_check: better search for functions in headers

PATCH In review Alexander Shishkin 3 participants 4 messages Nov 30, 2010 – Dec 14, 2010

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 headers_check: better search for functions in headers

Some headers don't bother with "extern" in function prototypes, which results in said prototypes being unnoticed and exported to userland.

This patch slightly improves detection of such cases by checking for C type names as well in the beginning of a line.

CC Stephen Hemminger <[email protected]>
CC Andrew Morton <[email protected]>
CC Michal Marek <[email protected]>
CC WANG Cong <[email protected]>
---
 scripts/headers_check.pl |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
scripts/headers_check.pl +1 -1
index 50d6cfd..e0e25a1 100644
@@ -64,7 +64,7 @@ sub check_include
 
 sub check_declarations
 {
-	if ($line =~m/^\s*extern\b/) {
+	if ($line =~m/^(\s*extern|unsigned|char|short|int|long|void)\b/) {
 		printf STDERR "$filename:$lineno: " .
 		              "userspace cannot call function or variable " .
 		              "defined in the kernel\n";
Signature · 1 line
1.7.2.1.45.gb66c2
#1 lore raw
Quoted 22 lines · On Tue, 30 Nov 2010 18:21:59 +0200 Alexander Shishkin wrote:

Some headers don't bother with "extern" in function prototypes, which results in said prototypes being unnoticed and exported to userland.

This patch slightly improves detection of such cases by checking for C type names as well in the beginning of a line.

CC Stephen Hemminger <[email protected]>
CC Andrew Morton <[email protected]>
CC Michal Marek <[email protected]>
CC WANG Cong <[email protected]>
---
 scripts/headers_check.pl |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
scripts/headers_check.pl +0 -0
index 50d6cfd..e0e25a1 100644

scripts/headers_check.pl sub check_include · line 69

Quoted 7 lines
scripts/headers_check.pl +1 -1
@@ -64,7 +64,7 @@ sub check_include
 
 sub check_declarations
 {
-	if ($line =~m/^\s*extern\b/) {
+	if ($line =~m/^(\s*extern|unsigned|char|short|int|long|void)\b/) {
 		printf STDERR "$filename:$lineno: " .
 		              "userspace cannot call function or variable " .

s/call/reference/ ?

scripts/headers_check.pl sub check_include · line 70

Quoted 2 lines
scripts/headers_check.pl +0 -0
 		              "defined in the kernel\n";

---
~Randy
*** Remember to use Documentation/SubmitChecklist when testing your code ***

#2 lore raw
Quoted 25 lines · Randy Dunlap
Quoted 23 lines · On Tue, 30 Nov 2010 18:21:59 +0200 Alexander Shishkin wrote:

Some headers don't bother with "extern" in function prototypes, which results in said prototypes being unnoticed and exported to userland.

This patch slightly improves detection of such cases by checking for C type names as well in the beginning of a line.

CC Stephen Hemminger <[email protected]>
CC Andrew Morton <[email protected]>
CC Michal Marek <[email protected]>
CC WANG Cong <[email protected]>
---
 scripts/headers_check.pl |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
scripts/headers_check.pl +0 -0
index 50d6cfd..e0e25a1 100644
@@ -64,7 +64,7 @@ sub check_include
 
Quoted 8 lines

scripts/headers_check.pl sub check_include · line 69

Quoted 6 lines
scripts/headers_check.pl +1 -1
 sub check_declarations
 {
-	if ($line =~m/^\s*extern\b/) {
+	if ($line =~m/^(\s*extern|unsigned|char|short|int|long|void)\b/) {
 		printf STDERR "$filename:$lineno: " .
 		              "userspace cannot call function or variable " .

s/call/reference/ ?

Yes, there's a mistake there, but it's unrelated to this patch. Maybe goes in another patch?

Regards,
--
Alex

#3 lore raw
In reply to Alexander Shishkin
Quoted 6 lines · Alexander Shishkin

Some headers don't bother with "extern" in function prototypes, which results in said prototypes being unnoticed and exported to userland.

This patch slightly improves detection of such cases by checking for C type names as well in the beginning of a line.

Applied to kbuild-2.6.git#misc, thanks.

Michal