Skip to contentSkip to conversation

docs: kdoc_parser: add data/function attributes to ignore

PATCH Applied Randy Dunlap 2 participants 2 messages Nov 27, 2025 – Nov 29, 2025 Documentation

lore
Share & tools
lore

Randy Dunlap

author reviewer
#0 lore raw

PATCH 1/1 docs: kdoc_parser: add data/function attributes to ignore

Recognize and ignore __rcu (in struct members), __private (in struct members), and __always_unused (in function parameters) to prevent kernel-doc warnings:

Warning: include/linux/rethook.h:38 struct member 'void (__rcu *handler' not described in 'rethook'
Warning: include/linux/hrtimer_types.h:47 Invalid param: enum hrtimer_restart (*__private function)(struct hrtimer *)
Warning: security/ipe/hooks.c:81 function parameter '__always_unused' not described in 'ipe_mmap_file'
Warning: security/ipe/hooks.c:109 function parameter '__always_unused' not described in 'ipe_file_mprotect'

There are more of these (in compiler_types.h, compiler_attributes.h) that can be added as needed.

---
Cc: Jonathan Corbet <[email protected]>
Cc: Mauro Carvalho Chehab <[email protected]>
Cc: [email protected]

---
 tools/lib/python/kdoc/kdoc_parser.py |    3 +++
 1 file changed, 3 insertions(+)
tools/lib/python/kdoc/kdoc_parser.py +3 -0
@@ -86,6 +86,8 @@ struct_xforms = [
     (KernRe(r'\s*__counted_by_(le|be)\s*\([^;]*\)', re.S), ' '),
     (KernRe(r'\s*__packed\s*', re.S), ' '),
     (KernRe(r'\s*CRYPTO_MINALIGN_ATTR', re.S), ' '),
+    (KernRe(r'\s*__private', re.S), ' '),
+    (KernRe(r'\s*__rcu', re.S), ' '),
     (KernRe(r'\s*____cacheline_aligned_in_smp', re.S), ' '),
     (KernRe(r'\s*____cacheline_aligned', re.S), ' '),
     (KernRe(r'\s*__cacheline_group_(begin|end)\([^\)]+\);'), ''),
@@ -183,6 +185,7 @@ function_xforms  = [
     (KernRe(r"__weak +"), ""),
     (KernRe(r"__sched +"), ""),
     (KernRe(r"_noprof"), ""),
+    (KernRe(r"__always_unused *"), ""),
     (KernRe(r"__printf\s*\(\s*\d*\s*,\s*\d*\s*\) +"), ""),
     (KernRe(r"__(?:re)?alloc_size\s*\(\s*\d+\s*(?:,\s*\d+\s*)?\) +"), ""),
     (KernRe(r"__diagnose_as\s*\(\s*\S+\s*(?:,\s*\d+\s*)*\) +"), ""),
maintainer Applied
#1 lore raw
Quoted 12 lines · Randy Dunlap

Recognize and ignore __rcu (in struct members), __private (in struct members), and __always_unused (in function parameters) to prevent kernel-doc warnings:

Warning: include/linux/rethook.h:38 struct member 'void (__rcu *handler' not described in 'rethook'
Warning: include/linux/hrtimer_types.h:47 Invalid param: enum hrtimer_restart (*__private function)(struct hrtimer *)
Warning: security/ipe/hooks.c:81 function parameter '__always_unused' not described in 'ipe_mmap_file'
Warning: security/ipe/hooks.c:109 function parameter '__always_unused' not described in 'ipe_file_mprotect'

There are more of these (in compiler_types.h, compiler_attributes.h) that can be added as needed.

Quoted 8 lines

---
Cc: Jonathan Corbet <[email protected]>
Cc: Mauro Carvalho Chehab <[email protected]>
Cc: [email protected]

---
 tools/lib/python/kdoc/kdoc_parser.py |    3 +++
 1 file changed, 3 insertions(+)

Applied, thanks.

jon