Skip to content

Commit b1aaa54

Browse files
bonziniJonathan Corbet
authored andcommitted
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. Signed-off-by: Paolo Bonzini <pbonzini@redhat.com> Acked-by: Jani Nikula <jani.nikula@intel.com> Signed-off-by: Jonathan Corbet <corbet@lwn.net>
1 parent 02a4f4f commit b1aaa54

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

scripts/kernel-doc

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2506,7 +2506,13 @@ sub dump_function($$) {
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)

0 commit comments

Comments
 (0)