Browse Source

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,...
      |                    ^~~~~~~~~~~~~~~~

Signed-off-by: Fabio Baltieri <fabiobaltieri@google.com>
pull/74035/head
Fabio Baltieri 1 year ago committed by Fabio Baltieri
parent
commit
328365989f
  1. 4
      kernel/mem_slab.c

4
kernel/mem_slab.c

@ -204,7 +204,8 @@ out:
return rc; 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; const char *p = ptr;
ptrdiff_t offset = p - slab->buffer; 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 * slab->info.num_blocks)) &&
((offset % slab->info.block_size) == 0); ((offset % slab->info.block_size) == 0);
} }
#endif
int k_mem_slab_alloc(struct k_mem_slab *slab, void **mem, k_timeout_t timeout) int k_mem_slab_alloc(struct k_mem_slab *slab, void **mem, k_timeout_t timeout)
{ {

Loading…
Cancel
Save