DPDK patches and discussions
 help / color / Atom feed
* [dpdk-dev] [PATCH] lib: fix unnecessary boolean casts
@ 2019-12-02  9:15 Ciara Power
  2019-12-02 11:58 ` [dpdk-dev] [dpdk-stable] " Ferruh Yigit
                   ` (2 more replies)
  0 siblings, 3 replies; 5+ messages in thread
From: Ciara Power @ 2019-12-02  9:15 UTC (permalink / raw)
  To: olivier.matz, arybchenko; +Cc: dev, Ciara Power, bruce.richardson, stable

The values already boolean types, so the use of !! is unnecessary as
it is used to convert to boolean.

Fixes: ea672a8b1655 ("mbuf: remove the rte_pktmbuf structure")
Fixes: a0fd91cefcc0 ("mempool: rename functions with confusing names")
Cc: olivier.matz@6wind.com
Cc: bruce.richardson@intel.com
Cc: stable@dpdk.org

Signed-off-by: Ciara Power <ciara.power@intel.com>
---
 lib/librte_mbuf/rte_mbuf.h       | 2 +-
 lib/librte_mempool/rte_mempool.h | 4 ++--
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/lib/librte_mbuf/rte_mbuf.h b/lib/librte_mbuf/rte_mbuf.h
index 219b110b7..6d080527f 100644
--- a/lib/librte_mbuf/rte_mbuf.h
+++ b/lib/librte_mbuf/rte_mbuf.h
@@ -1535,7 +1535,7 @@ static inline int rte_pktmbuf_trim(struct rte_mbuf *m, uint16_t len)
 static inline int rte_pktmbuf_is_contiguous(const struct rte_mbuf *m)
 {
 	__rte_mbuf_sanity_check(m, 1);
-	return !!(m->nb_segs == 1);
+	return m->nb_segs == 1;
 }
 
 /**
diff --git a/lib/librte_mempool/rte_mempool.h b/lib/librte_mempool/rte_mempool.h
index f81152af9..e588c5d9b 100644
--- a/lib/librte_mempool/rte_mempool.h
+++ b/lib/librte_mempool/rte_mempool.h
@@ -1653,7 +1653,7 @@ rte_mempool_in_use_count(const struct rte_mempool *mp);
 static inline int
 rte_mempool_full(const struct rte_mempool *mp)
 {
-	return !!(rte_mempool_avail_count(mp) == mp->size);
+	return rte_mempool_avail_count(mp) == mp->size;
 }
 
 /**
@@ -1672,7 +1672,7 @@ rte_mempool_full(const struct rte_mempool *mp)
 static inline int
 rte_mempool_empty(const struct rte_mempool *mp)
 {
-	return !!(rte_mempool_avail_count(mp) == 0);
+	return rte_mempool_avail_count(mp) == 0;
 }
 
 /**
-- 
2.17.1


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [dpdk-dev] [dpdk-stable] [PATCH] lib: fix unnecessary boolean casts
  2019-12-02  9:15 [dpdk-dev] [PATCH] lib: fix unnecessary boolean casts Ciara Power
@ 2019-12-02 11:58 ` " Ferruh Yigit
  2019-12-26 16:21 ` [dpdk-dev] " Olivier Matz
  2020-02-14 16:17 ` [dpdk-dev] [PATCH v2] lib: fix unnecessary double negation Ciara Power
  2 siblings, 0 replies; 5+ messages in thread
From: Ferruh Yigit @ 2019-12-02 11:58 UTC (permalink / raw)
  To: Ciara Power, olivier.matz, arybchenko; +Cc: dev, bruce.richardson, stable

On 12/2/2019 9:15 AM, Ciara Power wrote:
> The values already boolean types, so the use of !! is unnecessary as
> it is used to convert to boolean.
> 
> Fixes: ea672a8b1655 ("mbuf: remove the rte_pktmbuf structure")
> Fixes: a0fd91cefcc0 ("mempool: rename functions with confusing names")
> Cc: olivier.matz@6wind.com
> Cc: bruce.richardson@intel.com
> Cc: stable@dpdk.org
> 
> Signed-off-by: Ciara Power <ciara.power@intel.com>

Reviewed-by: Ferruh Yigit <ferruh.yigit@intel.com>

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [dpdk-dev] [PATCH] lib: fix unnecessary boolean casts
  2019-12-02  9:15 [dpdk-dev] [PATCH] lib: fix unnecessary boolean casts Ciara Power
  2019-12-02 11:58 ` [dpdk-dev] [dpdk-stable] " Ferruh Yigit
@ 2019-12-26 16:21 ` " Olivier Matz
  2020-02-14 16:17 ` [dpdk-dev] [PATCH v2] lib: fix unnecessary double negation Ciara Power
  2 siblings, 0 replies; 5+ messages in thread
From: Olivier Matz @ 2019-12-26 16:21 UTC (permalink / raw)
  To: Ciara Power; +Cc: arybchenko, dev, bruce.richardson, stable

On Mon, Dec 02, 2019 at 09:15:17AM +0000, Ciara Power wrote:
> The values already boolean types, so the use of !! is unnecessary as
> it is used to convert to boolean.
> 
> Fixes: ea672a8b1655 ("mbuf: remove the rte_pktmbuf structure")
> Fixes: a0fd91cefcc0 ("mempool: rename functions with confusing names")
> Cc: olivier.matz@6wind.com
> Cc: bruce.richardson@intel.com
> Cc: stable@dpdk.org
> 
> Signed-off-by: Ciara Power <ciara.power@intel.com>

Acked-by: Olivier Matz <olivier.matz@6wind.com>

Thanks

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [dpdk-dev] [PATCH v2] lib: fix unnecessary double negation
  2019-12-02  9:15 [dpdk-dev] [PATCH] lib: fix unnecessary boolean casts Ciara Power
  2019-12-02 11:58 ` [dpdk-dev] [dpdk-stable] " Ferruh Yigit
  2019-12-26 16:21 ` [dpdk-dev] " Olivier Matz
@ 2020-02-14 16:17 ` Ciara Power
  2020-02-14 16:39   ` David Marchand
  2 siblings, 1 reply; 5+ messages in thread
From: Ciara Power @ 2020-02-14 16:17 UTC (permalink / raw)
  To: olivier.matz, arybchenko; +Cc: dev, Ciara Power, bruce.richardson, stable

An equality expression already returns either 0 or 1.
There is no need to use double negation for these cases.

Fixes: ea672a8b1655 ("mbuf: remove the rte_pktmbuf structure")
Fixes: a0fd91cefcc0 ("mempool: rename functions with confusing names")
Cc: olivier.matz@6wind.com
Cc: bruce.richardson@intel.com
Cc: stable@dpdk.org

Signed-off-by: Ciara Power <ciara.power@intel.com>
Acked-by: Olivier Matz <olivier.matz@6wind.com>
Reviewed-by: Ferruh Yigit <ferruh.yigit@intel.com>

---
V2:
 - Rebased onto master
 - Changed commit subject and description
---
 lib/librte_mbuf/rte_mbuf.h       | 2 +-
 lib/librte_mempool/rte_mempool.h | 4 ++--
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/lib/librte_mbuf/rte_mbuf.h b/lib/librte_mbuf/rte_mbuf.h
index 219b110b7..6d080527f 100644
--- a/lib/librte_mbuf/rte_mbuf.h
+++ b/lib/librte_mbuf/rte_mbuf.h
@@ -1535,7 +1535,7 @@ static inline int rte_pktmbuf_trim(struct rte_mbuf *m, uint16_t len)
 static inline int rte_pktmbuf_is_contiguous(const struct rte_mbuf *m)
 {
 	__rte_mbuf_sanity_check(m, 1);
-	return !!(m->nb_segs == 1);
+	return m->nb_segs == 1;
 }
 
 /**
diff --git a/lib/librte_mempool/rte_mempool.h b/lib/librte_mempool/rte_mempool.h
index f81152af9..e588c5d9b 100644
--- a/lib/librte_mempool/rte_mempool.h
+++ b/lib/librte_mempool/rte_mempool.h
@@ -1653,7 +1653,7 @@ rte_mempool_in_use_count(const struct rte_mempool *mp);
 static inline int
 rte_mempool_full(const struct rte_mempool *mp)
 {
-	return !!(rte_mempool_avail_count(mp) == mp->size);
+	return rte_mempool_avail_count(mp) == mp->size;
 }
 
 /**
@@ -1672,7 +1672,7 @@ rte_mempool_full(const struct rte_mempool *mp)
 static inline int
 rte_mempool_empty(const struct rte_mempool *mp)
 {
-	return !!(rte_mempool_avail_count(mp) == 0);
+	return rte_mempool_avail_count(mp) == 0;
 }
 
 /**
-- 
2.17.1


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [dpdk-dev] [PATCH v2] lib: fix unnecessary double negation
  2020-02-14 16:17 ` [dpdk-dev] [PATCH v2] lib: fix unnecessary double negation Ciara Power
@ 2020-02-14 16:39   ` David Marchand
  0 siblings, 0 replies; 5+ messages in thread
From: David Marchand @ 2020-02-14 16:39 UTC (permalink / raw)
  To: Ciara Power
  Cc: Olivier Matz, Andrew Rybchenko, dev, Bruce Richardson, dpdk stable

On Fri, Feb 14, 2020 at 5:28 PM Ciara Power <ciara.power@intel.com> wrote:
>
> An equality expression already returns either 0 or 1.
> There is no need to use double negation for these cases.
>
> Fixes: ea672a8b1655 ("mbuf: remove the rte_pktmbuf structure")
> Fixes: a0fd91cefcc0 ("mempool: rename functions with confusing names")
> Cc: stable@dpdk.org
>
> Signed-off-by: Ciara Power <ciara.power@intel.com>
> Acked-by: Olivier Matz <olivier.matz@6wind.com>
> Reviewed-by: Ferruh Yigit <ferruh.yigit@intel.com>

Applied, thanks.


--
David Marchand


^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, back to index

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-12-02  9:15 [dpdk-dev] [PATCH] lib: fix unnecessary boolean casts Ciara Power
2019-12-02 11:58 ` [dpdk-dev] [dpdk-stable] " Ferruh Yigit
2019-12-26 16:21 ` [dpdk-dev] " Olivier Matz
2020-02-14 16:17 ` [dpdk-dev] [PATCH v2] lib: fix unnecessary double negation Ciara Power
2020-02-14 16:39   ` David Marchand

DPDK patches and discussions

Archives are clonable:
	git clone --mirror http://inbox.dpdk.org/dev/0 dev/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 dev dev/ http://inbox.dpdk.org/dev \
		dev@dpdk.org
	public-inbox-index dev


Newsgroup available over NNTP:
	nntp://inbox.dpdk.org/inbox.dpdk.dev


AGPL code for this site: git clone https://public-inbox.org/ public-inbox