summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorAdrien Mazarguil <adrien.mazarguil@6wind.com>2016-07-13 14:30:41 +0200
committerThomas Monjalon <thomas.monjalon@6wind.com>2016-07-15 17:26:52 +0200
commit1cc275ef61c5ddd5f9be7519b3b9db381947782e (patch)
tree37d26e54b0f6ad673939a3646c8ae690ac1f5691 /lib
parenta088b5ea35e78d3866d492ed5e8c8f47118696a6 (diff)
downloaddpdk-1cc275ef61c5ddd5f9be7519b3b9db381947782e.zip
dpdk-1cc275ef61c5ddd5f9be7519b3b9db381947782e.tar.gz
dpdk-1cc275ef61c5ddd5f9be7519b3b9db381947782e.tar.xz
mempool: fix empty structure definition
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>
Diffstat (limited to 'lib')
-rw-r--r--lib/librte_mempool/rte_mempool.c4
-rw-r--r--lib/librte_mempool/rte_mempool.h6
2 files changed, 8 insertions, 2 deletions
diff --git a/lib/librte_mempool/rte_mempool.c b/lib/librte_mempool/rte_mempool.c
index 6ec0906..8806633 100644
--- a/lib/librte_mempool/rte_mempool.c
+++ b/lib/librte_mempool/rte_mempool.c
@@ -199,7 +199,11 @@ rte_mempool_calc_obj_size(uint32_t elt_size, uint32_t flags,
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));
diff --git a/lib/librte_mempool/rte_mempool.h b/lib/librte_mempool/rte_mempool.h
index fb7052e..4a8fbb1 100644
--- a/lib/librte_mempool/rte_mempool.h
+++ b/lib/librte_mempool/rte_mempool.h
@@ -163,6 +163,8 @@ struct rte_mempool_objhdr {
*/
STAILQ_HEAD(rte_mempool_objhdr_list, rte_mempool_objhdr);
+#ifdef RTE_LIBRTE_MEMPOOL_DEBUG
+
/**
* Mempool object trailer structure
*
@@ -170,11 +172,11 @@ STAILQ_HEAD(rte_mempool_objhdr_list, rte_mempool_objhdr);
* 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
*/