]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
docs: kernel-doc: python: strip __counted_by_ptr macro
authorTudor Ambarus <tudor.ambarus@linaro.org>
Wed, 6 May 2026 11:04:12 +0000 (11:04 +0000)
committerJonathan Corbet <corbet@lwn.net>
Fri, 15 May 2026 14:11:36 +0000 (08:11 -0600)
The `__counted_by_ptr` macro was recently introduced [1] to extend
bounds checking semantics to standard dynamically allocated pointers.

However, the new Python implementation of kernel-doc does not currently
recognize it as a compiler attribute. When kernel-doc encounters a
struct member annotated with this macro, it fails to parse the variable
name correctly, resulting in false-positive warnings like:

  Warning: ... struct member '__counted_by_ptr(cmdcnt' not described

Add `__counted_by_ptr` to the `struct_xforms` regex list so it gets
safely stripped out during the parsing phase, mirroring the existing
behavior for `__counted_by`. Update the corresponding unit tests.

Link: https://git.kernel.org/torvalds/c/150a04d817d8
Signed-off-by: Tudor Ambarus <tudor.ambarus@linaro.org>
Reviewed-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
Reviewed-by: Kees Cook <kees@kernel.org>
Acked-by: Randy Dunlap <rdunlap@infradead.org>
Tested-by: Randy Dunlap <rdunlap@infradead.org>
Signed-off-by: Jonathan Corbet <corbet@lwn.net>
Message-ID: <20260506-kdoc-__counted_by_ptr-v1-1-70763486871f@linaro.org>

tools/lib/python/kdoc/xforms_lists.py
tools/unittests/test_cmatch.py

index 496c521882739d7020eeaf868192f03a49e5fd28..8753dd539f23be3cf0d4900cda80aa2629226ef3 100644 (file)
@@ -29,6 +29,7 @@ class CTransforms:
         (CMatch("__aligned"), ""),
         (CMatch("__counted_by"), ""),
         (CMatch("__counted_by_(le|be)"), ""),
+        (CMatch("__counted_by_ptr"), ""),
         (CMatch("__guarded_by"), ""),
         (CMatch("__pt_guarded_by"), ""),
         (CMatch("__packed"), ""),
index 7b996f83784d08d8a8ccb9d41797ded9d4196368..109141cd2ab8d63a1ce8a48951b8a1cfb976185b 100755 (executable)
@@ -320,6 +320,7 @@ class TestSubWithLocalXforms(TestCaseDiff):
         (CMatch('__aligned'), ' '),
         (CMatch('__counted_by'), ' '),
         (CMatch('__counted_by_(le|be)'), ' '),
+        (CMatch('__counted_by_ptr'), ' '),
         (CMatch('__guarded_by'), ' '),
         (CMatch('__pt_guarded_by'), ' '),