DPDK patches and discussions
 help / color / mirror / Atom feed
From: Stephen Hemminger <stephen@networkplumber.org>
To: dev@dpdk.org
Cc: Stephen Hemminger <shemming@brocade.com>
Subject: [dpdk-dev] [PATCH 1/4] rte_ethdev: remove impossible condition
Date: Fri, 26 Jun 2015 17:01:42 -0700	[thread overview]
Message-ID: <1435363305-17819-2-git-send-email-stephen@networkplumber.org> (raw)
In-Reply-To: <1435363305-17819-1-git-send-email-stephen@networkplumber.org>

From: Stephen Hemminger <shemming@brocade.com>

Since rte_eth_devices is in BSS, the address of rte_eth_devices
plus port_id can not ever be NULL for a valid port_id number.
Remove this unnecessary check and fix the code style.

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
 lib/librte_ether/rte_ethdev.c | 45 +++++++++----------------------------------
 1 file changed, 9 insertions(+), 36 deletions(-)

diff --git a/lib/librte_ether/rte_ethdev.c b/lib/librte_ether/rte_ethdev.c
index 02cd07f..dec3da7 100644
--- a/lib/librte_ether/rte_ethdev.c
+++ b/lib/librte_ether/rte_ethdev.c
@@ -3290,10 +3290,7 @@ int rte_eth_dev_bypass_init(uint8_t port_id)
 		return -ENODEV;
 	}
 
-	if ((dev= &rte_eth_devices[port_id]) == NULL) {
-		PMD_DEBUG_TRACE("Invalid port device\n");
-		return -ENODEV;
-	}
+	dev = &rte_eth_devices[port_id];
 
 	FUNC_PTR_OR_ERR_RET(*dev->dev_ops->bypass_init, -ENOTSUP);
 	(*dev->dev_ops->bypass_init)(dev);
@@ -3310,10 +3307,7 @@ rte_eth_dev_bypass_state_show(uint8_t port_id, uint32_t *state)
 		return -ENODEV;
 	}
 
-	if ((dev= &rte_eth_devices[port_id]) == NULL) {
-		PMD_DEBUG_TRACE("Invalid port device\n");
-		return -ENODEV;
-	}
+	dev = &rte_eth_devices[port_id];
 	FUNC_PTR_OR_ERR_RET(*dev->dev_ops->bypass_state_show, -ENOTSUP);
 	(*dev->dev_ops->bypass_state_show)(dev, state);
 	return 0;
@@ -3329,10 +3323,7 @@ rte_eth_dev_bypass_state_set(uint8_t port_id, uint32_t *new_state)
 		return -ENODEV;
 	}
 
-	if ((dev= &rte_eth_devices[port_id]) == NULL) {
-		PMD_DEBUG_TRACE("Invalid port device\n");
-		return -ENODEV;
-	}
+	dev = &rte_eth_devices[port_id];
 
 	FUNC_PTR_OR_ERR_RET(*dev->dev_ops->bypass_state_set, -ENOTSUP);
 	(*dev->dev_ops->bypass_state_set)(dev, new_state);
@@ -3349,10 +3340,7 @@ rte_eth_dev_bypass_event_show(uint8_t port_id, uint32_t event, uint32_t *state)
 		return -ENODEV;
 	}
 
-	if ((dev= &rte_eth_devices[port_id]) == NULL) {
-		PMD_DEBUG_TRACE("Invalid port device\n");
-		return -ENODEV;
-	}
+	dev = &rte_eth_devices[port_id];
 
 	FUNC_PTR_OR_ERR_RET(*dev->dev_ops->bypass_state_show, -ENOTSUP);
 	(*dev->dev_ops->bypass_event_show)(dev, event, state);
@@ -3369,10 +3357,7 @@ rte_eth_dev_bypass_event_store(uint8_t port_id, uint32_t event, uint32_t state)
 		return -ENODEV;
 	}
 
