Skip to content

Commit 3d9bfb1

Browse files
Sakari AilusJonathan Corbet
authored andcommitted
scripts/kernel-doc: Fix struct and struct field attribute processing
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 <sakari.ailus@linux.intel.com> Signed-off-by: Jonathan Corbet <corbet@lwn.net>
1 parent 32ddfe8 commit 3d9bfb1

1 file changed

Lines changed: 4 additions & 3 deletions

File tree

‎scripts/kernel-doc‎

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1062,7 +1062,7 @@ sub dump_struct($$) {
10621062
my $x = shift;
10631063
my $file = shift;
10641064

1065-
if ($x =~ /(struct|union)\s+(\w+)\s*\{(.*)\}/) {
1065+
if ($x =~ /(struct|union)\s+(\w+)\s*\{(.*)\}(\s*(__packed|__aligned|__attribute__\s*\(\([a-z0-9,_\s\(\)]*\)\)))*/) {
10661066
my $decl_type = $1;
10671067
$declaration_name = $2;
10681068
my $members = $3;
@@ -1073,8 +1073,9 @@ sub dump_struct($$) {
10731073
# strip comments:
10741074
$members =~ s/\/\*.*?\*\///gos;
10751075
# strip attributes
1076-
$members =~ s/__attribute__\s*\(\([a-z,_\*\s\(\)]*\)\)//i;
1077-
$members =~ s/__aligned\s*\([^;]*\)//gos;
1076+
$members =~ s/\s*__attribute__\s*\(\([a-z0-9,_\*\s\(\)]*\)\)//gi;
1077+
$members =~ s/\s*__aligned\s*\([^;]*\)//gos;
1078+
$members =~ s/\s*__packed\s*//gos;
10781079
$members =~ s/\s*CRYPTO_MINALIGN_ATTR//gos;
10791080
# replace DECLARE_BITMAP
10801081
$members =~ s/DECLARE_BITMAP\s*\(([^,)]+),\s*([^,)]+)\)/unsigned long $1\[BITS_TO_LONGS($2)\]/gos;

0 commit comments

Comments
 (0)