From: Adrien Mazarguil Date: Mon, 25 May 2015 16:27:45 +0000 (+0200) Subject: mempool: fix returned value after counting objects X-Git-Tag: spdx-start~9155 X-Git-Url: http://git.droids-corp.org/?a=commitdiff_plain;h=e221e274aa453a8a4674c9998984123792dad505;p=dpdk.git mempool: fix returned value after counting objects rte_mempool_xmem_usage()'s return type is ssize_t which has the same architecture-dependent width as size_t but is signed. On 64-bit architectures, returning a negative uint32_t value without casting to ssize_t first does not work as intended, the sign bit is lost and the returned value is garbage. This commit fixes an assertion failure in testpmd on 64 bit architectures when combining --no-huge and --mp-anon outside of Xen Dom0: PANIC in mempool_anon_create(): line 170 assert "elt_num == mp->size" failed Fixes: 148f963fb532 ("xen: core library changes") Signed-off-by: Adrien Mazarguil Acked-by: Konstantin Ananyev --- diff --git a/lib/librte_mempool/rte_mempool.c b/lib/librte_mempool/rte_mempool.c index 01972ba010..d1a02a2571 100644 --- a/lib/librte_mempool/rte_mempool.c +++ b/lib/librte_mempool/rte_mempool.c @@ -361,7 +361,7 @@ rte_mempool_xmem_usage(void *vaddr, uint32_t elt_num, size_t elt_sz, if ((n = rte_mempool_obj_iter(vaddr, elt_num, elt_sz, 1, paddr, pg_num, pg_shift, mempool_lelem_iter, &uv)) != elt_num) { - return (-n); + return (-(ssize_t)n); } uv = RTE_ALIGN_CEIL(uv, pg_sz);