aboutsummaryrefslogtreecommitdiffstats
path: root/scripts/kernel-doc
diff options
context:
space:
mode:
authorHoria Geanta <horia.geanta@freescale.com>2014-07-12 12:55:03 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2014-07-12 14:30:36 -0400
commitcbb4d3e6510b99522719c5ef0cd0482886a324c0 (patch)
tree862d33180349189935e7d37b56df90f3b984e3de /scripts/kernel-doc
parentc8c3f7d621c1dd803e92d4cdd59e2f730be71a2b (diff)
scripts/kernel-doc: handle object-like macros
Object-like macros are different than function-like macros: https://gcc.gnu.org/onlinedocs/cpp/Object-like-Macros.html https://gcc.gnu.org/onlinedocs/cpp/Function-like-Macros.html They are not parsed correctly, generating invalid intermediate files (xmls) for cases like: #define BIT_MASK (0xFF << BIT_SHIFT) where "OxFF <<" is considered to be parameter type. When parsing, we can differentiate beween these two types of macros by checking whether there is at least one whitespace b/w "#define" and first opening parenthesis. Signed-off-by: Horia Geanta <horia.geanta@freescale.com> Signed-off-by: Randy Dunlap <rdunlap@infradead.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'scripts/kernel-doc')
-rwxr-xr-xscripts/kernel-doc15
1 files changed, 12 insertions, 3 deletions
diff --git a/scripts/kernel-doc b/scripts/kernel-doc
index da058da413e7..16a07cfa4d34 100755
--- a/scripts/kernel-doc
+++ b/scripts/kernel-doc
@@ -2073,6 +2073,7 @@ sub check_return_section {
2073sub dump_function($$) { 2073sub dump_function($$) {
2074 my $prototype = shift; 2074 my $prototype = shift;
2075 my $file = shift; 2075 my $file = shift;
2076 my $noret = 0;
2076 2077
2077 $prototype =~ s/^static +//; 2078 $prototype =~ s/^static +//;
2078 $prototype =~ s/^extern +//; 2079 $prototype =~ s/^extern +//;
@@ -2086,7 +2087,7 @@ sub dump_function($$) {
2086 $prototype =~ s/__init_or_module +//; 2087 $prototype =~ s/__init_or_module +//;
2087 $prototype =~ s/__must_check +//; 2088 $prototype =~ s/__must_check +//;
2088 $prototype =~ s/__weak +//; 2089 $prototype =~ s/__weak +//;
2089 $prototype =~ s/^#\s*define\s+//; #ak added 2090 my $define = $prototype =~ s/^#\s*define\s+//; #ak added
2090 $prototype =~ s/__attribute__\s*\(\([a-z,]*\)\)//; 2091 $prototype =~ s/__attribute__\s*\(\([a-z,]*\)\)//;
2091 2092
2092 # Yes, this truly is vile. We are looking for: 2093 # Yes, this truly is vile. We are looking for:
@@ -2105,7 +2106,15 @@ sub dump_function($$) {
2105 # - atomic_set (macro) 2106 # - atomic_set (macro)
2106 # - pci_match_device, __copy_to_user (long return type) 2107 # - pci_match_device, __copy_to_user (long return type)
2107 2108
2108 if ($prototype =~ m/^()([a-zA-Z0-9_~:]+)\s*\(([^\(]*)\)/ || 2109 if ($define && $prototype =~ m/^()([a-zA-Z0-9_~:]+)\s+/) {
2110 # This is an object-like macro, it has no return type and no parameter
2111 # list.
2112 # Function-like macros are not allowed to have spaces between
2113 # declaration_name and opening parenthesis (notice the \s+).
2114 $return_type = $1;
2115 $declaration_name = $2;
2116 $noret = 1;
2117 } elsif ($prototype =~ m/^()([a-zA-Z0-9_~:]+)\s*\(([^\(]*)\)/ ||
2109 $prototype =~ m/^(\w+)\s+([a-zA-Z0-9_~:]+)\s*\(([^\(]*)\)/ || 2118 $prototype =~ m/^(\w+)\s+([a-zA-Z0-9_~:]+)\s*\(([^\(]*)\)/ ||
2110 $prototype =~ m/^(\w+\s*\*)\s*([a-zA-Z0-9_~:]+)\s*\(([^\(]*)\)/ || 2119 $prototype =~ m/^(\w+\s*\*)\s*([a-zA-Z0-9_~:]+)\s*\(([^\(]*)\)/ ||
2111 $prototype =~ m/^(\w+\s+\w+)\s+([a-zA-Z0-9_~:]+)\s*\(([^\(]*)\)/ || 2120 $prototype =~ m/^(\w+\s+\w+)\s+([a-zA-Z0-9_~:]+)\s*\(([^\(]*)\)/ ||
@@ -2140,7 +2149,7 @@ sub dump_function($$) {
2140 # of warnings goes sufficiently down, the check is only performed in 2149 # of warnings goes sufficiently down, the check is only performed in
2141 # verbose mode. 2150 # verbose mode.
2142 # TODO: always perform the check. 2151 # TODO: always perform the check.
2143 if ($verbose) { 2152 if ($verbose && !$noret) {
2144 check_return_section($file, $declaration_name, $return_type); 2153 check_return_section($file, $declaration_name, $return_type);
2145 } 2154 }
2146 2155