Skip to contentSkip to conversation

kasan: Mark unpoison_slab_object() as static

PATCH In review [email protected] 2 participants 2 messages Dec 21, 2023

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

PATCH 1/1 kasan: Mark unpoison_slab_object() as static

From: Nathan Chancellor <[email protected]>

With -Wmissing-prototypes enabled, there is a warning that unpoison_slab_object() has no prototype, breaking the build with CONFIG_WERROR=y:

mm/kasan/common.c:271:6: error: no previous prototype for 'unpoison_slab_object' [-Werror=missing-prototypes]
271 | void unpoison_slab_object(struct kmem_cache *cache, void *object, gfp_t flags,
| ^~~~~~~~~~~~~~~~~~~~
cc1: all warnings being treated as errors

Mark the function as static, as it is not used outside of this translation unit, clearing up the warning.

Fixes 3f38c3c5bc40 ("kasan: save alloc stack traces for mempool")

---

Changes v1->v2:
- Mark as "static inline" instead of just "static".

---
 mm/kasan/common.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
mm/kasan/common.c +2 -2
index ebb1b23d6480..f4255e807b74 100644
@@ -277,8 +277,8 @@ void __kasan_kfree_large(void *ptr, unsigned long ip)
 	/* The object will be poisoned by kasan_poison_pages(). */
 }
 
-void unpoison_slab_object(struct kmem_cache *cache, void *object, gfp_t flags,
-			  bool init)
+static inline void unpoison_slab_object(struct kmem_cache *cache, void *object,
+					gfp_t flags, bool init)
 {
 	/*
 	 * Unpoison the whole object. For kmalloc() allocations,
Signature · 1 line
2.25.1
Reviewed-by on v1 1/1
#1 lore raw
Quoted 12 lines · On Thu, 21 Dec 2023 at 19:00, <[email protected]> wrote:

From: Nathan Chancellor <[email protected]>

With -Wmissing-prototypes enabled, there is a warning that unpoison_slab_object() has no prototype, breaking the build with CONFIG_WERROR=y:

mm/kasan/common.c:271:6: error: no previous prototype for 'unpoison_slab_object' [-Werror=missing-prototypes]
271 | void unpoison_slab_object(struct kmem_cache *cache, void *object, gfp_t flags,
| ^~~~~~~~~~~~~~~~~~~~
cc1: all warnings being treated as errors

Quoted 6 lines

Mark the function as static, as it is not used outside of this translation unit, clearing up the warning.

Fixes 3f38c3c5bc40 ("kasan: save alloc stack traces for mempool")
Quoted 26 lines

---

Changes v1->v2:
- Mark as "static inline" instead of just "static".

---
 mm/kasan/common.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
mm/kasan/common.c +2 -3
index ebb1b23d6480..f4255e807b74 100644
@@ -277,8 +277,8 @@ void __kasan_kfree_large(void *ptr, unsigned long ip)
        /* The object will be poisoned by kasan_poison_pages(). */
 }
 
-void unpoison_slab_object(struct kmem_cache *cache, void *object, gfp_t flags,
-                         bool init)
+static inline void unpoison_slab_object(struct kmem_cache *cache, void *object,
+                                       gfp_t flags, bool init)
 {
        /*
         * Unpoison the whole object. For kmalloc() allocations,
--

2.25.1