Skip to contentSkip to conversation

docs: kernel-doc: python: strip __counted_by_ptr macro

PATCH Applied Tudor Ambarus 5 participants 5 messages May 6 – May 15

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 docs: kernel-doc: python: strip __counted_by_ptr macro

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.

---
 tools/lib/python/kdoc/xforms_lists.py | 1 +
 tools/unittests/test_cmatch.py        | 1 +
 2 files changed, 2 insertions(+)
tools/lib/python/kdoc/xforms_lists.py +1 -0
index f6ea9efb11ae..118156ea8cd2 100644
@@ -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"), ""),
tools/unittests/test_cmatch.py +1 -0
index 7b996f83784d..109141cd2ab8 100755
@@ -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'), ' '),
 

---
base-commit: 254f49634ee16a731174d2ae34bc50bd5f45e731
change-id: 20260506-kdoc-__counted_by_ptr-1e206f3f1dc1

Best regards,

Signature · 1 line
Tudor Ambarus <[email protected]>
reviewer Acked-by Tested-by on v1 1/1
#1 lore raw
Quoted 8 lines · Tudor Ambarus

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:

Quoted 8 lines

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.

Thanks.

Quoted 35 lines
---
 tools/lib/python/kdoc/xforms_lists.py | 1 +
 tools/unittests/test_cmatch.py        | 1 +
 2 files changed, 2 insertions(+)
tools/lib/python/kdoc/xforms_lists.py +1 -0
index f6ea9efb11ae..118156ea8cd2 100644
@@ -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"), ""),
tools/unittests/test_cmatch.py +1 -1
index 7b996f83784d..109141cd2ab8 100755
@@ -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'), ' '),
 
 
---

base-commit: 254f49634ee16a731174d2ae34bc50bd5f45e731
change-id: 20260506-kdoc-__counted_by_ptr-1e206f3f1dc1

Best regards,

Signature · 1 line
~Randy
Reviewed-by on v1 1/1
#2 lore raw
In reply to Tudor Ambarus
Quoted 8 lines · Tudor Ambarus

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:

Quoted 8 lines

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.

Signature · 1 line
Kees Cook
Reviewed-by on v1 1/1
#3 lore raw
In reply to Tudor Ambarus
Quoted 8 lines · On Wed, 06 May 2026 11:04:12 +0000 Tudor Ambarus <[email protected]>…

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:

Quoted 8 lines

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.

Quoted 34 lines
---
 tools/lib/python/kdoc/xforms_lists.py | 1 +
 tools/unittests/test_cmatch.py        | 1 +
 2 files changed, 2 insertions(+)
tools/lib/python/kdoc/xforms_lists.py +1 -0
index f6ea9efb11ae..118156ea8cd2 100644
@@ -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"), ""),
tools/unittests/test_cmatch.py +1 -1
index 7b996f83784d..109141cd2ab8 100755
@@ -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'), ' '),
 
 
---

base-commit: 254f49634ee16a731174d2ae34bc50bd5f45e731
change-id: 20260506-kdoc-__counted_by_ptr-1e206f3f1dc1

Quoted 1 line

Best regards,

Thanks,
Mauro

maintainer Applied
#4 lore raw
In reply to Tudor Ambarus
Quoted 14 lines · Tudor Ambarus

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.

Quoted 6 lines
---
 tools/lib/python/kdoc/xforms_lists.py | 1 +
 tools/unittests/test_cmatch.py        | 1 +
 2 files changed, 2 insertions(+)

Applied, thanks.

jon