From faed25aa1a9718c8c3aed66ebfbfae39f645151f Mon Sep 17 00:00:00 2001 From: Fabio Baltieri Date: Mon, 10 Jun 2024 10:02:08 +0000 Subject: [PATCH] kernel: mem_slab: only define slab_ptr_is_good with assert enabled Add a __ASSERT_ON guard around slab_ptr_is_good, as that is only used in assertions and leaving it on seems to generate a build warning with some clang versions: kernel/mem_slab.c:207:20: error: unused function 'slab_ptr_is_good' 207 | static inline bool slab_ptr_is_good(struct k_mem_slab *slab,... | ^~~~~~~~~~~~~~~~ (cherry picked from commit 328365989f278c581985ae3cd9510a4df14f82e9) Original-Signed-off-by: Fabio Baltieri GitOrigin-RevId: 328365989f278c581985ae3cd9510a4df14f82e9 Change-Id: If196dd35272db76466cece7c44139e4c1ec98dc1 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/third_party/zephyr/+/5616301 Tested-by: ChromeOS Prod (Robot) Commit-Queue: Fabio Baltieri Reviewed-by: Fabio Baltieri --- kernel/mem_slab.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/kernel/mem_slab.c b/kernel/mem_slab.c index f79c5b01d4f..86aebe38344 100644 --- a/kernel/mem_slab.c +++ b/kernel/mem_slab.c @@ -204,7 +204,8 @@ int k_mem_slab_init(struct k_mem_slab *slab, void *buffer, return rc; } -static inline bool slab_ptr_is_good(struct k_mem_slab *slab, const void *ptr) +#if __ASSERT_ON +static bool slab_ptr_is_good(struct k_mem_slab *slab, const void *ptr) { const char *p = ptr; ptrdiff_t offset = p - slab->buffer; @@ -213,6 +214,7 @@ static inline bool slab_ptr_is_good(struct k_mem_slab *slab, const void *ptr) (offset < (slab->info.block_size * slab->info.num_blocks)) && ((offset % slab->info.block_size) == 0); } +#endif int k_mem_slab_alloc(struct k_mem_slab *slab, void **mem, k_timeout_t timeout) {