mirror of
https://github.com/lwip-tcpip/lwip.git
synced 2025-01-15 22:49:16 +00:00
memp: Fixup LWIP_HOOK_MEMP_AVAILABLE() hook
I got below build warning if LWIP_HOOK_MEMP_AVAILABLE is defined.
src/core/memp.c: In function 'memp_free_pool':
src/core/memp.c:352:16: warning: variable 'old_first' set but not used [-Wunused-but-set-variable]
struct memp *old_first;
^
src/core/memp.c: In function 'memp_free':
src/core/memp.c:413:6: warning: 'old_first' may be used uninitialized in this function [-Wmaybe-uninitialized]
if (old_first == NULL) {
The LWIP_HOOK_MEMP_AVAILABLE() hook does not work, fix it.
Fixes: c838e1ed5b
("Implement possibility to declare private memory pools")
Signed-off-by: Axel Lin <axel.lin@ingics.com>
This commit is contained in:
parent
7f92660598
commit
a21144b834
@ -344,18 +344,16 @@ memp_malloc_fn(memp_t type, const char* file, const int line)
|
|||||||
return memp;
|
return memp;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
static void
|
||||||
memp_free_pool(const struct memp_desc* desc, void *mem)
|
#ifdef LWIP_HOOK_MEMP_AVAILABLE
|
||||||
|
do_memp_free_pool(const struct memp_desc* desc, void *mem, struct memp **old_first)
|
||||||
|
#else
|
||||||
|
do_memp_free_pool(const struct memp_desc* desc, void *mem)
|
||||||
|
#endif
|
||||||
{
|
{
|
||||||
struct memp *memp;
|
struct memp *memp;
|
||||||
#ifdef LWIP_HOOK_MEMP_AVAILABLE
|
|
||||||
struct memp *old_first;
|
|
||||||
#endif
|
|
||||||
SYS_ARCH_DECL_PROTECT(old_level);
|
SYS_ARCH_DECL_PROTECT(old_level);
|
||||||
|
|
||||||
if (mem == NULL) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
LWIP_ASSERT("memp_free: mem properly aligned",
|
LWIP_ASSERT("memp_free: mem properly aligned",
|
||||||
((mem_ptr_t)mem % MEM_ALIGNMENT) == 0);
|
((mem_ptr_t)mem % MEM_ALIGNMENT) == 0);
|
||||||
|
|
||||||
@ -369,9 +367,12 @@ memp_free_pool(const struct memp_desc* desc, void *mem)
|
|||||||
#endif /* MEMP_OVERFLOW_CHECK */
|
#endif /* MEMP_OVERFLOW_CHECK */
|
||||||
|
|
||||||
memp->next = *desc->tab;
|
memp->next = *desc->tab;
|
||||||
|
|
||||||
#ifdef LWIP_HOOK_MEMP_AVAILABLE
|
#ifdef LWIP_HOOK_MEMP_AVAILABLE
|
||||||
old_first = *desc->tab;
|
if (old_first)
|
||||||
|
*old_first = *desc->tab;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
*desc->tab = memp;
|
*desc->tab = memp;
|
||||||
|
|
||||||
#if MEMP_SANITY_CHECK
|
#if MEMP_SANITY_CHECK
|
||||||
@ -381,6 +382,20 @@ memp_free_pool(const struct memp_desc* desc, void *mem)
|
|||||||
SYS_ARCH_UNPROTECT(old_level);
|
SYS_ARCH_UNPROTECT(old_level);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
memp_free_pool(const struct memp_desc* desc, void *mem)
|
||||||
|
{
|
||||||
|
if ((desc == NULL) || (mem == NULL)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
#ifdef LWIP_HOOK_MEMP_AVAILABLE
|
||||||
|
do_memp_free_pool(desc, mem, NULL);
|
||||||
|
#else
|
||||||
|
do_memp_free_pool(desc, mem);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Put an element back into its pool.
|
* Put an element back into its pool.
|
||||||
*
|
*
|
||||||
@ -405,7 +420,11 @@ memp_free(memp_t type, void *mem)
|
|||||||
|
|
||||||
MEMP_STATS_DEC(used, type);
|
MEMP_STATS_DEC(used, type);
|
||||||
|
|
||||||
memp_free_pool(memp_pools[type], mem);
|
#ifdef LWIP_HOOK_MEMP_AVAILABLE
|
||||||
|
do_memp_free_pool(memp_pools[type], mem, &old_first);
|
||||||
|
#else
|
||||||
|
do_memp_free_pool(memp_pools[type], mem);
|
||||||
|
#endif
|
||||||
|
|
||||||
SYS_ARCH_UNPROTECT(old_level);
|
SYS_ARCH_UNPROTECT(old_level);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user