[v7,7/7] bbdev: remove unnecessary if-check

Message ID 1661796438-204861-8-git-send-email-nicolas.chautru@intel.com (mailing list archive)
State Superseded, archived
Delegated to: akhil goyal
Headers
Series bbdev changes for 22.11 |

Checks

Context Check Description
ci/checkpatch success coding style OK
ci/Intel-compilation success Compilation OK
ci/iol-mellanox-Performance success Performance Testing PASS
ci/iol-aarch64-unit-testing success Testing PASS
ci/iol-aarch64-compile-testing success Testing PASS
ci/iol-x86_64-unit-testing success Testing PASS
ci/iol-intel-Functional success Functional Testing PASS
ci/iol-intel-Performance success Performance Testing PASS
ci/iol-x86_64-compile-testing success Testing PASS
ci/github-robot: build success github build: passed
ci/intel-Testing success Testing PASS

Commit Message

Chautru, Nicolas Aug. 29, 2022, 6:07 p.m. UTC
  Code clean up due to if-check not required

Signed-off-by: Nicolas Chautru <nicolas.chautru@intel.com>
Acked-by: Maxime Coquelin <maxime.coquelin@redhat.com>
---
 lib/bbdev/rte_bbdev_op.h | 15 ++++-----------
 1 file changed, 4 insertions(+), 11 deletions(-)
  

Comments

Akhil Goyal Sept. 21, 2022, 7:25 p.m. UTC | #1
> Code clean up due to if-check not required
> 
> Signed-off-by: Nicolas Chautru <nicolas.chautru@intel.com>
> Acked-by: Maxime Coquelin <maxime.coquelin@redhat.com>
> ---
>  lib/bbdev/rte_bbdev_op.h | 15 ++++-----------
>  1 file changed, 4 insertions(+), 11 deletions(-)
> 
> diff --git a/lib/bbdev/rte_bbdev_op.h b/lib/bbdev/rte_bbdev_op.h
> index afa1a71..386eed8 100644
> --- a/lib/bbdev/rte_bbdev_op.h
> +++ b/lib/bbdev/rte_bbdev_op.h
> @@ -970,10 +970,8 @@ struct rte_mempool *
> 
>  	/* Get elements */
>  	ret = rte_mempool_get_bulk(mempool, (void **)ops, num_ops);
> -	if (unlikely(ret < 0))
> -		return ret;
> 
> -	return 0;
> +	return ret;
Do you really need ret?
It can be easily
return rte_mempool_get_bulk(mempool, (void **)ops, num_ops);

same comment for both cleanups
>  }
> 
>  /**
> @@ -1006,10 +1004,8 @@ struct rte_mempool *
> 
>  	/* Get elements */
>  	ret = rte_mempool_get_bulk(mempool, (void **)ops, num_ops);
> -	if (unlikely(ret < 0))
> -		return ret;
> 
> -	return 0;
> +	return ret;
>  }
> 
>  /**
> @@ -1035,17 +1031,14 @@ struct rte_mempool *
>  	int ret;
> 
>  	/* Check type */
> -	priv = (struct rte_bbdev_op_pool_private *)
> -			rte_mempool_get_priv(mempool);
> +	priv = (struct rte_bbdev_op_pool_private *)
> rte_mempool_get_priv(mempool);
>  	if (unlikely(priv->type != RTE_BBDEV_OP_FFT))
>  		return -EINVAL;
> 
>  	/* Get elements */
>  	ret = rte_mempool_get_bulk(mempool, (void **)ops, num_ops);
> -	if (unlikely(ret < 0))
> -		return ret;
> 
> -	return 0;
> +	return ret;
>  }
> 
>  /**
> --
> 1.8.3.1
  
Chautru, Nicolas Sept. 21, 2022, 8:58 p.m. UTC | #2
Hi Akhil, 

> -----Original Message-----
> From: Akhil Goyal <gakhil@marvell.com>
> Subject: RE: [EXT] [PATCH v7 7/7] bbdev: remove unnecessary if-check
> 
> > Code clean up due to if-check not required
> >
> > Signed-off-by: Nicolas Chautru <nicolas.chautru@intel.com>
> > Acked-by: Maxime Coquelin <maxime.coquelin@redhat.com>
> > ---
> >  lib/bbdev/rte_bbdev_op.h | 15 ++++-----------
> >  1 file changed, 4 insertions(+), 11 deletions(-)
> >
> > diff --git a/lib/bbdev/rte_bbdev_op.h b/lib/bbdev/rte_bbdev_op.h index
> > afa1a71..386eed8 100644
> > --- a/lib/bbdev/rte_bbdev_op.h
> > +++ b/lib/bbdev/rte_bbdev_op.h
> > @@ -970,10 +970,8 @@ struct rte_mempool *
> >
> >  	/* Get elements */
> >  	ret = rte_mempool_get_bulk(mempool, (void **)ops, num_ops);
> > -	if (unlikely(ret < 0))
> > -		return ret;
> >
> > -	return 0;
> > +	return ret;
> Do you really need ret?
> It can be easily
> return rte_mempool_get_bulk(mempool, (void **)ops, num_ops);

