Re: [PATCH 1/1] scripts/kernel-doc: Fix struct and struct field attribute processing

2018-11-25 Thread Jonathan Corbet
On Thu, 22 Nov 2018 13:06:04 +0200
Sakari Ailus  wrote:

> The kernel-doc attempts to clear the struct and struct member attributes
> from the API documentation it produces. It falls short of the job in the
> following respects:
> 
> - extra whitespaces are left where __attribute__((...)) was removed,
> 
> - only a single attribute is removed per struct,
> 
> - attributes (such as aligned) containing numbers were not removed,
> 
> - attributes are only cleared from struct fields, not structs themselves.
> 
> This patch addresses these issues by removing the attributes.
> 
> Signed-off-by: Sakari Ailus 

That does indeed seem to improve things.  I'm waiting for the pile of
regexes to fall over and hurt somebody, but I guess we're not there yet.
Applied, thanks.

jon


[PATCH 1/1] scripts/kernel-doc: Fix struct and struct field attribute processing

2018-11-22 Thread Sakari Ailus
The kernel-doc attempts to clear the struct and struct member attributes
from the API documentation it produces. It falls short of the job in the
following respects:

- extra whitespaces are left where __attribute__((...)) was removed,

- only a single attribute is removed per struct,

- attributes (such as aligned) containing numbers were not removed,

- attributes are only cleared from struct fields, not structs themselves.

This patch addresses these issues by removing the attributes.

Signed-off-by: Sakari Ailus 
---
 scripts/kernel-doc | 7 ---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/scripts/kernel-doc b/scripts/kernel-doc
index ffbe901a37b51..5a3945dc50358 100755
--- a/scripts/kernel-doc
+++ b/scripts/kernel-doc
@@ -1062,7 +1062,7 @@ sub dump_struct($$) {
 my $x = shift;
 my $file = shift;
 
-if ($x =~ /(struct|union)\s+(\w+)\s*\{(.*)\}/) {
+if ($x =~ 
/(struct|union)\s+(\w+)\s*\{(.*)\}(\s*(__packed|__aligned|__attribute__\s*\(\([a-z0-9,_\s\(\)]*\)\)))*/)
 {
my $decl_type = $1;
$declaration_name = $2;
my $members = $3;
@@ -1073,8 +1073,9 @@ sub dump_struct($$) {
# strip comments:
$members =~ s/\/\*.*?\*\///gos;
# strip attributes
-   $members =~ s/__attribute__\s*\(\([a-z,_\*\s\(\)]*\)\)//i;
-   $members =~ s/__aligned\s*\([^;]*\)//gos;
+   $members =~ s/\s*__attribute__\s*\(\([a-z0-9,_\*\s\(\)]*\)\)//gi;
+   $members =~ s/\s*__aligned\s*\([^;]*\)//gos;
+   $members =~ s/\s*__packed\s*//gos;
$members =~ s/\s*CRYPTO_MINALIGN_ATTR//gos;
# replace DECLARE_BITMAP
$members =~ s/DECLARE_BITMAP\s*\(([^,)]+),\s*([^,)]+)\)/unsigned long 
$1\[BITS_TO_LONGS($2)\]/gos;
-- 
2.11.0