Intel-Wired-Lan Archive on lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v4] docs: kdoc: fix struct_group_tagged() parsing regression
@ 2026-12-03 21:16 Omokefe Emmanuel Onanaroghene
  2026-12-04  2:41 ` Bagas Sanjaya
  2026-12-04 21:16 ` sashiko-bot
  0 siblings, 2 replies; 3+ messages in thread
From: Omokefe Emmanuel Onanaroghene @ 2026-12-03 21:16 UTC (permalink / raw)
  To: linux-doc, linux-kernel, netdev, intel-wired-lan
  Cc: corbet, skhan, rdunlap, mchehab, aleksander.lobakin,
	aleksandr.loktionov, tudor.ambarus, bvanassche, takano32,
	Omokefe Emmanuel Onanaroghene

kernel-doc reports struct_group_tagged() members as excess because
the macro transformation rewrites it to an anonymous struct and drops their
member names.

Keep the tag and member name when transforming struct_group_tagged(). The
nested members are then recorded as names such as fast.order; accept the
existing unqualified @order documentation tag during validation.

Add a regression test based on struct page_pool_params.

Reported-by: Randy Dunlap <rdunlap@infradead.org>
Link: https://lore.kernel.org/all/0cf8ea5f-418f-45f0-907c-3d1ed4f03e9f@infradead.org/
Fixes: 2f07ddbd5793 ("docs: xforms_lists: better evaluate struct_group macros")
Tested-by: TAKANO Mitsuhiro <takano32@gmail.com>
Signed-off-by: Omokefe Emmanuel Onanaroghene <emmaonana18@gmail.com>
---
v4:
  - Rebase onto docs-next; drop the Assisted-by tag.
v3: https://lore.kernel.org/all/20261129114700.12614-1-emmaonana18@gmail.com/
  - Previous posting.
 tools/lib/python/kdoc/kdoc_parser.py  |  4 ++-
 tools/lib/python/kdoc/xforms_lists.py |  2 +-
 tools/unittests/test_kdoc_parser.py   | 37 +++++++++++++++++++++++++++
 3 files changed, 41 insertions(+), 2 deletions(-)

diff --git a/tools/lib/python/kdoc/kdoc_parser.py b/tools/lib/python/kdoc/kdoc_parser.py
index ef5879b05308b..4bc36fba5fa8a 100644
--- a/tools/lib/python/kdoc/kdoc_parser.py
+++ b/tools/lib/python/kdoc/kdoc_parser.py
@@ -637,7 +637,9 @@ class KernelDoc:
                 continue
             if param_name.startswith("{unnamed_"):
                 continue
-            if param_name in self.entry.parameterlist:
+            if param_name in self.entry.parameterlist or \
+               any(actual.endswith('.' + param_name)
+                   for actual in self.entry.parameterlist):
                 continue
 
             hint = self.get_suggestions_hint(param_name, self.entry.parameterlist)
diff --git a/tools/lib/python/kdoc/xforms_lists.py b/tools/lib/python/kdoc/xforms_lists.py
index fa380055191c5..52415ef211538 100644
--- a/tools/lib/python/kdoc/xforms_lists.py
+++ b/tools/lib/python/kdoc/xforms_lists.py
@@ -62,7 +62,7 @@ class CTransforms:
         #
         (CMatch("struct_group"), r"struct { \2+ };"),
         (CMatch("struct_group_attr"), r"struct { \3+ };"),
-        (CMatch("struct_group_tagged"), r"struct { \3+ };"),
+        (CMatch("struct_group_tagged"), r"struct \1 { \3+ } \2;"),
         (CMatch("__struct_group"), r"struct { \4+ };"),
         (CMatch("context_lock_struct"), r"struct \1"),
     ]
diff --git a/tools/unittests/test_kdoc_parser.py b/tools/unittests/test_kdoc_parser.py
index 709455a4b39c7..21462a1c391b6 100755
--- a/tools/unittests/test_kdoc_parser.py
+++ b/tools/unittests/test_kdoc_parser.py
@@ -567,6 +567,43 @@ class TestContextLockStruct(GenerateKdocItem):
         self.assertEqual(entries[0].name, "debugfs_cancellation")
         self.assertEqual(entries[0].warnings, [])
 
