Skip to contentSkip to conversation

staging: rtlwifi: phydm: Remove parentheses

PATCH Superseded Nishka Dasgupta 2 participants 4 messages Mar 30, 2019 Staging

v3 of 5 Superseded Latest is v5 →

lore
Share & tools
lore
#0 lore raw

PATCH v3 1/1 staging: rtlwifi: phydm: Remove parentheses

Remove unnecessary parentheses on the right hand side and simplify expression from 'status = status & <expression>' to 'status &= expression' to make code more readable.
Issue first detected using Coccinelle.

---
Changes in v3:
- Move explanation of simplification to commit log.

 drivers/staging/rtlwifi/phydm/phydm_debug.c | 18 ++++++++----------
 1 file changed, 8 insertions(+), 10 deletions(-)
drivers/staging/rtlwifi/phydm/phydm_debug.c +8 -10
index 91f2c054d83b..13b34dc33011 100644
@@ -51,20 +51,18 @@ static inline void phydm_check_dmval_txagc(struct phy_dm_struct *dm, u32 used,
 				      (power_index << 16) | (power_index << 8) |
 				      (power_index);
 			for (i = 0; i < ODM_RATEVHTSS2MCS9; i += 4)
-				status = (status &
-					  phydm_api_set_txagc(
-						  dm, power_index,
-						  (enum odm_rf_radio_path)
+				status &= phydm_api_set_txagc(
+						   dm, power_index,
+						   (enum odm_rf_radio_path)
 							  dm_value[1],
-						  i, false));
+						   i, false);
 		} else if (dm->support_ic_type & ODM_RTL8197F) {
 			for (i = 0; i <= ODM_RATEMCS15; i++)
-				status = (status &
-					  phydm_api_set_txagc(
-						  dm, power_index,
-						  (enum odm_rf_radio_path)
+				status &= phydm_api_set_txagc(
+						   dm, power_index,
+						   (enum odm_rf_radio_path)
 							  dm_value[1],
-						  i, false));
+						   i, false);
 		}
 
 		if (status)
Signature · 1 line
2.19.1
#1 lore raw
Quoted 3 lines · Nishka Dasgupta' via outreachy-kernel

Remove unnecessary parentheses on the right hand side and simplify expression from 'status = status & <expression>' to 'status &= expression' to make code more readable.

It should be two patches, since you have done two things.

There is a third thing to do, which is get rid of the checkpatch error about a ( at the end of a line. There is plenty of room for the first two arguments, as far as I can see.

julia

Quoted 53 lines

Issue first detected using Coccinelle.

---
Changes in v3:
- Move explanation of simplification to commit log.

 drivers/staging/rtlwifi/phydm/phydm_debug.c | 18 ++++++++----------
 1 file changed, 8 insertions(+), 10 deletions(-)
drivers/staging/rtlwifi/phydm/phydm_debug.c +8 -11
index 91f2c054d83b..13b34dc33011 100644
@@ -51,20 +51,18 @@ static inline void phydm_check_dmval_txagc(struct phy_dm_struct *dm, u32 used,
 				      (power_index << 16) | (power_index << 8) |
 				      (power_index);
 			for (i = 0; i < ODM_RATEVHTSS2MCS9; i += 4)
-				status = (status &
-					  phydm_api_set_txagc(
-						  dm, power_index,
-						  (enum odm_rf_radio_path)
+				status &= phydm_api_set_txagc(
+						   dm, power_index,
+						   (enum odm_rf_radio_path)
 							  dm_value[1],
-						  i, false));
+						   i, false);
 		} else if (dm->support_ic_type & ODM_RTL8197F) {
 			for (i = 0; i <= ODM_RATEMCS15; i++)
-				status = (status &
-					  phydm_api_set_txagc(
-						  dm, power_index,
-						  (enum odm_rf_radio_path)
+				status &= phydm_api_set_txagc(
+						   dm, power_index,
+						   (enum odm_rf_radio_path)
 							  dm_value[1],
-						  i, false));
+						   i, false);
 		}
 
 		if (status)
--

2.19.1

--
You received this message because you are subscribed to the Google Groups "outreachy-kernel" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected].
To view this discussion on the web visit https://groups.google.com/d/msgid/outreachy-kernel/20190330155517.2194-1-nishka.dasgupta%40yahoo.com.
For more options, visit https://groups.google.com/d/optout.

#2 lore raw
Quoted 9 lines · Julia Lawall
Quoted 3 lines · Nishka Dasgupta' via outreachy-kernel

Remove unnecessary parentheses on the right hand side and simplify expression from 'status = status & <expression>' to 'status &= expression' to make code more readable.

It should be two patches, since you have done two things.

Okay, I will resend it.

Quoted 3 lines

