Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1549244 > unrolled thread

[PATCH 2/5] kernel-doc: strip attributes even if they have an argument

Started byPaolo Bonzini <pbonzini@redhat.com>
First post2017-01-02 16:30 +0100
Last post2017-01-02 16:30 +0100
Articles 1 — 1 participant

Back to article view | Back to linux.kernel

This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by below is the oldest one visible, not the original post.


Contents

  [PATCH 2/5] kernel-doc: strip attributes even if they have an argument Paolo Bonzini <pbonzini@redhat.com> - 2017-01-02 16:30 +0100

#1549244 — [PATCH 2/5] kernel-doc: strip attributes even if they have an argument

FromPaolo Bonzini <pbonzini@redhat.com>
Date2017-01-02 16:30 +0100
Subject[PATCH 2/5] kernel-doc: strip attributes even if they have an argument
Message-ID<sVcIF-jV-11@gated-at.bofh.it>
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>
---
 scripts/kernel-doc | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/scripts/kernel-doc b/scripts/kernel-doc
index c1ea91c2e497..265ea16cbe22 100755
--- a/scripts/kernel-doc
+++ b/scripts/kernel-doc
@@ -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)
-- 
2.9.3

[toc] | [standalone]


Back to top | Article view | linux.kernel


csiph-web