Skip to contentSkip to conversation

mm/slub: drop duplicate kernel-doc for ksize()

PATCH In review Sanjay Chitroda 2 participants 2 messages Feb 26

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

PATCH v2 1/1 mm/slub: drop duplicate kernel-doc for ksize()

From: Sanjay Chitroda <[email protected]>

The implementation of ksize() was updated with kernel-doc by commit fab0694646d7 ("mm/slab: move [__]ksize and slab_ksize() to mm/slub.c") However, the public header still contains a kernel-doc comment attached to the ksize() prototype.

Having documentation both in the header and next to the implementation causes Sphinx to treat the function as being documented twice, resulting in the warning:

WARNING: Duplicate C declaration, also defined at core-api/mm-api:521 Declaration is '.. c:function:: size_t ksize(const void *objp)'

Kernel-doc guidelines recommend keeping the documentation with the function implementation. Therefore remove the redundant kernel-doc block from include/linux/slab.h so that the implementation in slub.c remains the canonical source for documentation.

No functional change.

Fixes fab0694646d7 ("mm/slab: move [__]ksize and slab_ksize() to mm/slub.c")

---
Changes in v2:
- Instead of removing the doc comment from slub.c, remove it from the
public header as suggested by reviewers.
- Follow the guideline that kernel-doc should stay with the implementation.
- Updated commit message accordingly.
- Link to v1 https://lore.kernel.org/all/[email protected]/

---
 include/linux/slab.h | 12 ------------
 1 file changed, 12 deletions(-)
include/linux/slab.h +0 -12
index c5fde8740281..1c8c53b068b6 100644
@@ -517,18 +517,6 @@ void kfree_sensitive(const void *objp);
 DEFINE_FREE(kfree, void *, if (!IS_ERR_OR_NULL(_T)) kfree(_T))
 DEFINE_FREE(kfree_sensitive, void *, if (_T) kfree_sensitive(_T))
 
-/**
- * ksize - Report actual allocation size of associated object
- *
- * @objp: Pointer returned from a prior kmalloc()-family allocation.
- *
- * This should not be used for writing beyond the originally requested
- * allocation size. Either use krealloc() or round up the allocation size
- * with kmalloc_size_roundup() prior to allocation. If this is used to
- * access beyond the originally requested allocation size, UBSAN_BOUNDS
- * and/or FORTIFY_SOURCE may trip, since they only know about the
- * originally allocated size via the __alloc_size attribute.
- */
 size_t ksize(const void *objp);
 
 #ifdef CONFIG_PRINTK
Signature · 1 line
2.34.1
#1 lore raw
Quoted 19 lines · Sanjay Chitroda

From: Sanjay Chitroda <[email protected]>

The implementation of ksize() was updated with kernel-doc by commit fab0694646d7 ("mm/slab: move [__]ksize and slab_ksize() to mm/slub.c") However, the public header still contains a kernel-doc comment attached to the ksize() prototype.

Having documentation both in the header and next to the implementation causes Sphinx to treat the function as being documented twice, resulting in the warning:

WARNING: Duplicate C declaration, also defined at core-api/mm-api:521 Declaration is '.. c:function:: size_t ksize(const void *objp)'

Kernel-doc guidelines recommend keeping the documentation with the function implementation. Therefore remove the redundant kernel-doc block from include/linux/slab.h so that the implementation in slub.c remains the canonical source for documentation.

Quoted 4 lines

No functional change.

Fixes fab0694646d7 ("mm/slab: move [__]ksize and slab_ksize() to mm/slub.c")

Thanks, added to slab/for-next-fixes

Quoted 34 lines

---
Changes in v2:
- Instead of removing the doc comment from slub.c, remove it from the
public header as suggested by reviewers.
- Follow the guideline that kernel-doc should stay with the implementation.
- Updated commit message accordingly.
- Link to v1 https://lore.kernel.org/all/[email protected]/

---
 include/linux/slab.h | 12 ------------
 1 file changed, 12 deletions(-)
include/linux/slab.h +0 -12
index c5fde8740281..1c8c53b068b6 100644
@@ -517,18 +517,6 @@ void kfree_sensitive(const void *objp);
 DEFINE_FREE(kfree, void *, if (!IS_ERR_OR_NULL(_T)) kfree(_T))
 DEFINE_FREE(kfree_sensitive, void *, if (_T) kfree_sensitive(_T))
 
-/**
- * ksize - Report actual allocation size of associated object
- *
- * @objp: Pointer returned from a prior kmalloc()-family allocation.
- *
- * This should not be used for writing beyond the originally requested
- * allocation size. Either use krealloc() or round up the allocation size
- * with kmalloc_size_roundup() prior to allocation. If this is used to
- * access beyond the originally requested allocation size, UBSAN_BOUNDS
- * and/or FORTIFY_SOURCE may trip, since they only know about the
- * originally allocated size via the __alloc_size attribute.
- */
 size_t ksize(const void *objp);
 
 #ifdef CONFIG_PRINTK