[dpdk-dev,v2,1/2] ethdev: remove useless null checks

Message ID 1453471618-29722-2-git-send-email-david.marchand@6wind.com (mailing list archive)
State Accepted, archived
Headers

Commit Message

David Marchand Jan. 22, 2016, 2:06 p.m. UTC
  We are in static functions and those passed arguments can't be NULL.

Signed-off-by: David Marchand <david.marchand@6wind.com>
---
 lib/librte_ether/rte_ethdev.c | 15 ---------------
 1 file changed, 15 deletions(-)
  

Comments

Jan Viktorin Jan. 26, 2016, 3:50 p.m. UTC | #1
What about the RTE_VERIFY? I think, it's more appropriate here.
Otherwise, feel free to add:

Reviewed-by: Jan Viktorin <viktorin@rehivetech.com>

On Fri, 22 Jan 2016 15:06:57 +0100
David Marchand <david.marchand@6wind.com> wrote:

> We are in static functions and those passed arguments can't be NULL.
> 
> Signed-off-by: David Marchand <david.marchand@6wind.com>
> ---
>  lib/librte_ether/rte_ethdev.c | 15 ---------------
>  1 file changed, 15 deletions(-)
> 
> diff --git a/lib/librte_ether/rte_ethdev.c b/lib/librte_ether/rte_ethdev.c
> index ed971b4..cab74e0 100644
> --- a/lib/librte_ether/rte_ethdev.c
> +++ b/lib/librte_ether/rte_ethdev.c
> @@ -220,9 +220,6 @@ rte_eth_dev_create_unique_device_name(char *name, size_t size,
>  {
>  	int ret;
>  
> -	if ((name == NULL) || (pci_dev == NULL))
> -		return -EINVAL;
> -
>  	ret = snprintf(name, size, "%d:%d.%d",
>  			pci_dev->addr.bus, pci_dev->addr.devid,
>  			pci_dev->addr.function);
> @@ -505,9 +502,6 @@ rte_eth_dev_is_detachable(uint8_t port_id)
>  static int
>  rte_eth_dev_attach_pdev(struct rte_pci_addr *addr, uint8_t *port_id)
>  {
> -	if ((addr == NULL) || (port_id == NULL))
> -		goto err;
> -
>  	/* re-construct pci_device_list */
>  	if (rte_eal_pci_scan())
>  		goto err;
> @@ -531,9 +525,6 @@ rte_eth_dev_detach_pdev(uint8_t port_id, struct rte_pci_addr *addr)
>  	struct rte_pci_addr freed_addr;
>  	struct rte_pci_addr vp;
>  
> -	if (addr == NULL)
> -		goto err;
> -
>  	/* check whether the driver supports detach feature, or not */
>  	if (rte_eth_dev_is_detachable(port_id))
>  		goto err;
> @@ -566,9 +557,6 @@ rte_eth_dev_attach_vdev(const char *vdevargs, uint8_t *port_id)
>  	char *name = NULL, *args = NULL;
>  	int ret = -1;
>  
> -	if ((vdevargs == NULL) || (port_id == NULL))
> -		goto end;
> -
>  	/* parse vdevargs, then retrieve device name and args */
>  	if (rte_eal_parse_devargs_str(vdevargs, &name, &args))
>  		goto end;
> @@ -602,9 +590,6 @@ rte_eth_dev_detach_vdev(uint8_t port_id, char *vdevname)
>  {
>  	char name[RTE_ETH_NAME_MAX_LEN];
>  
> -	if (vdevname == NULL)
> -		goto err;
> -
>  	/* check whether the driver supports detach feature, or not */
>  	if (rte_eth_dev_is_detachable(port_id))
>  		goto err;
  
David Marchand Jan. 27, 2016, 9:40 a.m. UTC | #2
On Tue, Jan 26, 2016 at 4:50 PM, Jan Viktorin <viktorin@rehivetech.com> wrote:
> What about the RTE_VERIFY? I think, it's more appropriate here.

Well, here, I am removing useless checks in static functions.

But for the rest of ethdev api, I agree we could add some RTE_VERIFY.

> Otherwise, feel free to add:
>
> Reviewed-by: Jan Viktorin <viktorin@rehivetech.com>

Thanks.
  

Patch

diff --git a/lib/librte_ether/rte_ethdev.c b/lib/librte_ether/rte_ethdev.c
index ed971b4..cab74e0 100644
--- a/lib/librte_ether/rte_ethdev.c
+++ b/lib/librte_ether/rte_ethdev.c
@@ -220,9 +220,6 @@  rte_eth_dev_create_unique_device_name(char *name, size_t size,
 {
 	int ret;
 
-	if ((name == NULL) || (pci_dev == NULL))
-		return -EINVAL;
-
 	ret = snprintf(name, size, "%d:%d.%d",
 			pci_dev->addr.bus, pci_dev->addr.devid,
 			pci_dev->addr.function);
@@ -505,9 +502,6 @@  rte_eth_dev_is_detachable(uint8_t port_id)
 static int
 rte_eth_dev_attach_pdev(struct rte_pci_addr *addr, uint8_t *port_id)
 {
-	if ((addr == NULL) || (port_id == NULL))
-		goto err;
-
 	/* re-construct pci_device_list */
 	if (rte_eal_pci_scan())
 		goto err;
@@ -531,9 +525,6 @@  rte_eth_dev_detach_pdev(uint8_t port_id, struct rte_pci_addr *addr)
 	struct rte_pci_addr freed_addr;
 	struct rte_pci_addr vp;
 
-	if (addr == NULL)
-		goto err;
-
 	/* check whether the driver supports detach feature, or not */
 	if (rte_eth_dev_is_detachable(port_id))
 		goto err;
@@ -566,9 +557,6 @@  rte_eth_dev_attach_vdev(const char *vdevargs, uint8_t *port_id)
 	char *name = NULL, *args = NULL;
 	int ret = -1;
 
-	if ((vdevargs == NULL) || (port_id == NULL))
-		goto end;
-
 	/* parse vdevargs, then retrieve device name and args */
 	if (rte_eal_parse_devargs_str(vdevargs, &name, &args))
 		goto end;
@@ -602,9 +590,6 @@  rte_eth_dev_detach_vdev(uint8_t port_id, char *vdevname)
 {
 	char name[RTE_ETH_NAME_MAX_LEN];
 
-	if (vdevname == NULL)
-		goto err;
-
 	/* check whether the driver supports detach feature, or not */
 	if (rte_eth_dev_is_detachable(port_id))
 		goto err;