Skip to content

Commit

Permalink
kernel-doc: strip attributes even if they have an argument
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Paolo Bonzini authored and Jonathan Corbet committed Jan 4, 2017
1 parent 02a4f4f commit b1aaa54
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion scripts/kernel-doc
Original file line number Diff line number Diff line change
Expand Up @@ -2506,7 +2506,13 @@ sub dump_function($$) {
$prototype =~ s/__must_check +//;
$prototype =~ s/__weak +//;
my $define = $prototype =~ s/^#\s*define\s+//; #ak added
$prototype =~ s/__attribute__\s*\(\([a-z,]*\)\)//;
$prototype =~ s/__attribute__\s*\(\(
(?:
[\w\s]++ # attribute name
(?:\([^)]*+\))? # attribute arguments
\s*+,? # optional comma at the end
)+
\)\)\s+//x;

# Yes, this truly is vile. We are looking for:
# 1. Return type (may be nothing if we're looking at a macro)
Expand Down

0 comments on commit b1aaa54

Please sign in to comment.