DPDK patches and discussions
 help / color / mirror / Atom feed
From: Ferruh Yigit <ferruh.yigit@intel.com>
To: dev@dpdk.org
Subject: [dpdk-dev] [PATCH 22/22] net/pcap: fix checkpatch warnings
Date: Fri, 26 Aug 2016 12:17:59 +0100	[thread overview]
Message-ID: <1472210279-8286-23-git-send-email-ferruh.yigit@intel.com> (raw)
In-Reply-To: <1472210279-8286-1-git-send-email-ferruh.yigit@intel.com>

Signed-off-by: Ferruh Yigit <ferruh.yigit@intel.com>
---
 drivers/net/pcap/rte_eth_pcap.c | 81 ++++++++++++++++++++++-------------------
 1 file changed, 43 insertions(+), 38 deletions(-)

diff --git a/drivers/net/pcap/rte_eth_pcap.c b/drivers/net/pcap/rte_eth_pcap.c
index 782ee4d..35ea2cd 100644
--- a/drivers/net/pcap/rte_eth_pcap.c
+++ b/drivers/net/pcap/rte_eth_pcap.c
@@ -97,7 +97,7 @@ struct pmd_internals {
 };
 
 struct pmd_devargs {
-	unsigned num_of_queue;
+	unsigned int num_of_queue;
 	struct devargs_queue {
 		pcap_dumper_t *dumper;
 		pcap_t *pcap;
@@ -118,6 +118,7 @@ static const char *valid_arguments[] = {
 static struct ether_addr eth_addr = {
 	.addr_bytes = { 0, 0, 0, 0x1, 0x2, 0x3 }
 };
+
 static const char *drivername = "Pcap PMD";
 static struct rte_eth_link pmd_link = {
 		.link_speed = ETH_SPEED_NUM_10G,
@@ -182,7 +183,7 @@ eth_pcap_gather_data(unsigned char *data, struct rte_mbuf *mbuf)
 static uint16_t
 eth_pcap_rx(void *queue, struct rte_mbuf **bufs, uint16_t nb_pkts)
 {
-	unsigned i;
+	unsigned int i;
 	struct pcap_pkthdr header;
 	const u_char *packet;
 	struct rte_mbuf *mbuf;
@@ -202,17 +203,17 @@ eth_pcap_rx(void *queue, struct rte_mbuf **bufs, uint16_t nb_pkts)
 		packet = pcap_next(pcap_q->pcap, &header);
 		if (unlikely(packet == NULL))
 			break;
-		else
-			mbuf = rte_pktmbuf_alloc(pcap_q->mb_pool);
+
+		mbuf = rte_pktmbuf_alloc(pcap_q->mb_pool);
 		if (unlikely(mbuf == NULL))
 			break;
 
 		/* Now get the space available for data in the mbuf */
-		buf_size = (uint16_t)(rte_pktmbuf_data_room_size(pcap_q->mb_pool) -
-				RTE_PKTMBUF_HEADROOM);
+		buf_size = rte_pktmbuf_data_room_size(pcap_q->mb_pool) -
+				RTE_PKTMBUF_HEADROOM;
 
 		if (header.caplen <= buf_size) {
-			/* pcap packet will fit in the mbuf, go ahead and copy */
+			/* pcap packet will fit in the mbuf, can copy it */
 			rte_memcpy(rte_pktmbuf_mtod(mbuf, void *), packet,
 					header.caplen);
 			mbuf->data_len = (uint16_t)header.caplen;
@@ -254,7 +255,7 @@ calculate_timestamp(struct timeval *ts) {
 static uint16_t
 eth_pcap_tx_dumper(void *queue, struct rte_mbuf **bufs, uint16_t nb_pkts)
 {
-	unsigned i;
+	unsigned int i;
 	struct rte_mbuf *mbuf;
 	struct pcap_tx_queue *dumper_q = queue;
 	uint16_t num_tx = 0;
@@ -264,7 +265,8 @@ eth_pcap_tx_dumper(void *queue, struct rte_mbuf **bufs, uint16_t nb_pkts)
 	if (dumper_q->dumper == NULL || nb_pkts == 0)
 		return 0;
 
-	/* writes the nb_pkts packets to the previously opened pcap file dumper */
+	/* writes the nb_pkts packets to the previously opened pcap file
+	 * dumper */
 	for (i = 0; i < nb_pkts; i++) {
 		mbuf = bufs[i];
 		calculate_timestamp(&header.ts);
@@ -281,8 +283,7 @@ eth_pcap_tx_dumper(void *queue, struct rte_mbuf **bufs, uint16_t nb_pkts)
 					  tx_pcap_data);
 			} else {
 				RTE_LOG(ERR, PMD,
-					"Dropping PCAP packet. "
-					"Size (%d) > max jumbo size (%d).\n",
+					"Dropping PCAP packet. Size (%d) > max jumbo size (%d).\n",
 					mbuf->pkt_len,
 					ETHER_MAX_JUMBO_FRAME_LEN);
 
@@ -315,7 +316,7 @@ eth_pcap_tx_dumper(void *queue, struct rte_mbuf **bufs, uint16_t nb_pkts)
 static uint16_t
 eth_pcap_tx(void *queue, struct rte_mbuf **bufs, uint16_t nb_pkts)
 {
-	unsigned i;
+	unsigned int i;
 	int ret;
 	struct rte_mbuf *mbuf;
 	struct pcap_tx_queue *tx_queue = queue;
@@ -339,8 +340,7 @@ eth_pcap_tx(void *queue, struct rte_mbuf **bufs, uint16_t nb_pkts)
 						tx_pcap_data, mbuf->pkt_len);
 			} else {
 				RTE_LOG(ERR, PMD,
-					"Dropping PCAP packet. "
-					"Size (%d) > max jumbo size (%d).\n",
+					"Dropping PCAP packet. Size (%d) > max jumbo size (%d).\n",
 					mbuf->pkt_len,
 					ETHER_MAX_JUMBO_FRAME_LEN);
 
@@ -400,14 +400,15 @@ open_single_tx_pcap(const char *pcap_filename, pcap_dumper_t **dumper)
 	 * with pcap_dump_open(). We create big enough an Ethernet
 	 * pcap holder.
 	 */
-	if ((tx_pcap = pcap_open_dead(DLT_EN10MB, RTE_ETH_PCAP_SNAPSHOT_LEN))
-			== NULL) {
+	tx_pcap = pcap_open_dead(DLT_EN10MB, RTE_ETH_PCAP_SNAPSHOT_LEN);
+	if (tx_pcap == NULL) {
 		RTE_LOG(ERR, PMD, "Couldn't create dead pcap\n");
 		return -1;
 	}
 
 	/* The dumper is created using the previous pcap_t reference */
-	if ((*dumper = pcap_dump_open(tx_pcap, pcap_filename)) == NULL) {
+	*dumper = pcap_dump_open(tx_pcap, pcap_filename);
+	if (*dumper == NULL) {
 		RTE_LOG(ERR, PMD, "Couldn't open %s for writing.\n",
 			pcap_filename);
 		return -1;
@@ -419,8 +420,10 @@ open_single_tx_pcap(const char *pcap_filename, pcap_dumper_t **dumper)
 static int
 open_single_rx_pcap(const char *pcap_filename, pcap_t **pcap)
 {
-	if ((*pcap = pcap_open_offline(pcap_filename, errbuf)) == NULL) {
-		RTE_LOG(ERR, PMD, "Couldn't open %s: %s\n", pcap_filename, errbuf);
+	*pcap = pcap_open_offline(pcap_filename, errbuf);
+	if (*pcap == NULL) {
+		RTE_LOG(ERR, PMD, "Couldn't open %s: %s\n", pcap_filename,
+			errbuf);
 		return -1;
 	}
 
@@ -430,7 +433,7 @@ open_single_rx_pcap(const char *pcap_filename, pcap_t **pcap)
 static int
 eth_dev_start(struct rte_eth_dev *dev)
 {
-	unsigned i;
+	unsigned int i;
 	struct pmd_internals *internals = dev->data->dev_private;
 	struct pcap_tx_queue *tx;
 	struct pcap_rx_queue *rx;
@@ -452,10 +455,12 @@ eth_dev_start(struct rte_eth_dev *dev)
 	for (i = 0; i < dev->data->nb_tx_queues; i++) {
 		tx = &internals->tx_queue[i];
 
-		if (!tx->dumper && strcmp(tx->type, ETH_PCAP_TX_PCAP_ARG) == 0) {
+		if (!tx->dumper &&
+				strcmp(tx->type, ETH_PCAP_TX_PCAP_ARG) == 0) {
 			if (open_single_tx_pcap(tx->name, &tx->dumper) < 0)
 				return -1;
-		} else if (!tx->pcap && strcmp(tx->type, ETH_PCAP_TX_IFACE_ARG) == 0) {
+		} else if (!tx->pcap &&
+				strcmp(tx->type, ETH_PCAP_TX_IFACE_ARG) == 0) {
 			if (open_single_iface(tx->name, &tx->pcap) < 0)
 				return -1;
 		}
@@ -491,7 +496,7 @@ status_up:
 static void
 eth_dev_stop(struct rte_eth_dev *dev)
 {
-	unsigned i;
+	unsigned int i;
 	struct pmd_internals *internals = dev->data->dev_private;
 	struct pcap_tx_queue *tx;
 	struct pcap_rx_queue *rx;
@@ -558,7 +563,7 @@ eth_dev_info(struct rte_eth_dev *dev,
 static void
 eth_stats_get(struct rte_eth_dev *dev, struct rte_eth_stats *stats)
 {
-	unsigned i;
+	unsigned int i;
 	unsigned long rx_packets_total = 0, rx_bytes_total = 0;
 	unsigned long tx_packets_total = 0, tx_bytes_total = 0;
 	unsigned long tx_packets_err_total = 0;
@@ -592,7 +597,7 @@ eth_stats_get(struct rte_eth_dev *dev, struct rte_eth_stats *stats)
 static void
 eth_stats_reset(struct rte_eth_dev *dev)
 {
-	unsigned i;
+	unsigned int i;
 	struct pmd_internals *internal = dev->data->dev_private;
 
 	for (i = 0; i < dev->data->nb_rx_queues; i++) {
@@ -649,7 +654,6 @@ eth_tx_queue_setup(struct rte_eth_dev *dev,
 		unsigned int socket_id __rte_unused,
 		const struct rte_eth_txconf *tx_conf __rte_unused)
 {
-
 	struct pmd_internals *internals = dev->data->dev_private;
 
 	dev->data->tx_queues[tx_queue_id] = &internals->tx_queue[tx_queue_id];
@@ -679,7 +683,7 @@ static const struct eth_dev_ops ops = {
 static int
 open_rx_pcap(const char *key, const char *value, void *extra_args)
 {
-	unsigned i;
+	unsigned int i;
 	const char *pcap_filename = value;
 	struct pmd_devargs *rx = extra_args;
 	pcap_t *pcap = NULL;
@@ -703,7 +707,7 @@ open_rx_pcap(const char *key, const char *value, void *extra_args)
 static int
 open_tx_pcap(const char *key, const char *value, void *extra_args)
 {
-	unsigned i;
+	unsigned int i;
 	const char *pcap_filename = value;
 	struct pmd_devargs *dumpers = extra_args;
 	pcap_dumper_t *dumper;
@@ -746,7 +750,7 @@ open_rx_tx_iface(const char *key, const char *value, void *extra_args)
 static inline int
 open_rx_iface(const char *key, const char *value, void *extra_args)
 {
-	unsigned i;
+	unsigned int i;
 	const char *iface = value;
 	struct pmd_devargs *rx = extra_args;
 	pcap_t *pcap = NULL;
@@ -768,7 +772,7 @@ open_rx_iface(const char *key, const char *value, void *extra_args)
 static int
 open_tx_iface(const char *key, const char *value, void *extra_args)
 {
-	unsigned i;
+	unsigned int i;
 	const char *iface = value;
 	struct pmd_devargs *tx = extra_args;
 	pcap_t *pcap;
@@ -785,8 +789,9 @@ open_tx_iface(const char *key, const char *value, void *extra_args)
 }
 
 static int
-pmd_init_internals(const char *name, const unsigned nb_rx_queues,
-		const unsigned nb_tx_queues, struct pmd_internals **internals,
+pmd_init_internals(const char *name, const unsigned int nb_rx_queues,
+		const unsigned int nb_tx_queues,
+		struct pmd_internals **internals,
 		struct rte_eth_dev **eth_dev)
 {
 	struct rte_eth_dev_data *data = NULL;
@@ -849,13 +854,13 @@ error:
 
 static int
 eth_from_pcaps_common(const char *name, struct pmd_devargs *rx_queues,
-		const unsigned nb_rx_queues, struct pmd_devargs *tx_queues,
-		const unsigned nb_tx_queues, struct rte_kvargs *kvlist,
+		const unsigned int nb_rx_queues, struct pmd_devargs *tx_queues,
+		const unsigned int nb_tx_queues, struct rte_kvargs *kvlist,
 		struct pmd_internals **internals, struct rte_eth_dev **eth_dev)
 {
 	struct rte_kvargs_pair *pair = NULL;
-	unsigned k_idx;
-	unsigned i;
+	unsigned int k_idx;
+	unsigned int i;
 
 	/* do some parameter checking */
 	if (rx_queues == NULL && nb_rx_queues > 0)
@@ -902,8 +907,8 @@ eth_from_pcaps_common(const char *name, struct pmd_devargs *rx_queues,
 
 static int
 eth_from_pcaps(const char *name, struct pmd_devargs *rx_queues,
-		const unsigned nb_rx_queues, struct pmd_devargs *tx_queues,
-		const unsigned nb_tx_queues, struct rte_kvargs *kvlist,
+		const unsigned int nb_rx_queues, struct pmd_devargs *tx_queues,
+		const unsigned int nb_tx_queues, struct rte_kvargs *kvlist,
 		int single_iface, unsigned int using_dumpers)
 {
 	struct pmd_internals *internals = NULL;
-- 
2.7.4

  parent reply	other threads:[~2016-08-26 11:25 UTC|newest]

Thread overview: 25+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-08-26 11:17 [dpdk-dev] [PATCH 00/22] pcap pmd improvements Ferruh Yigit
2016-08-26 11:17 ` [dpdk-dev] [PATCH 01/22] net/pcap: convert config option to a macro Ferruh Yigit
2016-08-26 11:17 ` [dpdk-dev] [PATCH 02/22] net/pcap: use macros for param string Ferruh Yigit
2016-08-26 11:17 ` [dpdk-dev] [PATCH 03/22] net/pcap: reorganize private structs Ferruh Yigit
2016-08-26 11:17 ` [dpdk-dev] [PATCH 04/22] net/pcap: add checks for max queue number Ferruh Yigit
2016-08-26 11:17 ` [dpdk-dev] [PATCH 05/22] net/pcap: update function to reuse it Ferruh Yigit
2016-08-26 11:17 ` [dpdk-dev] [PATCH 06/22] net/pcap: don't carry numa_node argument Ferruh Yigit
2016-08-26 11:17 ` [dpdk-dev] [PATCH 07/22] net/pcap: don't carry kvlist argument Ferruh Yigit
2016-08-26 11:17 ` [dpdk-dev] [PATCH 08/22] net/pcap: move comment to correct place Ferruh Yigit
2016-08-26 11:17 ` [dpdk-dev] [PATCH 09/22] net/pcap: remove duplicated max queue number check Ferruh Yigit
2016-08-26 11:17 ` [dpdk-dev] [PATCH 10/22] net/pcap: use single_iface variable instead of hardcoded Ferruh Yigit
2016-08-26 11:17 ` [dpdk-dev] [PATCH 11/22] net/pcap: group stats related fields into a struct Ferruh Yigit
2016-08-26 11:17 ` [dpdk-dev] [PATCH 12/22] net/pcap: make const array static Ferruh Yigit
2016-08-26 11:17 ` [dpdk-dev] [PATCH 13/22] net/pcap: reorder header files Ferruh Yigit
2016-08-26 11:17 ` [dpdk-dev] [PATCH 14/22] net/pcap: reorder functions Ferruh Yigit
2016-08-26 11:17 ` [dpdk-dev] [PATCH 15/22] net/pcap: update how single iface handled Ferruh Yigit
2016-08-26 11:17 ` [dpdk-dev] [PATCH 16/22] net/pcap: remove unnecessary check Ferruh Yigit
2016-08-26 11:17 ` [dpdk-dev] [PATCH 17/22] net/pcap: remove redundant assignment Ferruh Yigit
2016-08-26 11:17 ` [dpdk-dev] [PATCH 18/22] net/pcap: simplify function Ferruh Yigit
2016-08-26 11:17 ` [dpdk-dev] [PATCH 19/22] net/pcap: fix missing Tx iface assignment Ferruh Yigit
2016-08-26 11:17 ` [dpdk-dev] [PATCH 20/22] net/pcap: coding convention updates Ferruh Yigit
2016-08-26 11:17 ` [dpdk-dev] [PATCH 21/22] net/pcap: remove rte prefix from static functions Ferruh Yigit
2016-08-26 11:17 ` Ferruh Yigit [this message]
2016-08-26 17:38 ` [dpdk-dev] [PATCH 00/22] pcap pmd improvements Stephen Hemminger
2016-09-19 16:42   ` Bruce Richardson

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1472210279-8286-23-git-send-email-ferruh.yigit@intel.com \
    --to=ferruh.yigit@intel.com \
    --cc=dev@dpdk.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).