There is a third thing to do, which is get rid of the checkpatch error about a ( at the end of a line. There is plenty of room for the first two arguments, as far as I can see.

The first two arguments fit. The problem is that the arguments have to be aligned (as far as I know), and the third argument (even just the typecast) cannot fit after the open bracket of the function without triggering the 80-character warning. I thought a checkpatch check about a ( at the end of the line might be preferable to a warning about line exceeding 80 characters? Given the existing alignment and indentation, I don't see how we can avoid both the check and the warning without adding new variables (i.e by doing the enum typecast before). What should I do?
- Nishka

Quoted 55 lines

julia

Quoted 53 lines

Issue first detected using Coccinelle.

---
Changes in v3:
- Move explanation of simplification to commit log.

  drivers/staging/rtlwifi/phydm/phydm_debug.c | 18 ++++++++----------
  1 file changed, 8 insertions(+), 10 deletions(-)
drivers/staging/rtlwifi/phydm/phydm_debug.c +8 -11
index 91f2c054d83b..13b34dc33011 100644
@@ -51,20 +51,18 @@ static inline void phydm_check_dmval_txagc(struct phy_dm_struct *dm, u32 used,
  				      (power_index << 16) | (power_index << 8) |
  				      (power_index);
  			for (i = 0; i < ODM_RATEVHTSS2MCS9; i += 4)
-				status = (status &
-					  phydm_api_set_txagc(
-						  dm, power_index,
-						  (enum odm_rf_radio_path)
+				status &= phydm_api_set_txagc(
+						   dm, power_index,
+						   (enum odm_rf_radio_path)
  							  dm_value[1],
-						  i, false));
+						   i, false);
  		} else if (dm->support_ic_type & ODM_RTL8197F) {
  			for (i = 0; i <= ODM_RATEMCS15; i++)
-				status = (status &
-					  phydm_api_set_txagc(
-						  dm, power_index,
-						  (enum odm_rf_radio_path)
+				status &= phydm_api_set_txagc(
+						   dm, power_index,
+						   (enum odm_rf_radio_path)
  							  dm_value[1],
-						  i, false));
+						   i, false);
  		}
 
  		if (status)
--

2.19.1

--
You received this message because you are subscribed to the Google Groups "outreachy-kernel" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected].
To view this discussion on the web visit https://groups.google.com/d/msgid/outreachy-kernel/20190330155517.2194-1-nishka.dasgupta%40yahoo.com.
For more options, visit https://groups.google.com/d/optout.

#3 lore raw
Quoted 19 lines · NIshka Dasgupta
Quoted 9 lines · Julia Lawall
Quoted 3 lines · Nishka Dasgupta' via outreachy-kernel

Remove unnecessary parentheses on the right hand side and simplify expression from 'status = status & <expression>' to 'status &= expression' to make code more readable.

It should be two patches, since you have done two things.

Okay, I will resend it.

Quoted 3 lines

There is a third thing to do, which is get rid of the checkpatch error about a ( at the end of a line. There is plenty of room for the first two arguments, as far as I can see.

Quoted 8 lines

The first two arguments fit. The problem is that the arguments have to be aligned (as far as I know), and the third argument (even just the typecast) cannot fit after the open bracket of the function without triggering the 80-character warning. I thought a checkpatch check about a ( at the end of the line might be preferable to a warning about line exceeding 80 characters? Given the existing alignment and indentation, I don't see how we can avoid both the check and the warning without adding new variables (i.e by doing the enum typecast before). What should I do?

Ignore the warning about the arguments needing to be aligned.

julia

Quoted 64 lines

- Nishka

Quoted 61 lines

julia

Quoted 59 lines

Issue first detected using Coccinelle.

---
Changes in v3:
- Move explanation of simplification to commit log.

  drivers/staging/rtlwifi/phydm/phydm_debug.c | 18 ++++++++----------
  1 file changed, 8 insertions(+), 10 deletions(-)
drivers/staging/rtlwifi/phydm/phydm_debug.c +0 -0
index 91f2c054d83b..13b34dc33011 100644
@@ -51,20 +51,18 @@ static inline void phydm_check_dmval_txagc(struct
 phy_dm_struct *dm, u32 used,
  				      (power_index << 16) | (power_index << 8)

|
(power_index);
for (i = 0; i < ODM_RATEVHTSS2MCS9; i += 4)

drivers/staging/rtlwifi/phydm/phydm_debug.c +8 -11
-				status = (status &
-					  phydm_api_set_txagc(
-						  dm, power_index,
-						  (enum odm_rf_radio_path)
+				status &= phydm_api_set_txagc(
+						   dm, power_index,
+						   (enum odm_rf_radio_path)
  							  dm_value[1],
-						  i, false));
+						   i, false);
  		} else if (dm->support_ic_type & ODM_RTL8197F) {
  			for (i = 0; i <= ODM_RATEMCS15; i++)
-				status = (status &
-					  phydm_api_set_txagc(
-						  dm, power_index,
-						  (enum odm_rf_radio_path)
+				status &= phydm_api_set_txagc(
+						   dm, power_index,
+						   (enum odm_rf_radio_path)
  							  dm_value[1],
-						  i, false));
+						   i, false);
  		}
 
  		if (status)
--

2.19.1

--
You received this message because you are subscribed to the Google Groups "outreachy-kernel" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [email protected].
To post to this group, send email to [email protected]. To view this discussion on the web visit
https://groups.google.com/d/msgid/outreachy-kernel/20190330155517.2194-1-nishka.dasgupta%40yahoo.com.
For more options, visit https://groups.google.com/d/optout.