DPDK patches and discussions
 help / color / mirror / Atom feed
* [dpdk-dev] [PATCH 0/5] remove double parenthesis
@ 2017-12-14 23:32 Stephen Hemminger
  2017-12-14 23:32 ` [dpdk-dev] [PATCH 1/5] bnx2x: remove (redundant) parenthesis Stephen Hemminger
                   ` (5 more replies)
  0 siblings, 6 replies; 7+ messages in thread
From: Stephen Hemminger @ 2017-12-14 23:32 UTC (permalink / raw)
  To: dev; +Cc: Stephen Hemminger

Noticed in ethdev an obvious case of extra parenthesis so
went hunting for others as well. There seems to be some weird
coding standard that loves extra parenthesis (or developers
don't understand basic C precedence rules).

Stephen Hemminger (5):
  bnx2x: remove (redundant) parenthesis
  kni: remove (redundant) parenthesis
  ethdev: remove (redundant) parenthesis
  distributor: remove (unnecessary) parenthesis
  loadbalancer: remove (unnecessary) parenthesis

 drivers/net/bnx2x/bnx2x.c                                | 2 +-
 drivers/net/bnx2x/ecore_sp.c                             | 4 ++--
 examples/load_balancer/config.c                          | 2 +-
 lib/librte_distributor/rte_distributor.c                 | 2 +-
 lib/librte_eal/linuxapp/kni/ethtool/igb/igb_main.c       | 4 ++--
 lib/librte_eal/linuxapp/kni/ethtool/ixgbe/ixgbe_common.c | 6 +++---
 lib/librte_ether/rte_ethdev.c                            | 4 ++--
 7 files changed, 12 insertions(+), 12 deletions(-)

-- 
2.11.0

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

* [dpdk-dev] [PATCH 1/5] bnx2x: remove (redundant) parenthesis
  2017-12-14 23:32 [dpdk-dev] [PATCH 0/5] remove double parenthesis Stephen Hemminger
@ 2017-12-14 23:32 ` Stephen Hemminger
  2017-12-14 23:32 ` [dpdk-dev] [PATCH 2/5] kni: " Stephen Hemminger
                   ` (4 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: Stephen Hemminger @ 2017-12-14 23:32 UTC (permalink / raw)
  To: dev; +Cc: Stephen Hemminger, Stephen Hemminger

From: Stephen Hemminger <sthemmin@microsoft.com>

No need for extra parentheis around simple if expresssion

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
 drivers/net/bnx2x/bnx2x.c    | 2 +-
 drivers/net/bnx2x/ecore_sp.c | 4 ++--
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/net/bnx2x/bnx2x.c b/drivers/net/bnx2x/bnx2x.c
index 9394f6c50c00..1b36cab32f5a 100644
--- a/drivers/net/bnx2x/bnx2x.c
+++ b/drivers/net/bnx2x/bnx2x.c
@@ -8137,7 +8137,7 @@ static int bnx2x_get_igu_cam_info(struct bnx2x_softc *sc)
 			continue;
 		}
 		fid = IGU_FID(val);
-		if ((fid & IGU_FID_ENCODE_IS_PF)) {
+		if (fid & IGU_FID_ENCODE_IS_PF) {
 			if ((fid & IGU_FID_PF_NUM_MASK) != pfid) {
 				continue;
 			}
diff --git a/drivers/net/bnx2x/ecore_sp.c b/drivers/net/bnx2x/ecore_sp.c
index ef7f9fea4736..a75a7fa46f69 100644
--- a/drivers/net/bnx2x/ecore_sp.c
+++ b/drivers/net/bnx2x/ecore_sp.c
@@ -3402,7 +3402,7 @@ void ecore_init_mac_credit_pool(struct bnx2x_softc *sc,
 		/* CAM credit is equally divided between all active functions
 		 * on the PORT!.
 		 */
-		if ((func_num > 0)) {
+		if (func_num > 0) {
 			if (!CHIP_REV_IS_SLOW(sc))
 				cam_sz = (MAX_MAC_CREDIT_E1H / (2 * func_num));
 			else
@@ -3419,7 +3419,7 @@ void ecore_init_mac_credit_pool(struct bnx2x_softc *sc,
 		 * CAM credit is equaly divided between all active functions
 		 * on the PATH.
 		 */
-		if ((func_num > 0)) {
+		if (func_num > 0) {
 			if (!CHIP_REV_IS_SLOW(sc))
 				cam_sz = (MAX_MAC_CREDIT_E2 / func_num);
 			else
-- 
2.11.0

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

* [dpdk-dev] [PATCH 2/5] kni: remove (redundant) parenthesis
  2017-12-14 23:32 [dpdk-dev] [PATCH 0/5] remove double parenthesis Stephen Hemminger
  2017-12-14 23:32 ` [dpdk-dev] [PATCH 1/5] bnx2x: remove (redundant) parenthesis Stephen Hemminger
@ 2017-12-14 23:32 ` Stephen Hemminger
  2017-12-14 23:32 ` [dpdk-dev] [PATCH 3/5] ethdev: " Stephen Hemminger
                   ` (3 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: Stephen Hemminger @ 2017-12-14 23:32 UTC (permalink / raw)
  To: dev; +Cc: Stephen Hemminger, Stephen Hemminger

From: Stephen Hemminger <sthemmin@microsoft.com>

Don't need parens on simple if expression

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
 lib/librte_eal/linuxapp/kni/ethtool/igb/igb_main.c       | 4 ++--
 lib/librte_eal/linuxapp/kni/ethtool/ixgbe/ixgbe_common.c | 6 +++---
 2 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/lib/librte_eal/linuxapp/kni/ethtool/igb/igb_main.c b/lib/librte_eal/linuxapp/kni/ethtool/igb/igb_main.c
index 99338c5c8071..089fd4962a07 100644
--- a/lib/librte_eal/linuxapp/kni/ethtool/igb/igb_main.c
+++ b/lib/librte_eal/linuxapp/kni/ethtool/igb/igb_main.c
@@ -2993,7 +2993,7 @@ static int __devinit igb_probe(struct pci_dev *pdev,
 		case e1000_i211:
 			/* Enable EEE for internal copper PHY devices */
 			err = e1000_set_eee_i350(hw);
-			if ((!err) &&
+			if (!err &&
 			    (adapter->flags & IGB_FLAG_EEE))
 				adapter->eee_advert =
 					MDIO_EEE_100TX | MDIO_EEE_1000T;
@@ -4988,7 +4988,7 @@ static void igb_update_itr(struct igb_q_vector *q_vector,
 				itrval = bulk_latency;
 			} else if ((packets < 10) || ((bytes/packets) > 1200)) {
 				itrval = bulk_latency;
-			} else if ((packets > 35)) {
+			} else if (packets > 35) {
 				itrval = lowest_latency;
 			}
 		} else if (bytes/packets > 2000) {
diff --git a/lib/librte_eal/linuxapp/kni/ethtool/ixgbe/ixgbe_common.c b/lib/librte_eal/linuxapp/kni/ethtool/ixgbe/ixgbe_common.c
index 2c861de5d6e7..1a1cfe574cd1 100644
--- a/lib/librte_eal/linuxapp/kni/ethtool/ixgbe/ixgbe_common.c
+++ b/lib/librte_eal/linuxapp/kni/ethtool/ixgbe/ixgbe_common.c
@@ -2415,7 +2415,7 @@ s32 ixgbe_fc_enable_generic(struct ixgbe_hw *hw)
 static s32 ixgbe_negotiate_fc(struct ixgbe_hw *hw, u32 adv_reg, u32 lp_reg,
 			      u32 adv_sym, u32 adv_asm, u32 lp_sym, u32 lp_asm)
 {
-	if ((!(adv_reg)) ||  (!(lp_reg)))
+	if (!adv_reg || !lp_reg)
 		return IXGBE_ERR_FC_NOT_NEGOTIATED;
 
 	if ((adv_reg & adv_sym) && (lp_reg & lp_sym)) {
@@ -3279,7 +3279,7 @@ s32 ixgbe_set_vfta_generic(struct ixgbe_hw *hw, u32 vlan, u32 vind,
 			vfta_changed = true;
 		}
 	} else {
-		if ((vfta & targetbit)) {
+		if (vfta & targetbit) {
 			vfta &= ~targetbit;
 			vfta_changed = true;
 		}
@@ -3392,7 +3392,7 @@ s32 ixgbe_set_vlvf_generic(struct ixgbe_hw *hw, u32 vlan, u32 vind,
 		if (bits) {
 			IXGBE_WRITE_REG(hw, IXGBE_VLVF(vlvf_index),
 					(IXGBE_VLVF_VIEN | vlan));
-			if ((!vlan_on) && (vfta_changed != NULL)) {
+			if (!vlan_on && (vfta_changed != NULL)) {
 				/* someone wants to clear the vfta entry
 				 * but some pools/VFs are still using it.
 				 * Ignore it. */
-- 
2.11.0

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

* [dpdk-dev] [PATCH 3/5] ethdev: remove (redundant) parenthesis
  2017-12-14 23:32 [dpdk-dev] [PATCH 0/5] remove double parenthesis Stephen Hemminger
  2017-12-14 23:32 ` [dpdk-dev] [PATCH 1/5] bnx2x: remove (redundant) parenthesis Stephen Hemminger
  2017-12-14 23:32 ` [dpdk-dev] [PATCH 2/5] kni: " Stephen Hemminger
@ 2017-12-14 23:32 ` Stephen Hemminger
  2017-12-14 23:32 ` [dpdk-dev] [PATCH 4/5] distributor: remove (unnecessary) parenthesis Stephen Hemminger
                   ` (2 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: Stephen Hemminger @ 2017-12-14 23:32 UTC (permalink / raw)
  To: dev; +Cc: Stephen Hemminger

Obvious extra parenthesis do not help readability

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

diff --git a/lib/librte_ether/rte_ethdev.c b/lib/librte_ether/rte_ethdev.c
index 318af2869743..c53b28bf80fd 100644
--- a/lib/librte_ether/rte_ethdev.c
+++ b/lib/librte_ether/rte_ethdev.c
@@ -810,7 +810,7 @@ rte_eth_dev_configure(uint16_t port_id, uint16_t nb_rx_q, uint16_t nb_tx_q,
 	 * Convert between the offloads API to enable PMDs to support
 	 * only one of them.
 	 */
-	if ((dev_conf->rxmode.ignore_offload_bitfield == 0)) {
+	if (dev_conf->rxmode.ignore_offload_bitfield == 0) {
 		rte_eth_convert_rx_offload_bitfield(
 				&dev_conf->rxmode, &local_conf.rxmode.offloads);
 	} else {
@@ -2693,7 +2693,7 @@ rte_eth_dev_uc_hash_table_set(uint16_t port_id, struct ether_addr *addr,
 
 	index = get_hash_mac_addr_index(port_id, addr);
 	/* Check if it's already there, and do nothing */
-	if ((index >= 0) && (on))
+	if ((index >= 0) && on)
 		return 0;
 
 	if (index < 0) {
-- 
2.11.0

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

* [dpdk-dev] [PATCH 4/5] distributor: remove (unnecessary) parenthesis
  2017-12-14 23:32 [dpdk-dev] [PATCH 0/5] remove double parenthesis Stephen Hemminger
                   ` (2 preceding siblings ...)
  2017-12-14 23:32 ` [dpdk-dev] [PATCH 3/5] ethdev: " Stephen Hemminger
@ 2017-12-14 23:32 ` Stephen Hemminger
  2017-12-14 23:32 ` [dpdk-dev] [PATCH 5/5] loadbalancer: " Stephen Hemminger
  2018-01-05 21:09 ` [dpdk-dev] [PATCH 0/5] remove double parenthesis Thomas Monjalon
  5 siblings, 0 replies; 7+ messages in thread
From: Stephen Hemminger @ 2017-12-14 23:32 UTC (permalink / raw)
  To: dev; +Cc: Stephen Hemminger

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
 lib/librte_distributor/rte_distributor.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/lib/librte_distributor/rte_distributor.c b/lib/librte_distributor/rte_distributor.c
index 6ad230131502..b71f254c3cbc 100644
--- a/lib/librte_distributor/rte_distributor.c
+++ b/lib/librte_distributor/rte_distributor.c
@@ -382,7 +382,7 @@ rte_distributor_process_v1705(struct rte_distributor *d,
 	if (unlikely(num_mbufs == 0)) {
 		/* Flush out all non-full cache-lines to workers. */
 		for (wid = 0 ; wid < d->num_workers; wid++) {
-			if ((d->bufs[wid].bufptr64[0] & RTE_DISTRIB_GET_BUF)) {
+			if (d->bufs[wid].bufptr64[0] & RTE_DISTRIB_GET_BUF) {
 				release(d, wid);
 				handle_returns(d, wid);
 			}
-- 
2.11.0

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

* [dpdk-dev] [PATCH 5/5] loadbalancer: remove (unnecessary) parenthesis
  2017-12-14 23:32 [dpdk-dev] [PATCH 0/5] remove double parenthesis Stephen Hemminger
                   ` (3 preceding siblings ...)
  2017-12-14 23:32 ` [dpdk-dev] [PATCH 4/5] distributor: remove (unnecessary) parenthesis Stephen Hemminger
@ 2017-12-14 23:32 ` Stephen Hemminger
  2018-01-05 21:09 ` [dpdk-dev] [PATCH 0/5] remove double parenthesis Thomas Monjalon
  5 siblings, 0 replies; 7+ messages in thread
From: Stephen Hemminger @ 2017-12-14 23:32 UTC (permalink / raw)
  To: dev; +Cc: Stephen Hemminger

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
 examples/load_balancer/config.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/examples/load_balancer/config.c b/examples/load_balancer/config.c
index 755a86e48878..f3402eae2c85 100644
--- a/examples/load_balancer/config.c
+++ b/examples/load_balancer/config.c
@@ -357,7 +357,7 @@ parse_arg_w(const char *arg)
 
 		errno = 0;
 		lcore = strtoul(p, NULL, 0);
-		if ((errno != 0)) {
+		if (errno != 0) {
 			return -2;
 		}
 
-- 
2.11.0

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

* Re: [dpdk-dev] [PATCH 0/5] remove double parenthesis
  2017-12-14 23:32 [dpdk-dev] [PATCH 0/5] remove double parenthesis Stephen Hemminger
                   ` (4 preceding siblings ...)
  2017-12-14 23:32 ` [dpdk-dev] [PATCH 5/5] loadbalancer: " Stephen Hemminger
@ 2018-01-05 21:09 ` Thomas Monjalon
  5 siblings, 0 replies; 7+ messages in thread
From: Thomas Monjalon @ 2018-01-05 21:09 UTC (permalink / raw)
  To: Stephen Hemminger; +Cc: dev

15/12/2017 00:32, Stephen Hemminger:
> Noticed in ethdev an obvious case of extra parenthesis so
> went hunting for others as well. There seems to be some weird
> coding standard that loves extra parenthesis (or developers
> don't understand basic C precedence rules).
> 
> Stephen Hemminger (5):
>   bnx2x: remove (redundant) parenthesis
>   kni: remove (redundant) parenthesis
>   ethdev: remove (redundant) parenthesis
>   distributor: remove (unnecessary) parenthesis
>   loadbalancer: remove (unnecessary) parenthesis

Applied, thanks

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

end of thread, other threads:[~2018-01-05 21:09 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-12-14 23:32 [dpdk-dev] [PATCH 0/5] remove double parenthesis Stephen Hemminger
2017-12-14 23:32 ` [dpdk-dev] [PATCH 1/5] bnx2x: remove (redundant) parenthesis Stephen Hemminger
2017-12-14 23:32 ` [dpdk-dev] [PATCH 2/5] kni: " Stephen Hemminger
2017-12-14 23:32 ` [dpdk-dev] [PATCH 3/5] ethdev: " Stephen Hemminger
2017-12-14 23:32 ` [dpdk-dev] [PATCH 4/5] distributor: remove (unnecessary) parenthesis Stephen Hemminger
2017-12-14 23:32 ` [dpdk-dev] [PATCH 5/5] loadbalancer: " Stephen Hemminger
2018-01-05 21:09 ` [dpdk-dev] [PATCH 0/5] remove double parenthesis Thomas Monjalon

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).