public inbox for linux-doc@vger.kernel.org
 help / color / mirror / Atom feed
* Re: [PATCH] scripts/kernel-doc: Detect mismatched inline member documentation tags
       [not found] <20260415215032.3398330-1-shuicheng.lin@intel.com>
@ 2026-04-28  8:12 ` Jani Nikula
  0 siblings, 0 replies; only message in thread
From: Jani Nikula @ 2026-04-28  8:12 UTC (permalink / raw)
  To: Shuicheng Lin, linux-kernel, intel-xe; +Cc: Shuicheng Lin, linux-doc

On Wed, 15 Apr 2026, Shuicheng Lin <shuicheng.lin@intel.com> wrote:
> Add validation in check_sections() to verify that inline member
> documentation tags (/** @member: description */) match actual struct/union
> member names. Previously, kernel-doc only validated section headers against
> the parameter list, but inline doc tags stored in parameterdescs were never
> cross-checked, allowing stale or mistyped member names to go undetected.
>
> The new check iterates over parameterdescs keys and warns about any that
> don't appear in the parameter list, catching issues like renamed struct
> members where the documentation tag was not updated to match.
>
> This catches real issues such as:
>   - xe_bo_types.h: @atomic_access (missing struct prefix, should be
>     @attr.atomic_access)
>   - xe_device_types.h: @usm.asid (member is actually asid_to_vm)
>
> Assisted-by: Claude:claude-opus-4.6
> Signed-off-by: Shuicheng Lin <shuicheng.lin@intel.com>

Cc: linux-doc@vger.kernel.org

> ---
>  tools/lib/python/kdoc/kdoc_parser.py | 25 +++++++++++++++++++++++++
>  1 file changed, 25 insertions(+)
>
> diff --git a/tools/lib/python/kdoc/kdoc_parser.py b/tools/lib/python/kdoc/kdoc_parser.py
> index ca00695b47b3..f21f06c0a9b0 100644
> --- a/tools/lib/python/kdoc/kdoc_parser.py
> +++ b/tools/lib/python/kdoc/kdoc_parser.py
> @@ -673,6 +673,31 @@ class KernelDoc:
>                  self.emit_msg(ln,
>                                f"Excess {dname} '{section}' description in '{decl_name}'")
>  
> +        #
> +        # Check that documented parameter names (from doc comments, including
> +        # inline ``/** @member: */`` tags) actually match real members in
> +        # the declaration.  This catches mismatched or stale kernel-doc
> +        # member tags that don't correspond to any actual struct/union
> +        # member or function parameter.
> +        #
> +        for param_name, desc in self.entry.parameterdescs.items():
> +            # Skip auto-generated entries from push_parameter()
> +            if desc == self.undescribed:
> +                continue
> +            if desc in ("no arguments", "anonymous\n", "variable arguments"):
> +                continue
> +            if param_name.startswith("{unnamed_"):
> +                continue
> +            if param_name in self.entry.parameterlist:
> +                continue
> +
> +            if decl_type == 'function':
> +                dname = f"{decl_type} parameter"
> +            else:
> +                dname = f"{decl_type} member"
> +            self.emit_msg(ln,
> +                          f"Excess {dname} '{param_name}' description in '{decl_name}'")
> +
>      def check_return_section(self, ln, declaration_name, return_type):
>          """
>          If the function doesn't return void, warns about the lack of a

-- 
Jani Nikula, Intel

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2026-04-28  8:12 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
     [not found] <20260415215032.3398330-1-shuicheng.lin@intel.com>
2026-04-28  8:12 ` [PATCH] scripts/kernel-doc: Detect mismatched inline member documentation tags Jani Nikula

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