From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from sclab-apps-2.localdomain (sc-fw1.tilera.com [12.218.212.162]) by dpdk.org (Postfix) with ESMTP id 274B3C914 for ; Fri, 19 Jun 2015 19:35:04 +0200 (CEST) X-CheckPoint: {558452C7-C-A3D4DA0C-C0000002} Received: by sclab-apps-2.localdomain (Postfix, from userid 1318) id 19420220493; Fri, 19 Jun 2015 10:35:02 -0700 (PDT) From: Cyril Chemparathy To: dev@dpdk.org Date: Fri, 19 Jun 2015 10:34:46 -0700 Message-Id: <1434735293-15469-4-git-send-email-cchemparathy@ezchip.com> X-Mailer: git-send-email 2.1.2 In-Reply-To: <1434735293-15469-1-git-send-email-cchemparathy@ezchip.com> References: <1434735293-15469-1-git-send-email-cchemparathy@ezchip.com> Subject: [dpdk-dev] [PATCH v2 03/10] ethdev: silence -Wcast-align on pointer arithmetic 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: Fri, 19 Jun 2015 17:35:14 -0000 Statistics offsets in the rte_stats_strings[] array are always 64-bit aligned. However, the compiler is unaware of this fact and complains on -Wcast-align. This patch modifies the code to use RTE_PTR_ADD(), thereby silencing the compiler by casting through (void *). Acked-by: Olivier Matz Signed-off-by: Cyril Chemparathy --- lib/librte_ether/rte_ethdev.c | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/lib/librte_ether/rte_ethdev.c b/lib/librte_ether/rte_ethdev.c index e13fde5..02cd07f 100644 --- a/lib/librte_ether/rte_ethdev.c +++ b/lib/librte_ether/rte_ethdev.c @@ -1742,8 +1742,7 @@ rte_eth_xstats_get(uint8_t port_id, struct rte_eth_xstats *xstats, struct rte_eth_stats eth_stats; struct rte_eth_dev *dev; unsigned count, i, q; - uint64_t val; - char *stats_ptr; + uint64_t val, *stats_ptr; if (!rte_eth_dev_is_valid_port(port_id)) { PMD_DEBUG_TRACE("Invalid port_id=%d\n", port_id); @@ -1770,8 +1769,9 @@ rte_eth_xstats_get(uint8_t port_id, struct rte_eth_xstats *xstats, /* global stats */ for (i = 0; i < RTE_NB_STATS; i++) { - stats_ptr = (char *)ð_stats + rte_stats_strings[i].offset; - val = *(uint64_t *)stats_ptr; + stats_ptr = RTE_PTR_ADD(ð_stats, + rte_stats_strings[i].offset); + val = *stats_ptr; snprintf(xstats[count].name, sizeof(xstats[count].name), "%s", rte_stats_strings[i].name); xstats[count++].value = val; @@ -1780,10 +1780,10 @@ rte_eth_xstats_get(uint8_t port_id, struct rte_eth_xstats *xstats, /* per-rxq stats */ for (q = 0; q < dev->data->nb_rx_queues; q++) { for (i = 0; i < RTE_NB_RXQ_STATS; i++) { - stats_ptr = (char *)ð_stats; - stats_ptr += rte_rxq_stats_strings[i].offset; - stats_ptr += q * sizeof(uint64_t); - val = *(uint64_t *)stats_ptr; + stats_ptr = RTE_PTR_ADD(ð_stats, + rte_rxq_stats_strings[i].offset + + q * sizeof(uint64_t)); + val = *stats_ptr; snprintf(xstats[count].name, sizeof(xstats[count].name), "rx_queue_%u_%s", q, rte_rxq_stats_strings[i].name); @@ -1794,10 +1794,10 @@ rte_eth_xstats_get(uint8_t port_id, struct rte_eth_xstats *xstats, /* per-txq stats */ for (q = 0; q < dev->data->nb_tx_queues; q++) { for (i = 0; i < RTE_NB_TXQ_STATS; i++) { - stats_ptr = (char *)ð_stats; - stats_ptr += rte_txq_stats_strings[i].offset; - stats_ptr += q * sizeof(uint64_t); - val = *(uint64_t *)stats_ptr; + stats_ptr = RTE_PTR_ADD(ð_stats, + rte_txq_stats_strings[i].offset + + q * sizeof(uint64_t)); + val = *stats_ptr; snprintf(xstats[count].name, sizeof(xstats[count].name), "tx_queue_%u_%s", q, rte_txq_stats_strings[i].name); -- 2.1.2