This commit addresses the following warning reported by clang, which
happens by default, as long as CONFIG_RTE_LIBRTE_MEMPOOL_DEBUG is disabled:
warning: empty struct has size 0 in C, size 1 in C++
C and C++ must use the same size for objects to avoid corruption during run
time.
Fixes:
97e7e685bfcd ("mempool: add structure for object trailers")
Signed-off-by: Adrien Mazarguil <adrien.mazarguil@6wind.com>
Acked-by: Olivier Matz <olivier.matz@6wind.com>
sz->header_size = RTE_ALIGN_CEIL(sz->header_size,
RTE_MEMPOOL_ALIGN);
+#ifdef RTE_LIBRTE_MEMPOOL_DEBUG
sz->trailer_size = sizeof(struct rte_mempool_objtlr);
+#else
+ sz->trailer_size = 0;
+#endif
/* element size is 8 bytes-aligned at least */
sz->elt_size = RTE_ALIGN_CEIL(elt_size, sizeof(uint64_t));
*/
STAILQ_HEAD(rte_mempool_objhdr_list, rte_mempool_objhdr);
+#ifdef RTE_LIBRTE_MEMPOOL_DEBUG
+
/**
* Mempool object trailer structure
*
* trailer structure containing a cookie preventing memory corruptions.
*/
struct rte_mempool_objtlr {
-#ifdef RTE_LIBRTE_MEMPOOL_DEBUG
uint64_t cookie; /**< Debug cookie. */
-#endif
};
+#endif
+
/**
* A list of memory where objects are stored
*/