remove double parenthesis
cover remove double parenthesis
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(-)
Signature · 1 line
2.11.0
PATCH 1/5 bnx2x: remove (redundant) parenthesis
From: Stephen Hemminger <[email protected]>
No need for extra parentheis around simple if expresssion
--- drivers/net/bnx2x/bnx2x.c | 2 +- drivers/net/bnx2x/ecore_sp.c | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-)
drivers/net/bnx2x/bnx2x.c +1 -1
@@ -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 ; }
drivers/net/bnx2x/ecore_sp.c +2 -2
@@ -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
Signature · 1 line
2.11.0
PATCH 2/5 kni: remove (redundant) parenthesis
In reply to Stephen HemmingerFrom: Stephen Hemminger <[email protected]>
Don't need parens on simple if expression
--- 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(-)
lib/librte_eal/linuxapp/kni/ethtool/igb/igb_main.c +2 -2
@@ -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 ) {
lib/librte_eal/linuxapp/kni/ethtool/ixgbe/ixgbe_common.c +3 -3
@@ -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. */
Signature · 1 line
2.11.0
PATCH 3/5 ethdev: remove (redundant) parenthesis
In reply to Stephen HemmingerObvious extra parenthesis do not help readability
--- lib/librte_ether/rte_ethdev.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
lib/librte_ether/rte_ethdev.c +2 -2
@@ -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 ) {
Signature · 1 line
2.11.0
PATCH 4/5 distributor: remove (unnecessary) parenthesis
In reply to Stephen Hemminger--- lib/librte_distributor/rte_distributor.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
lib/librte_distributor/rte_distributor.c +1 -1
@@ -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); }
Signature · 1 line
2.11.0
PATCH 5/5 loadbalancer: remove (unnecessary) parenthesis
In reply to Stephen Hemminger--- examples/load_balancer/config.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
examples/load_balancer/config.c +1 -1
@@ -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 ; }
Signature · 1 line
2.11.0
Thomas Monjalon
Applied15/12/2017 00:32, Stephen Hemminger:
Quoted 11 lines
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