netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] kernel-doc: fix struct_group_tagged() parsing
@ 2024-04-11  9:32 Alexander Lobakin
  2024-04-11 11:14 ` Przemek Kitszel
  2024-04-24 19:31 ` Jonathan Corbet
  0 siblings, 2 replies; 6+ messages in thread
From: Alexander Lobakin @ 2024-04-11  9:32 UTC (permalink / raw)
  To: Jonathan Corbet
  Cc: Kees Cook, Alexander Lobakin, Jakub Kicinski, Dan Williams,
	Gustavo A. R. Silva, Keith Packard,
	nex.sw.ncis.osdt.itp.upstreaming, linux-doc, netdev, linux-kernel

From: Kees Cook <keescook@chromium.org>

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.

Reported-by: Jakub Kicinski <kuba@kernel.org>
Closes: https://lore.kernel.org/netdev/20240405212513.0d189968@kernel.org
Fixes: 50d7bd38c3aa ("stddef: Introduce struct_group() helper macro")
Signed-off-by: Kees Cook <keescook@chromium.org>
Co-developed-by: Alexander Lobakin <aleksander.lobakin@intel.com>
Signed-off-by: Alexander Lobakin <aleksander.lobakin@intel.com>
---
 scripts/kernel-doc | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/scripts/kernel-doc b/scripts/kernel-doc
index 43a30f2de513..01ac8f794b30 100755
--- a/scripts/kernel-doc
+++ b/scripts/kernel-doc
@@ -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;
 
-- 
2.44.0


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [PATCH] kernel-doc: fix struct_group_tagged() parsing
  2024-04-11 11:14 ` Przemek Kitszel
@ 2024-04-11 11:14   ` Alexander Lobakin
  2024-04-11 11:48     ` Przemek Kitszel
  0 siblings, 1 reply; 6+ messages in thread
From: Alexander Lobakin @ 2024-04-11 11:14 UTC (permalink / raw)
  To: Przemek Kitszel
  Cc: Jonathan Corbet, Kees Cook, Jakub Kicinski, Dan Williams,
	Gustavo A. R. Silva, Keith Packard,
	nex.sw.ncis.osdt.itp.upstreaming, linux-doc, netdev, linux-kernel

From: Przemek Kitszel <przemyslaw.kitszel@intel.com>
Date: Thu, 11 Apr 2024 13:14:20 +0200

> On 4/11/24 11:32, Alexander Lobakin wrote:
>> From: Kees Cook <keescook@chromium.org>
>>
>> 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.
>>
>> Reported-by: Jakub Kicinski <kuba@kernel.org>
>> Closes: https://lore.kernel.org/netdev/20240405212513.0d189968@kernel.org
>> Fixes: 50d7bd38c3aa ("stddef: Introduce struct_group() helper macro")
>> Signed-off-by: Kees Cook <keescook@chromium.org>
>> Co-developed-by: Alexander Lobakin <aleksander.lobakin@intel.com>
>> Signed-off-by: Alexander Lobakin <aleksander.lobakin@intel.com>
>> ---
>>   scripts/kernel-doc | 3 ++-
>>   1 file changed, 2 insertions(+), 1 deletion(-)
>>
>> diff --git a/scripts/kernel-doc b/scripts/kernel-doc
>> index 43a30f2de513..01ac8f794b30 100755
>> --- a/scripts/kernel-doc
>> +++ b/scripts/kernel-doc
>> @@ -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.

Rather a subject for checkpatch, not kernel-doc?

> 
> This is clearly an improvement, so:
> Reviewed-by: Przemek Kitszel <przemyslaw.kitszel@intel.com>

Thanks!
Olek

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] kernel-doc: fix struct_group_tagged() parsing
  2024-04-11  9:32 [PATCH] kernel-doc: fix struct_group_tagged() parsing Alexander Lobakin
@ 2024-04-11 11:14 ` Przemek Kitszel
  2024-04-11 11:14   ` Alexander Lobakin
  2024-04-24 19:31 ` Jonathan Corbet
  1 sibling, 1 reply; 6+ messages in thread
From: Przemek Kitszel @ 2024-04-11 11:14 UTC (permalink / raw)
  To: Alexander Lobakin, Jonathan Corbet
  Cc: Kees Cook, Jakub Kicinski, Dan Williams, Gustavo A. R. Silva,
	Keith Packard, nex.sw.ncis.osdt.itp.upstreaming, linux-doc,
	netdev, linux-kernel

On 4/11/24 11:32, Alexander Lobakin wrote:
> From: Kees Cook <keescook@chromium.org>
> 
> 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.
> 
> Reported-by: Jakub Kicinski <kuba@kernel.org>
> Closes: https://lore.kernel.org/netdev/20240405212513.0d189968@kernel.org
> Fixes: 50d7bd38c3aa ("stddef: Introduce struct_group() helper macro")
> Signed-off-by: Kees Cook <keescook@chromium.org>
> Co-developed-by: Alexander Lobakin <aleksander.lobakin@intel.com>
> Signed-off-by: Alexander Lobakin <aleksander.lobakin@intel.com>
> ---
>   scripts/kernel-doc | 3 ++-
>   1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/scripts/kernel-doc b/scripts/kernel-doc
> index 43a30f2de513..01ac8f794b30 100755
> --- a/scripts/kernel-doc
> +++ b/scripts/kernel-doc
> @@ -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:
Reviewed-by: Przemek Kitszel <przemyslaw.kitszel@intel.com>

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] kernel-doc: fix struct_group_tagged() parsing
  2024-04-11 11:14   ` Alexander Lobakin
@ 2024-04-11 11:48     ` Przemek Kitszel
  0 siblings, 0 replies; 6+ messages in thread