-	if ((dev= &rte_eth_devices[port_id]) == NULL) {
-		PMD_DEBUG_TRACE("Invalid port device\n");
-		return -ENODEV;
-	}
+	dev = &rte_eth_devices[port_id];
 
 	FUNC_PTR_OR_ERR_RET(*dev->dev_ops->bypass_event_set, -ENOTSUP);
 	(*dev->dev_ops->bypass_event_set)(dev, event, state);
@@ -3389,10 +3374,7 @@ rte_eth_dev_wd_timeout_store(uint8_t port_id, uint32_t timeout)
 		return -ENODEV;
 	}
 
-	if ((dev= &rte_eth_devices[port_id]) == NULL) {
-		PMD_DEBUG_TRACE("Invalid port device\n");
-		return -ENODEV;
-	}
+	dev = &rte_eth_devices[port_id];
 
 	FUNC_PTR_OR_ERR_RET(*dev->dev_ops->bypass_wd_timeout_set, -ENOTSUP);
 	(*dev->dev_ops->bypass_wd_timeout_set)(dev, timeout);
@@ -3409,10 +3391,7 @@ rte_eth_dev_bypass_ver_show(uint8_t port_id, uint32_t *ver)
 		return -ENODEV;
 	}
 
-	if ((dev= &rte_eth_devices[port_id]) == NULL) {
-		PMD_DEBUG_TRACE("Invalid port device\n");
-		return -ENODEV;
-	}
+	dev = &rte_eth_devices[port_id];
 
 	FUNC_PTR_OR_ERR_RET(*dev->dev_ops->bypass_ver_show, -ENOTSUP);
 	(*dev->dev_ops->bypass_ver_show)(dev, ver);
@@ -3429,10 +3408,7 @@ rte_eth_dev_bypass_wd_timeout_show(uint8_t port_id, uint32_t *wd_timeout)
 		return -ENODEV;
 	}
 
-	if ((dev= &rte_eth_devices[port_id]) == NULL) {
-		PMD_DEBUG_TRACE("Invalid port device\n");
-		return -ENODEV;
-	}
+	dev = &rte_eth_devices[port_id];
 
 	FUNC_PTR_OR_ERR_RET(*dev->dev_ops->bypass_wd_timeout_show, -ENOTSUP);
 	(*dev->dev_ops->bypass_wd_timeout_show)(dev, wd_timeout);
@@ -3449,10 +3425,7 @@ rte_eth_dev_bypass_wd_reset(uint8_t port_id)
 		return -ENODEV;
 	}
 
-	if ((dev= &rte_eth_devices[port_id]) == NULL) {
-		PMD_DEBUG_TRACE("Invalid port device\n");
-		return -ENODEV;
-	}
+	dev = &rte_eth_devices[port_id];
 
 	FUNC_PTR_OR_ERR_RET(*dev->dev_ops->bypass_wd_reset, -ENOTSUP);
 	(*dev->dev_ops->bypass_wd_reset)(dev);
-- 
2.1.4

  reply	other threads:[~2015-06-27  0:01 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-06-27  0:01 [dpdk-dev] [PATCH 0/4] ethdev: patches Stephen Hemminger
2015-06-27  0:01 ` Stephen Hemminger [this message]
2015-06-27  0:01 ` [dpdk-dev] [PATCH 2/4] rte_ethdev: fix comment spelling Stephen Hemminger
2015-06-27  0:01 ` [dpdk-dev] [PATCH 3/4] rte_ethdev: fix code style Stephen Hemminger
2015-06-27  0:01 ` [dpdk-dev] [PATCH 4/4] rte_ethdev: introduce valid port helper Stephen Hemminger
2015-07-02 10:32 ` [dpdk-dev] [PATCH 0/4] ethdev: patches Thomas Monjalon

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=1435363305-17819-2-git-send-email-stephen@networkplumber.org \
    --to=stephen@networkplumber.org \
    --cc=dev@dpdk.org \
    --cc=shemming@brocade.com \
    /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).