From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-wm0-f49.google.com (mail-wm0-f49.google.com [74.125.82.49]) by dpdk.org (Postfix) with ESMTP id D2C6E1C52 for ; Wed, 13 Jul 2016 14:30:47 +0200 (CEST) Received: by mail-wm0-f49.google.com with SMTP id i5so66755269wmg.0 for ; Wed, 13 Jul 2016 05:30:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=6wind-com.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id; bh=XL/pRsIgrY0SHfBe7aayJDrT2fKSP9xvh0S2LWK7W1E=; b=AOlOC0bgwdzGIbNNgbnaRa329lNhrym9HbMI9lsq8qzhYGVCuAE0FH1KWVNqU2oJJt mvNyXN5/qlOivMhOS5LQ7LCfv4CeF5xJVQJCAIUcHNZYRdVqRKXd1D9kKMk0o65Bb+TO +3XBiUHtYo4Nja7sIjtUHqLCNXezUaQKwWAvVGgJhWYdMTXvQh5I84HkW4w8da/4vq6i itvp2gawtA+aPyTONMnXezG7hE+yYFdq4n+jARxdE9TVgXhLpnO2o29ohlb016no1XjP TueOFmPstSGYiBFZ9Ip3VX8We49iO0hd4GnQjSqfXxtIvkinVsO29/CU5Suri7B1Jzxu B0XQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=XL/pRsIgrY0SHfBe7aayJDrT2fKSP9xvh0S2LWK7W1E=; b=EQEz9ZHTApSMiiAkidChZga4yN9qKHsIB6673c906kN+BOvACy9jA2byotoYSpEbPt R13ZzETeromVAWvtjz+MmM/FVEtjDH6tOcisJMgSmT1M/mHAdEfJRK9Utu42yLul4M8N DeoZLBhLIl3r8bvo2TFFuIZzOObqAnM7R1XdpnVq+M5tNTvPlfPvcZbDtt233DKMDM+0 ioIG/NcW5F8ZverCbA4d642UIpZGzs6AoWldA7oY6TQTBee9p5OIkiaJ8dnOWY6VgXWD dDcOp66L3I6bKMGIBLWtjnRL+CJ+MOd0GzgranBq2QL5dpys6fEPD1ZIYoPHzIDWG5oV ADaA== X-Gm-Message-State: ALyK8tIZJEjU5HuGoYbsccxoWX7hBDGqfrDW88bARK4ExiCWsB0pl2fa/3txOzgLvv51lqLw X-Received: by 10.194.168.228 with SMTP id zz4mr794812wjb.21.1468413047418; Wed, 13 Jul 2016 05:30:47 -0700 (PDT) Received: from 6wind.com (guy78-3-82-239-227-177.fbx.proxad.net. [82.239.227.177]) by smtp.gmail.com with ESMTPSA id g184sm5675708wme.15.2016.07.13.05.30.46 (version=TLS1_2 cipher=AES128-SHA bits=128/128); Wed, 13 Jul 2016 05:30:46 -0700 (PDT) From: Adrien Mazarguil To: dev@dpdk.org Cc: Olivier Matz Date: Wed, 13 Jul 2016 14:30:41 +0200 Message-Id: <1468413041-22357-1-git-send-email-adrien.mazarguil@6wind.com> X-Mailer: git-send-email 2.1.4 Subject: [dpdk-dev] [PATCH] mempool: fix empty structure definition X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: patches and discussions about DPDK List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 13 Jul 2016 12:30:48 -0000 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 --- lib/librte_mempool/rte_mempool.c | 4 ++++ lib/librte_mempool/rte_mempool.h | 6 ++++-- 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 */ -- 2.1.4