History

kernel-doc: strip attributes even if they have an argument

An inline function can have an attribute, as in include/linux/log2.h, and kernel-doc handles this already for simple cases. However, some attributes have arguments (e.g. the "target" attribute). Handle those too. Furthermore, attributes could be at the beginning of a function declaration, before the return type. To correctly handle this case, you need to strip spaces after the attributes; otherwise, dump_function is left confused.

Paolo Bonzini committed 9 years ago

Commit b1aaa541 parent 02a4f4f1 file · +7 −1Browse files

Showing the changes to scripts (1 of 1 file). Show all

Unified · Split

scripts/kernel-doc+7−1
@@ -2506,7 +2506,13 @@ sub dump_function($$) { · 2505 unmodified lines
25062506 $prototype =~ s/__must_check +//;
25072507 $prototype =~ s/__weak +//;
25082508 my $define = $prototype =~ s/^#\s*define\s+//; #ak added
2509− $prototype =~ s/__attribute__\s*\(\([a-z,]*\)\)//;
2509+ $prototype =~ s/__attribute__\s*\(\(
2510+ (?:
2511+ [\w\s]++ # attribute name
2512+ (?:\([^)]*+\))? # attribute arguments
2513+ \s*+,? # optional comma at the end
2514+ )+
2515+ \)\)\s+//x;
25102516
25112517 # Yes, this truly is vile. We are looking for:
25122518 # 1. Return type (may be nothing if we're looking at a macro)

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t