From: Olivier Matz Date: Wed, 18 May 2016 11:04:25 +0000 (+0200) Subject: mempool: use sizeof to get size of header and trailer X-Git-Tag: spdx-start~6897 X-Git-Url: http://git.droids-corp.org/?a=commitdiff_plain;h=26d624002defc8e322f70f4ee0c01d92631ee9f8;p=dpdk.git mempool: use sizeof to get size of header and trailer Since commits d2e0ca22f and 97e7e685b the headers and trailers of the mempool are defined as a structure. We can get their size using a sizeof instead of doing a calculation that will become wrong at the first structure update. Signed-off-by: Olivier Matz --- diff --git a/lib/librte_mempool/rte_mempool.c b/lib/librte_mempool/rte_mempool.c index 46a5d59ca8..992edcd936 100644 --- a/lib/librte_mempool/rte_mempool.c +++ b/lib/librte_mempool/rte_mempool.c @@ -265,24 +265,13 @@ rte_mempool_calc_obj_size(uint32_t elt_size, uint32_t flags, sz = (sz != NULL) ? sz : &lsz; - /* - * In header, we have at least the pointer to the pool, and - * optionaly a 64 bits cookie. - */ - sz->header_size = 0; - sz->header_size += sizeof(struct rte_mempool *); /* ptr to pool */ -#ifdef RTE_LIBRTE_MEMPOOL_DEBUG - sz->header_size += sizeof(uint64_t); /* cookie */ -#endif + sz->header_size = sizeof(struct rte_mempool_objhdr); if ((flags & MEMPOOL_F_NO_CACHE_ALIGN) == 0) sz->header_size = RTE_ALIGN_CEIL(sz->header_size, RTE_MEMPOOL_ALIGN); - /* trailer contains the cookie in debug mode */ - sz->trailer_size = 0; -#ifdef RTE_LIBRTE_MEMPOOL_DEBUG - sz->trailer_size += sizeof(uint64_t); /* cookie */ -#endif + sz->trailer_size = sizeof(struct rte_mempool_objtlr); + /* element size is 8 bytes-aligned at least */ sz->elt_size = RTE_ALIGN_CEIL(elt_size, sizeof(uint64_t));