Sure, fixing in v8. 

> 
> same comment for both cleanups
> >  }
> >
> >  /**
> > @@ -1006,10 +1004,8 @@ struct rte_mempool *
> >
> >  	/* Get elements */
> >  	ret = rte_mempool_get_bulk(mempool, (void **)ops, num_ops);
> > -	if (unlikely(ret < 0))
> > -		return ret;
> >
> > -	return 0;
> > +	return ret;
> >  }
> >
> >  /**
> > @@ -1035,17 +1031,14 @@ struct rte_mempool *
> >  	int ret;
> >
> >  	/* Check type */
> > -	priv = (struct rte_bbdev_op_pool_private *)
> > -			rte_mempool_get_priv(mempool);
> > +	priv = (struct rte_bbdev_op_pool_private *)
> > rte_mempool_get_priv(mempool);
> >  	if (unlikely(priv->type != RTE_BBDEV_OP_FFT))
> >  		return -EINVAL;
> >
> >  	/* Get elements */
> >  	ret = rte_mempool_get_bulk(mempool, (void **)ops, num_ops);
> > -	if (unlikely(ret < 0))
> > -		return ret;
> >
> > -	return 0;
> > +	return ret;
> >  }
> >
> >  /**
> > --
> > 1.8.3.1
  

Patch

diff --git a/lib/bbdev/rte_bbdev_op.h b/lib/bbdev/rte_bbdev_op.h
index afa1a71..386eed8 100644
--- a/lib/bbdev/rte_bbdev_op.h
+++ b/lib/bbdev/rte_bbdev_op.h
@@ -970,10 +970,8 @@  struct rte_mempool *
 
 	/* Get elements */
 	ret = rte_mempool_get_bulk(mempool, (void **)ops, num_ops);
-	if (unlikely(ret < 0))
-		return ret;
 
-	return 0;
+	return ret;
 }
 
 /**
@@ -1006,10 +1004,8 @@  struct rte_mempool *
 
 	/* Get elements */
 	ret = rte_mempool_get_bulk(mempool, (void **)ops, num_ops);
-	if (unlikely(ret < 0))
-		return ret;
 
-	return 0;
+	return ret;
 }
 
 /**
@@ -1035,17 +1031,14 @@  struct rte_mempool *
 	int ret;
 
 	/* Check type */
-	priv = (struct rte_bbdev_op_pool_private *)
-			rte_mempool_get_priv(mempool);
+	priv = (struct rte_bbdev_op_pool_private *) rte_mempool_get_priv(mempool);
 	if (unlikely(priv->type != RTE_BBDEV_OP_FFT))
 		return -EINVAL;
 
 	/* Get elements */
 	ret = rte_mempool_get_bulk(mempool, (void **)ops, num_ops);
-	if (unlikely(ret < 0))
-		return ret;
 
-	return 0;
+	return ret;
 }
 
 /**