[dpdk-dev,1/2] Move the error check inside __mempool_check_cookies()

Message ID 1412464229-125521-1-git-send-email-keith.wiles@windriver.com (mailing list archive)
State Rejected, archived
Headers

Commit Message

Wiles, Roger Keith Oct. 4, 2014, 11:10 p.m. UTC
  Three places check for the return value from __mempool_get_bulk to be zero
and then call the debug routine __mempool_check_cookies(). The test is
not required if moved into the debug routine. Minor cleanup and mostly
does not effect performance, unless the is not removed by the compiler
in the case where teh debug routine is not defined.

Signed-off-by: Keith Wiles <keith.wiles@windriver.com>
---
 lib/librte_mempool/rte_mempool.h | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)
  

Comments

Wiles, Roger Keith Oct. 4, 2014, 11:17 p.m. UTC | #1
Self Nack this one and will resend the patch as a single patch. :-(

On Oct 4, 2014, at 6:10 PM, Keith Wiles <keith.wiles@windriver.com> wrote:

> Three places check for the return value from __mempool_get_bulk to be zero
> and then call the debug routine __mempool_check_cookies(). The test is
> not required if moved into the debug routine. Minor cleanup and mostly
> does not effect performance, unless the is not removed by the compiler
> in the case where teh debug routine is not defined.
> 
> Signed-off-by: Keith Wiles <keith.wiles@windriver.com>
> ---
> lib/librte_mempool/rte_mempool.h | 12 ++++++------
> 1 file changed, 6 insertions(+), 6 deletions(-)
> 
> diff --git a/lib/librte_mempool/rte_mempool.h b/lib/librte_mempool/rte_mempool.h
> index 597cf4f..154fdd4 100644
> --- a/lib/librte_mempool/rte_mempool.h
> +++ b/lib/librte_mempool/rte_mempool.h
> @@ -325,6 +325,9 @@ static inline void __mempool_check_cookies(const struct rte_mempool *mp,
> 	void *obj;
> 	void **obj_table;
> 
> +	if ( n < 0 )
> +		return;
> +
> 	/* Force to drop the "const" attribute. This is done only when
> 	 * DEBUG is enabled */
> 	tmp = (void *) obj_table_const;
> @@ -1029,8 +1032,7 @@ rte_mempool_mc_get_bulk(struct rte_mempool *mp, void **obj_table, unsigned n)
> {
> 	int ret;
> 	ret = __mempool_get_bulk(mp, obj_table, n, 1);
> -	if (ret == 0)
> -		__mempool_check_cookies(mp, obj_table, n, 1);
> +	__mempool_check_cookies(mp, obj_table, n, 1);
> 	return ret;
> }
> 
> @@ -1058,8 +1060,7 @@ rte_mempool_sc_get_bulk(struct rte_mempool *mp, void **obj_table, unsigned n)
> {
> 	int ret;
> 	ret = __mempool_get_bulk(mp, obj_table, n, 0);
> -	if (ret == 0)
> -		__mempool_check_cookies(mp, obj_table, n, 1);
> +	__mempool_check_cookies(mp, obj_table, n, 1);
> 	return ret;
> }
> 
> @@ -1091,8 +1092,7 @@ rte_mempool_get_bulk(struct rte_mempool *mp, void **obj_table, unsigned n)
> 	int ret;
> 	ret = __mempool_get_bulk(mp, obj_table, n,
> 				 !(mp->flags & MEMPOOL_F_SC_GET));
> -	if (ret == 0)
> -		__mempool_check_cookies(mp, obj_table, n, 1);
> +	__mempool_check_cookies(mp, obj_table, n, 1);
> 	return ret;
> }
> 
> -- 
> 2.1.0
> 

Keith Wiles, Principal Technologist with CTO office, Wind River mobile 972-213-5533
  

Patch

diff --git a/lib/librte_mempool/rte_mempool.h b/lib/librte_mempool/rte_mempool.h
index 597cf4f..154fdd4 100644
--- a/lib/librte_mempool/rte_mempool.h
+++ b/lib/librte_mempool/rte_mempool.h
@@ -325,6 +325,9 @@  static inline void __mempool_check_cookies(const struct rte_mempool *mp,
 	void *obj;
 	void **obj_table;
 
+	if ( n < 0 )
+		return;
+
 	/* Force to drop the "const" attribute. This is done only when
 	 * DEBUG is enabled */
 	tmp = (void *) obj_table_const;
@@ -1029,8 +1032,7 @@  rte_mempool_mc_get_bulk(struct rte_mempool *mp, void **obj_table, unsigned n)
 {
 	int ret;
 	ret = __mempool_get_bulk(mp, obj_table, n, 1);
-	if (ret == 0)
-		__mempool_check_cookies(mp, obj_table, n, 1);
+	__mempool_check_cookies(mp, obj_table, n, 1);
 	return ret;
 }
 
@@ -1058,8 +1060,7 @@  rte_mempool_sc_get_bulk(struct rte_mempool *mp, void **obj_table, unsigned n)
 {
 	int ret;
 	ret = __mempool_get_bulk(mp, obj_table, n, 0);
-	if (ret == 0)
-		__mempool_check_cookies(mp, obj_table, n, 1);
+	__mempool_check_cookies(mp, obj_table, n, 1);
 	return ret;
 }
 
@@ -1091,8 +1092,7 @@  rte_mempool_get_bulk(struct rte_mempool *mp, void **obj_table, unsigned n)
 	int ret;
 	ret = __mempool_get_bulk(mp, obj_table, n,
 				 !(mp->flags & MEMPOOL_F_SC_GET));
-	if (ret == 0)
-		__mempool_check_cookies(mp, obj_table, n, 1);
+	__mempool_check_cookies(mp, obj_table, n, 1);
 	return ret;
 }