From: Przemek Kitszel @ 2024-04-11 11:48 UTC (permalink / raw)
  To: Alexander Lobakin
  Cc: Jonathan Corbet, Kees Cook, Jakub Kicinski, Dan Williams,
	Gustavo A. R. Silva, Keith Packard,
	nex.sw.ncis.osdt.itp.upstreaming, linux-doc, netdev, linux-kernel

On 4/11/24 13:14, Alexander Lobakin wrote:
> From: Przemek Kitszel <przemyslaw.kitszel@intel.com>
> Date: Thu, 11 Apr 2024 13:14:20 +0200
> 
>> On 4/11/24 11:32, Alexander Lobakin wrote:
>>> From: Kees Cook <keescook@chromium.org>
>>>
>>> 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.
>>>
>>> Reported-by: Jakub Kicinski <kuba@kernel.org>
>>> Closes: https://lore.kernel.org/netdev/20240405212513.0d189968@kernel.org
>>> Fixes: 50d7bd38c3aa ("stddef: Introduce struct_group() helper macro")
>>> Signed-off-by: Kees Cook <keescook@chromium.org>
>>> Co-developed-by: Alexander Lobakin <aleksander.lobakin@intel.com>
>>> Signed-off-by: Alexander Lobakin <aleksander.lobakin@intel.com>
>>> ---
>>>    scripts/kernel-doc | 3 ++-
>>>    1 file changed, 2 insertions(+), 1 deletion(-)
>>>
>>> diff --git a/scripts/kernel-doc b/scripts/kernel-doc
>>> index 43a30f2de513..01ac8f794b30 100755
>>> --- a/scripts/kernel-doc
>>> +++ b/scripts/kernel-doc
>>> @@ -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.
> 
> 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)

> 
>>
>> This is clearly an improvement, so:
>> Reviewed-by: Przemek Kitszel <przemyslaw.kitszel@intel.com>
> 
> Thanks!
> Olek


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] kernel-doc: fix struct_group_tagged() parsing
  2024-04-11  9:32 [PATCH] kernel-doc: fix struct_group_tagged() parsing Alexander Lobakin
  2024-04-11 11:14 ` Przemek Kitszel
@ 2024-04-24 19:31 ` Jonathan Corbet
  2024-04-25  9:13   ` Alexander Lobakin
  1 sibling, 1 reply; 6+ messages in thread
From: Jonathan Corbet @ 2024-04-24 19:31 UTC (permalink / raw)
  To: Alexander Lobakin
  Cc: Kees Cook, Alexander Lobakin, Jakub Kicinski, Dan Williams,
	Gustavo A. R. Silva, Keith Packard,
	nex.sw.ncis.osdt.itp.upstreaming, linux-doc, netdev, linux-kernel

Alexander Lobakin <aleksander.lobakin@intel.com> writes:

> From: Kees Cook <keescook@chromium.org>
>
> 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.
>
> Reported-by: Jakub Kicinski <kuba@kernel.org>
> Closes: https://lore.kernel.org/netdev/20240405212513.0d189968@kernel.org
> Fixes: 50d7bd38c3aa ("stddef: Introduce struct_group() helper macro")
> Signed-off-by: Kees Cook <keescook@chromium.org>
> Co-developed-by: Alexander Lobakin <aleksander.lobakin@intel.com>
> Signed-off-by: Alexander Lobakin <aleksander.lobakin@intel.com>
> ---
>  scripts/kernel-doc | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)

So, in docs-next, applying this *adds* two warnings:

> ./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

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] kernel-doc: fix struct_group_tagged() parsing
  2024-04-24 19:31 ` Jonathan Corbet
@ 2024-04-25  9:13   ` Alexander Lobakin
  0 siblings, 0 replies; 6+ messages in thread
From: Alexander Lobakin @ 2024-04-25  9:13 UTC (permalink / raw)
  To: Jonathan Corbet
  Cc: Kees Cook, Jakub Kicinski, Dan Williams, Gustavo A. R. Silva,
	Keith Packard, nex.sw.ncis.osdt.itp.upstreaming, linux-doc,
	netdev, linux-kernel

From: Jonathan Corbet <corbet@lwn.net>
Date: Wed, 24 Apr 2024 13:31:14 -0600

> Alexander Lobakin <aleksander.lobakin@intel.com> writes:
> 
>> From: Kees Cook <keescook@chromium.org>
>>
>> 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.
>>
>> Reported-by: Jakub Kicinski <kuba@kernel.org>
>> Closes: https://lore.kernel.org/netdev/20240405212513.0d189968@kernel.org
>> Fixes: 50d7bd38c3aa ("stddef: Introduce struct_group() helper macro")
>> Signed-off-by: Kees Cook <keescook@chromium.org>
>> Co-developed-by: Alexander Lobakin <aleksander.lobakin@intel.com>
>> Signed-off-by: Alexander Lobakin <aleksander.lobakin@intel.com>
>> ---
>>  scripts/kernel-doc | 3 ++-
>>  1 file changed, 2 insertions(+), 1 deletion(-)
> 
> So, in docs-next, applying this *adds* two warnings:
> 
>> ./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!

> 
> Thanks,
> 
> jon

Olek

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2024-04-25  9:13 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-04-11  9:32 [PATCH] kernel-doc: fix struct_group_tagged() parsing Alexander Lobakin
2024-04-11 11:14 ` Przemek Kitszel
2024-04-11 11:14   ` Alexander Lobakin
2024-04-11 11:48     ` Przemek Kitszel
2024-04-24 19:31 ` Jonathan Corbet
2024-04-25  9:13   ` Alexander Lobakin

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).