+
+class TestStructGroupTagged(GenerateKdocItem):
+    def test_nested_struct_group_tagged_members(self):
+        source = """
+            /**
+             * struct page_pool_params - page pool parameters
+             * @fast: Fast path parameters.
+             * @order: Order of pages.
+             * @pool_size: Number of pages.
+             * @slow: Slow path parameters.
+             * @netdev: Net device pointer.
+             * @queue_idx: Queue index.
+             * @flags: Flags.
+             */
+            struct page_pool_params {
+                struct_group_tagged(page_pool_params_fast, fast,
+                                    unsigned int order;
+                                    unsigned int pool_size;
+                );
+                struct_group_tagged(page_pool_params_slow, slow,
+                                    struct net_device *netdev;
+                                    unsigned int queue_idx;
+                                    unsigned int flags;
+                );
+            };
+        """
+
+        kernel_doc = KernelDoc(self.config, "test.c", self.xforms)
+        patcher = patch('builtins.open', new_callable=mock_open,
+                        read_data=dedent(source))
+        with patcher:
+            _, entries = kernel_doc.parse_kdoc()
+
+        self.assertEqual(len(entries), 1)
+        self.assertEqual(entries[0].warnings, [])
+
+
 class TestUnusedWarnings(GenerateKdocItem):
     """
     Test that the parser itself only emits warnings of discarded entries.
-- 
2.43.0


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

* Re: [PATCH v4] docs: kdoc: fix struct_group_tagged() parsing regression
  2026-12-03 21:16 [PATCH v4] docs: kdoc: fix struct_group_tagged() parsing regression Omokefe Emmanuel Onanaroghene
@ 2026-12-04  2:41 ` Bagas Sanjaya
  2026-12-04 21:16 ` sashiko-bot
  1 sibling, 0 replies; 3+ messages in thread
From: Bagas Sanjaya @ 2026-12-04  2:41 UTC (permalink / raw)
  To: Omokefe Emmanuel Onanaroghene, linux-doc, linux-kernel, netdev,
	intel-wired-lan
  Cc: corbet, skhan, rdunlap, mchehab, aleksander.lobakin,
	aleksandr.loktionov, tudor.ambarus, bvanassche, takano32

[-- Attachment #1: Type: text/plain, Size: 609 bytes --]

On Thu, Dec 03, 2026 at 10:16:16PM +0100, Omokefe Emmanuel Onanaroghene wrote:
> kernel-doc reports struct_group_tagged() members as excess because
> the macro transformation rewrites it to an anonymous struct and drops their
> member names.
> 
> Keep the tag and member name when transforming struct_group_tagged(). The
> nested members are then recorded as names such as fast.order; accept the
> existing unqualified @order documentation tag during validation.

Works for me, thanks!

Tested-by: Bagas Sanjaya <bagasdotme@gmail.com>

-- 
An old man doll... just what I always wanted! - Clara

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 228 bytes --]

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

* Re: [PATCH v4] docs: kdoc: fix struct_group_tagged() parsing regression
  2026-12-03 21:16 [PATCH v4] docs: kdoc: fix struct_group_tagged() parsing regression Omokefe Emmanuel Onanaroghene
  2026-12-04  2:41 ` Bagas Sanjaya
@ 2026-12-04 21:16 ` sashiko-bot
  1 sibling, 0 replies; 3+ messages in thread
From: sashiko-bot @ 2026-12-04 21:16 UTC (permalink / raw)
  To: Omokefe Emmanuel Onanaroghene, intel-wired-lan

Thank you for your contribution! Sashiko AI review found 3 potential
issues to consider:
- [Medium] docs: kdoc: struct_group_tagged() member descriptions dropped
  from output
- [Medium] docs: kdoc: check_sections() hides missing prefixes on all
  nested structs
- [Low] docs: kdoc: struct_group_tagged() hides undocumented member
  warnings
--

commit d7d797016b310e8dcc282c86cfe920ed0b31eda8
Author: Omokefe Emmanuel Onanaroghene <emmaonana18@gmail.com>

docs: kdoc: fix struct_group_tagged() parsing regression

This commit updates the struct_group_tagged() kernel-doc transform to
preserve the struct tag and member name, relaxes check_sections() to
accept unqualified tags matching dotted member suffixes, and adds a unit
test based on struct page_pool_params.

Link: https://lore.kernel.org/all/0cf8ea5f-418f-45f0-907c-3d1ed4f03e9f@infradead.org/

> diff --git a/tools/lib/python/kdoc/kdoc_parser.py b/tools/lib/python/kdoc/kdoc_parser.py
> index ef5879b05308b..4bc36fba5fa8a 100644
> --- a/tools/lib/python/kdoc/kdoc_parser.py
> +++ b/tools/lib/python/kdoc/kdoc_parser.py
> @@ -637,7 +637,9 @@ class KernelDoc:
>                  continue
>              if param_name.startswith("{unnamed_"):
>                  continue
> -            if param_name in self.entry.parameterlist:
> +            if param_name in self.entry.parameterlist or \
> +               any(actual.endswith('.' + param_name)
> +                   for actual in self.entry.parameterlist):
>                  continue
>  
>              hint = self.get_suggestions_hint(param_name, self.entry.parameterlist)

[Severity: Medium]
As reported by TAKANO Mitsuhiro on v2 [1], does this endswith() check
suppress missing-prefix warnings for all nested structs and unions, not
just struct_group_tagged()?

This regresses commit 46d9c16115cf ("scripts/kernel-doc: Detect
mismatched inline member documentation tags"): writing @atomic_access
instead of @attr.atomic_access on an ordinary nested struct like
struct xe_bo no longer warns, while out_struct() drops the description.

It also makes the submember_exact hint path in get_suggestions_hint()
unreachable from check_sections().

> diff --git a/tools/lib/python/kdoc/xforms_lists.py b/tools/lib/python/kdoc/xforms_lists.py
> index fa380055191c5..52415ef211538 100644
> --- a/tools/lib/python/kdoc/xforms_lists.py
> +++ b/tools/lib/python/kdoc/xforms_lists.py
> @@ -62,7 +62,7 @@ class CTransforms:
>          #
>          (CMatch("struct_group"), r"struct { \2+ };"),
>          (CMatch("struct_group_attr"), r"struct { \3+ };"),
> -        (CMatch("struct_group_tagged"), r"struct { \3+ };"),
> +        (CMatch("struct_group_tagged"), r"struct \1 { \3+ } \2;"),
>          (CMatch("__struct_group"), r"struct { \4+ };"),
>          (CMatch("context_lock_struct"), r"struct \1"),
>      ]

[Severity: Medium]
As reported by TAKANO Mitsuhiro on v2 [1], does rewriting
struct_group_tagged() as a named nested struct drop all inner member
descriptions from the rendered documentation?

rewrite_struct_members() prefixes inner members with the group name
(such as fast.order), so push_parameter() misses the unqualified @order
in parameterdescs and marks fast.order undescribed.  check_sections()
silences the warning without migrating the description.

RestFormat.out_struct() and ManFormat.out_struct() then skip those
undescribed entries, omitting 24 documented member descriptions across
the four struct_group_tagged() structs in the tree (including
struct page_pool_params).

The new TestStructGroupTagged test only asserts that warnings is empty,
so it does not catch the dropped descriptions.

[Severity: Low]
Will prefixing inner struct_group_tagged() members also hide genuine
missing-description warnings?

KernelDoc.push_parameter() only warns about undocumented members when
"." not in param, so dotted names like fast.order now bypass the
"not described" check if a member inside struct_group_tagged() lacks
kernel-doc.

[1] https://lore.kernel.org/r/179527340172.2367332.3292077208678045371@gmail.com

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20261203211616.10272-1-emmaonana18@gmail.com?part=1

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

end of thread, other threads:[~2026-12-04 21:16 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-12-03 21:16 [PATCH v4] docs: kdoc: fix struct_group_tagged() parsing regression Omokefe Emmanuel Onanaroghene
2026-12-04  2:41 ` Bagas Sanjaya
2026-12-04 21:16 ` sashiko-bot

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox