kernel-doc: fix struct_group_tagged() parsing
Subsystems (3)
PATCH 1/1 kernel-doc: fix struct_group_tagged() parsing
From: Kees Cook <[email protected]>
kernel-doc emits a warning on struct_group_tagged() if you describe your struct group member:
include/net/libeth/rx.h:69: warning: Excess struct member 'fp' description in 'libeth_fq'
The code:
/**
* struct libeth_fq - structure representing a buffer queue
* @fp: hotpath part of the structure
* @pp: &page_pool for buffer management
[...]
*/
struct libeth_fq {
struct_group_tagged(libeth_fq_fp, fp,
struct page_pool *pp;
[...]
);When a struct_group_tagged() is encountered, we need to build a struct TAG NAME; from it, so that it will be treated as a valid embedded struct.
Decouple the regex and do the replacement there. As far as I can see, this doesn't produce any new warnings on the current mainline tree.
--- scripts/kernel-doc | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
scripts/kernel-doc +2 -1
@@ -1152,7 +1152,8 @@ sub dump_struct($$) { # - first eat non-declaration parameters and rewrite for final match # - then remove macro, outer parens, and trailing semicolon $members =~ s/\bstruct_group\s*\(([^,]*,)/STRUCT_GROUP(/gos; - $members =~ s/\bstruct_group_(attr|tagged)\s*\(([^,]*,){2}/STRUCT_GROUP(/gos; + $members =~ s/\bstruct_group_attr\s*\(([^,]*,){2}/STRUCT_GROUP(/gos; + $members =~ s/\bstruct_group_tagged\s*\(([^,]*),([^,]*),/struct $1 $2; STRUCT_GROUP(/gos; $members =~ s/\b__struct_group\s*\(([^,]*,){3}/STRUCT_GROUP(/gos; $members =~ s/\bSTRUCT_GROUP(\(((?:(?>[^)(]+)|(?1))*)\))[^;]*;/$2/gos;
Signature · 1 line
2.44.0
Quoted 42 lines · Alexander Lobakin
From: Kees Cook <[email protected]>
kernel-doc emits a warning on
struct_group_tagged()if you describe your struct group member:
include/net/libeth/rx.h:69: warning: Excess struct member 'fp' description in 'libeth_fq'The code:
/**
* structlibeth_fq- structure representing a buffer queue
* @fp: hotpath part of the structure
* @pp:&page_poolfor buffer management
[...]
*/struct libeth_fq { struct_group_tagged(libeth_fq_fp, fp, struct page_pool *pp; [...] );When a
struct_group_tagged()is encountered, we need to build astruct TAG NAME;from it, so that it will be treated as a valid embedded struct.
Decouple the regex and do the replacement there. As far as I can see, this doesn't produce any new warnings on the current mainline tree.Reported-by Jakub Kicinski <[email protected]>Fixes 50d7bd38c3aa ("stddef: Introduce struct_group() helper macro")Signed-off-by Kees Cook <[email protected]>Co-developed-by Alexander Lobakin <[email protected]>Signed-off-by Alexander Lobakin <[email protected]>--- scripts/kernel-doc | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)scripts/kernel-doc +0
-0
scripts/kernel-doc sub dump_struct($$) { · line 1159
Quoted 9 lines
scripts/kernel-doc +2
-1@@ -1152,7 +1152,8 @@ sub dump_struct($$) { # - first eat non-declaration parameters and rewrite for final match # - then remove macro, outer parens, and trailing semicolon $members =~ s/\bstruct_group\s*\(([^,]*,)/STRUCT_GROUP(/gos; - $members =~ s/\bstruct_group_(attr|tagged)\s*\(([^,]*,){2}/STRUCT_GROUP(/gos; + $members =~ s/\bstruct_group_attr\s*\(([^,]*,){2}/STRUCT_GROUP(/gos; + $members =~ s/\bstruct_group_tagged\s*\(([^,]*),([^,]*),/struct $1 $2; STRUCT_GROUP(/gos; $members =~ s/\b__struct_group\s*\(([^,]*,){3}/STRUCT_GROUP(/gos; $members =~ s/\bSTRUCT_GROUP(\(((?:(?>[^)(]+)|(?1))*)\))[^;]*;/$2/gos;
I would complain on code that matches [^,]* part with 0 characters, meaning no tag for struct_group_tagged(), or no attrs for struct_group_attrs(). In such cases simpler struct_group() call should be suggested. However, that issue was presented prior to your patch.
This is clearly an improvement, so:
From: Przemek Kitszel <[email protected]>
Date: Thu, 11 Apr 2024 13:14:20 +0200
Quoted 57 lines · Alexander Lobakin
Quoted 56 lines
From: Kees Cook <[email protected]>
kernel-doc emits a warning on
struct_group_tagged()if you describe your struct group member:
include/net/libeth/rx.h:69: warning: Excess struct member 'fp' description in 'libeth_fq'The code:
/**
* structlibeth_fq- structure representing a buffer queue
* @fp: hotpath part of the structure
* @pp:&page_poolfor buffer management
[...]
*/
structlibeth_fq{ struct_group_tagged(libeth_fq_fp, fp,
struct page_pool *pp;
[...]
);When a
struct_group_tagged()is encountered, we need to build astruct TAG NAME;from it, so that it will be treated as a valid embedded struct.
Decouple the regex and do the replacement there. As far as I can see, this doesn't produce any new warnings on the current mainline tree.Reported-by Jakub Kicinski <[email protected]>Fixes 50d7bd38c3aa ("stddef: Introduce struct_group() helper macro")Signed-off-by Kees Cook <[email protected]>Co-developed-by Alexander Lobakin <[email protected]>Signed-off-by Alexander Lobakin <[email protected]>---
scripts/kernel-doc| 3 ++-1 file changed, 2 insertions(+), 1 deletion(-)scripts/kernel-doc +0
-0@@ -1152,7 +1152,8 @@ sub dump_struct($$) { # - first eat non-declaration parameters and rewrite forfinal match
# - then remove macro, outer parens, and trailing semicolon $members =~ s/\bstruct_group\s*\(([^,]*,)/STRUCT_GROUP(/gos; - $members =~ s/\bstruct_group_(attr|tagged)\s*\(([^,]*,){2}/STRUCT_GROUP(/gos; + $members =~ s/\bstruct_group_attr\s*\(([^,]*,){2}/STRUCT_GROUP(/gos;
+ $members =~ s/\bstruct_group_tagged\s*\(([^,]*),([^,]*),/struct $1 $2; STRUCT_GROUP(/gos;
$members =~ s/\b__struct_group\s*\(([^,]*,){3}/STRUCT_GROUP(/gos;
Quoted 8 lines
Quoted 3 lines
$members =~ s/\bSTRUCT_GROUP(\(((?:(?>[^)(]+)|(?1))*)\))[^;]*;/$2/gos;
I would complain on code that matches
[^,]*part with 0 characters, meaning no tag forstruct_group_tagged(), or no attrs forstruct_group_attrs(). In such cases simplerstruct_group()call should be suggested. However, that issue was presented prior to your patch.
Rather a subject for checkpatch, not kernel-doc?
Quoted 3 lines
This is clearly an improvement, so:
Reviewed-by Przemek Kitszel <[email protected]>
Thanks!
Olek
Quoted 69 lines · Alexander Lobakin
From: Przemek Kitszel <[email protected]>
Date: Thu, 11 Apr 2024 13:14:20 +0200Quoted 57 lines · Alexander Lobakin
Quoted 56 lines
From: Kees Cook <[email protected]>
kernel-doc emits a warning on
struct_group_tagged()if you describe your struct group member:
include/net/libeth/rx.h:69: warning: Excess struct member 'fp' description in 'libeth_fq'The code:
/**
* structlibeth_fq- structure representing a buffer queue
* @fp: hotpath part of the structure
* @pp:&page_poolfor buffer management
[...]
*/
structlibeth_fq{
struct_group_tagged(libeth_fq_fp, fp,
struct page_pool *pp;
[...]
);When a
struct_group_tagged()is encountered, we need to build astruct TAG NAME;from it, so that it will be treated as a valid embedded struct.
Decouple the regex and do the replacement there. As far as I can see, this doesn't produce any new warnings on the current mainline tree.Reported-by Jakub Kicinski <[email protected]>Fixes 50d7bd38c3aa ("stddef: Introduce struct_group() helper macro")Signed-off-by Kees Cook <[email protected]>Co-developed-by Alexander Lobakin <[email protected]>Signed-off-by Alexander Lobakin <[email protected]>--- scripts/kernel-doc | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)scripts/kernel-doc +0
-0@@ -1152,7 +1152,8 @@ sub dump_struct($$) { # - first eat non-declaration parameters and rewrite forfinal match
# - then remove macro, outer parens, and trailing semicolon $members =~ s/\bstruct_group\s*\(([^,]*,)/STRUCT_GROUP(/gos;
- $members =~ s/\bstruct_group_(attr|tagged)\s*\(([^,]*,){2}/STRUCT_GROUP(/gos; + $members =~ s/\bstruct_group_attr\s*\(([^,]*,){2}/STRUCT_GROUP(/gos;
+ $members =~ s/\bstruct_group_tagged\s*\(([^,]*),([^,]*),/struct $1 $2; STRUCT_GROUP(/gos;
$members =~
s/\b__struct_group\s*\(([^,]*,){3}/STRUCT_GROUP(/gos;Quoted 8 lines
Quoted 3 lines
$members =~
s/\bSTRUCT_GROUP(\(((?:(?>[^)(]+)|(?1))*)\))[^;]*;/$2/gos;I would complain on code that matches
[^,]*part with 0 characters, meaning no tag forstruct_group_tagged(), or no attrs forstruct_group_attrs(). In such cases simplerstruct_group()call should be suggested. However, that issue was presented prior to your patch.
Quoted 1 line
Rather a subject for checkpatch, not kernel-doc?
Good point.
But that reminds me that getting patches accepted into checkpatch is not possible for mere mortals :/ (exaggerating here, but just a little)
Quoted 7 lines
Quoted 4 lines
This is clearly an improvement, so:
Reviewed-by Przemek Kitszel <[email protected]>Thanks!
Olek
Jonathan Corbet
maintainerQuoted 33 lines · Alexander Lobakin
From: Kees Cook <[email protected]>
kernel-doc emits a warning on
struct_group_tagged()if you describe your struct group member:
include/net/libeth/rx.h:69: warning: Excess struct member 'fp' description in 'libeth_fq'The code:
/**
* structlibeth_fq- structure representing a buffer queue
* @fp: hotpath part of the structure
* @pp:&page_poolfor buffer management
[...]
*/struct libeth_fq { struct_group_tagged(libeth_fq_fp, fp, struct page_pool *pp; [...] );When a
struct_group_tagged()is encountered, we need to build astruct TAG NAME;from it, so that it will be treated as a valid embedded struct.
Decouple the regex and do the replacement there. As far as I can see, this doesn't produce any new warnings on the current mainline tree.Reported-by Jakub Kicinski <[email protected]>Fixes 50d7bd38c3aa ("stddef: Introduce struct_group() helper macro")Signed-off-by Kees Cook <[email protected]>Co-developed-by Alexander Lobakin <[email protected]>Signed-off-by Alexander Lobakin <[email protected]>
Quoted 3 lines
--- scripts/kernel-doc | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
So, in docs-next, applying this *adds* two warnings:
Quoted 2 lines
./include/net/page_pool/types.h:77: warning: Function parameter or struct member 'fast' not described in 'page_pool_params'./include/net/page_pool/types.h:77: warning: Function parameter or struct member 'slow' not described in 'page_pool_params'
In truth, the warnings look correct. I guess I'll leave this applied, but perhaps a fix for the warnings should go into the net tree?
Thanks,
jon
From: Jonathan Corbet <[email protected]>
Date: Wed, 24 Apr 2024 13:31:14 -0600
Quoted 39 lines
Quoted 33 lines · Alexander Lobakin
From: Kees Cook <[email protected]>
kernel-doc emits a warning on
struct_group_tagged()if you describe your struct group member:
include/net/libeth/rx.h:69: warning: Excess struct member 'fp' description in 'libeth_fq'The code:
/**
* structlibeth_fq- structure representing a buffer queue
* @fp: hotpath part of the structure
* @pp:&page_poolfor buffer management
[...]
*/struct libeth_fq { struct_group_tagged(libeth_fq_fp, fp, struct page_pool *pp; [...] );When a
struct_group_tagged()is encountered, we need to build astruct TAG NAME;from it, so that it will be treated as a valid embedded struct.
Decouple the regex and do the replacement there. As far as I can see, this doesn't produce any new warnings on the current mainline tree.Reported-by Jakub Kicinski <[email protected]>Fixes 50d7bd38c3aa ("stddef: Introduce struct_group() helper macro")Signed-off-by Kees Cook <[email protected]>Co-developed-by Alexander Lobakin <[email protected]>Signed-off-by Alexander Lobakin <[email protected]>Quoted 3 lines
--- scripts/kernel-doc | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
Quoted 7 lines
So, in docs-next, applying this *adds* two warnings:
Quoted 2 lines
./include/net/page_pool/types.h:77: warning: Function parameter or struct member 'fast' not described in 'page_pool_params'./include/net/page_pool/types.h:77: warning: Function parameter or struct member 'slow' not described in 'page_pool_params'In truth, the warnings look correct. I guess I'll leave this applied, but perhaps a fix for the warnings should go into the net tree?
Sure, we'll fix this. Thanks!
Quoted 4 lines
Thanks,
jon
Olek