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.
Showing the changes to scripts (1 of 1 file). Show all
Unified · Split
| @@ -2506,7 +2506,13 @@ sub dump_function($$) { · 2505 unmodified lines | |||
| 2506 | $prototype =~ s/__must_check +//; | 2506 | $prototype =~ s/__must_check +//; |
| 2507 | $prototype =~ s/__weak +//; | 2507 | $prototype =~ s/__weak +//; |
| 2508 | my $define = $prototype =~ s/^#\s*define\s+//; #ak added | 2508 | 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; | ||
| 2510 | 2516 | ||
| 2511 | # Yes, this truly is vile. We are looking for: | 2517 | # Yes, this truly is vile. We are looking for: |
| 2512 | # 1. Return type (may be nothing if we're looking at a macro) | 2518 | # 1. Return type (may be nothing if we're looking at a macro) |