Skip to contentSkip to conversation

staging: vt6655: Remove else after return

PATCH Superseded Marcos Antonio de Jesus Filho 2 participants 10 messages Oct 31, 2020 Staging

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

cover staging: vt6655: Remove else after return

This patchset removes multiples useless else statements after return statements. Reported by check patch.

Observation
-----------

After cleaning up the code I noticed that the code from 530 to 548 repeats at 551,569 and that it can be removed and one of the conditional statements can be simplified.

Marcos Antonio de Jesus Filho (3):
staging: vt6655: Remove useless else
staging: vt6655: Remove useless else
staging: vt6655: Remove useless else

 drivers/staging/vt6655/rxtx.c | 99 ++++++++++++++++++-----------------
 1 file changed, 51 insertions(+), 48 deletions(-)
Signature · 1 line
2.28.0
#1 lore raw

PATCH 1/3 staging: vt6655: Remove useless else

The else statement is not useful due to the presence of a return statement on the if block. Remove the else statement and adjust the indentation of the code. Reported by checkpatch.

---
 drivers/staging/vt6655/rxtx.c | 48 ++++++++++++++++++-----------------
 1 file changed, 25 insertions(+), 23 deletions(-)
drivers/staging/vt6655/rxtx.c +25 -23
index 477d19314634..c1da54314fbd 100644
@@ -444,6 +444,9 @@ s_uFillDataHead(
 		return 0;
 
 	if (byPktType == PK_TYPE_11GB || byPktType == PK_TYPE_11GA) {
+		/* Auto Fallback */
+		struct vnt_tx_datahead_g_fb *buf = pTxDataHead;
+
 		if (byFBOption == AUTO_FB_NONE) {
 			struct vnt_tx_datahead_g *buf = pTxDataHead;
 			/* Get SignalField, ServiceField & Length */
@@ -477,31 +480,30 @@ s_uFillDataHead(
 			buf->time_stamp_off_b = vnt_time_stamp_off(pDevice, pDevice->byTopCCKBasicRate);
 
 			return buf->duration_a;
-		} else {
-			/* Auto Fallback */
-			struct vnt_tx_datahead_g_fb *buf = pTxDataHead;
-			/* Get SignalField, ServiceField & Length */
-			vnt_get_phy_field(pDevice, cbFrameLength, wCurrentRate,
-					  byPktType, &buf->a);
-
-			vnt_get_phy_field(pDevice, cbFrameLength,
-					  pDevice->byTopCCKBasicRate,
-					  PK_TYPE_11B, &buf->b);
-			/* Get Duration and TimeStamp */
-			buf->duration_a = cpu_to_le16((u16)s_uGetDataDuration(pDevice, DATADUR_A, cbFrameLength, byPktType,
-									      wCurrentRate, bNeedAck, uFragIdx, cbLastFragmentSize, uMACfragNum, byFBOption));
-			buf->duration_b = cpu_to_le16((u16)s_uGetDataDuration(pDevice, DATADUR_B, cbFrameLength, PK_TYPE_11B,
-									       pDevice->byTopCCKBasicRate, bNeedAck, uFragIdx, cbLastFragmentSize, uMACfragNum, byFBOption));
-			buf->duration_a_f0 = cpu_to_le16((u16)s_uGetDataDuration(pDevice, DATADUR_A_F0, cbFrameLength, byPktType,
-										  wCurrentRate, bNeedAck, uFragIdx, cbLastFragmentSize, uMACfragNum, byFBOption));
-			buf->duration_a_f1 = cpu_to_le16((u16)s_uGetDataDuration(pDevice, DATADUR_A_F1, cbFrameLength, byPktType,
-										 wCurrentRate, bNeedAck, uFragIdx, cbLastFragmentSize, uMACfragNum, byFBOption));
+		}
 
-			buf->time_stamp_off_a = vnt_time_stamp_off(pDevice, wCurrentRate);
-			buf->time_stamp_off_b = vnt_time_stamp_off(pDevice, pDevice->byTopCCKBasicRate);
+		/* Get SignalField, ServiceField & Length */
+		vnt_get_phy_field(pDevice, cbFrameLength, wCurrentRate,
+				  byPktType, &buf->a);
 
-			return buf->duration_a;
-		} /* if (byFBOption == AUTO_FB_NONE) */
+		vnt_get_phy_field(pDevice, cbFrameLength,
+				  pDevice->byTopCCKBasicRate,
+				  PK_TYPE_11B, &buf->b);
+		/* Get Duration and TimeStamp */
+		buf->duration_a = cpu_to_le16((u16)s_uGetDataDuration(pDevice, DATADUR_A, cbFrameLength, byPktType,
+								      wCurrentRate, bNeedAck, uFragIdx, cbLastFragmentSize, uMACfragNum, byFBOption));
+		buf->duration_b = cpu_to_le16((u16)s_uGetDataDuration(pDevice, DATADUR_B, cbFrameLength, PK_TYPE_11B,
+								       pDevice->byTopCCKBasicRate, bNeedAck, uFragIdx, cbLastFragmentSize, uMACfragNum, byFBOption));
+		buf->duration_a_f0 = cpu_to_le16((u16)s_uGetDataDuration(pDevice, DATADUR_A_F0, cbFrameLength, byPktType,
+									  wCurrentRate, bNeedAck, uFragIdx, cbLastFragmentSize, uMACfragNum, byFBOption));
+		buf->duration_a_f1 = cpu_to_le16((u16)s_uGetDataDuration(pDevice, DATADUR_A_F1, cbFrameLength, byPktType,
+									 wCurrentRate, bNeedAck, uFragIdx, cbLastFragmentSize, uMACfragNum, byFBOption));
+
+		buf->time_stamp_off_a = vnt_time_stamp_off(pDevice, wCurrentRate);
+		buf->time_stamp_off_b = vnt_time_stamp_off(pDevice, pDevice->byTopCCKBasicRate);
+
+		return buf->duration_a;
+		  /* if (byFBOption == AUTO_FB_NONE) */
 	} else if (byPktType == PK_TYPE_11A) {
 		if (byFBOption != AUTO_FB_NONE) {
 			/* Auto Fallback */
Signature · 1 line
2.28.0
#2 lore raw

PATCH 2/3 staging: vt6655: Remove useless else

In reply to Marcos Antonio de Jesus Filho

The else statement is not useful due to the presence of a return statement on the if block. Remove the else statement and adjust the indentation of the code. Reported by checkpatch.

---
 drivers/staging/vt6655/rxtx.c | 37 ++++++++++++++++++-----------------
 1 file changed, 19 insertions(+), 18 deletions(-)
drivers/staging/vt6655/rxtx.c +19 -18
index c1da54314fbd..9db4317f9a42 100644
@@ -505,6 +505,8 @@ s_uFillDataHead(
 		return buf->duration_a;
 		  /* if (byFBOption == AUTO_FB_NONE) */
 	} else if (byPktType == PK_TYPE_11A) {
+		struct vnt_tx_datahead_ab *buf = pTxDataHead;
+
 		if (byFBOption != AUTO_FB_NONE) {
 			/* Auto Fallback */
 			struct vnt_tx_datahead_a_fb *buf = pTxDataHead;
@@ -521,28 +523,27 @@ s_uFillDataHead(
 										wCurrentRate, bNeedAck, uFragIdx, cbLastFragmentSize, uMACfragNum, byFBOption));
 			buf->time_stamp_off = vnt_time_stamp_off(pDevice, wCurrentRate);
 			return buf->duration;
-		} else {
-			struct vnt_tx_datahead_ab *buf = pTxDataHead;
-			/* Get SignalField, ServiceField & Length */
-			vnt_get_phy_field(pDevice, cbFrameLength, wCurrentRate,
-					  byPktType, &buf->ab);
+		}
 
-			if (is_pspoll) {
-				__le16 dur = cpu_to_le16(pDevice->current_aid | BIT(14) | BIT(15));
+		/* Get SignalField, ServiceField & Length */
+		vnt_get_phy_field(pDevice, cbFrameLength, wCurrentRate,
+				  byPktType, &buf->ab);
 
-				buf->duration = dur;
-			} else {
-				/* Get Duration and TimeStampOff */
-				buf->duration =
-					cpu_to_le16((u16)s_uGetDataDuration(pDevice, DATADUR_A, cbFrameLength, byPktType,
-									    wCurrentRate, bNeedAck, uFragIdx,
-									    cbLastFragmentSize, uMACfragNum,
-									    byFBOption));
-			}
+		if (is_pspoll) {
+			__le16 dur = cpu_to_le16(pDevice->current_aid | BIT(14) | BIT(15));
 
-			buf->time_stamp_off = vnt_time_stamp_off(pDevice, wCurrentRate);
-			return buf->duration;
+			buf->duration = dur;
+		} else {
+			/* Get Duration and TimeStampOff */
+			buf->duration =
+				cpu_to_le16((u16)s_uGetDataDuration(pDevice, DATADUR_A, cbFrameLength, byPktType,
+								    wCurrentRate, bNeedAck, uFragIdx,
+								    cbLastFragmentSize, uMACfragNum,
+								    byFBOption));
 		}
+
+		buf->time_stamp_off = vnt_time_stamp_off(pDevice, wCurrentRate);
+		return buf->duration;
 	} else {
 		struct vnt_tx_datahead_ab *buf = pTxDataHead;
 		/* Get SignalField, ServiceField & Length */
Signature · 1 line
2.28.0
#3 lore raw

PATCH 3/3 staging: vt6655: Remove useless else

In reply to Marcos Antonio de Jesus Filho

The else statement is not useful due to the presence of a return statement on the if block. Remove the else statement, adjust the indentation of the code and remove useless return statement. Reported by checkpatch.

---
 drivers/staging/vt6655/rxtx.c | 38 +++++++++++++++++------------------
 1 file changed, 19 insertions(+), 19 deletions(-)
drivers/staging/vt6655/rxtx.c +19 -19
index 9db4317f9a42..508e1bd7d76e 100644
@@ -440,6 +440,8 @@ s_uFillDataHead(
 	bool is_pspoll
 )
 {
+	struct vnt_tx_datahead_ab *buf = pTxDataHead;
+
 	if (!pTxDataHead)
 		return 0;
 
@@ -544,29 +546,27 @@ s_uFillDataHead(
 
 		buf->time_stamp_off = vnt_time_stamp_off(pDevice, wCurrentRate);
 		return buf->duration;
-	} else {
-		struct vnt_tx_datahead_ab *buf = pTxDataHead;
-		/* Get SignalField, ServiceField & Length */
-		vnt_get_phy_field(pDevice, cbFrameLength, wCurrentRate,
-				  byPktType, &buf->ab);
+	}
 
-		if (is_pspoll) {
-			__le16 dur = cpu_to_le16(pDevice->current_aid | BIT(14) | BIT(15));
+	/* Get SignalField, ServiceField & Length */
+	vnt_get_phy_field(pDevice, cbFrameLength, wCurrentRate,
+			  byPktType, &buf->ab);
 
-			buf->duration = dur;
-		} else {
-			/* Get Duration and TimeStampOff */
-			buf->duration =
-				cpu_to_le16((u16)s_uGetDataDuration(pDevice, DATADUR_B, cbFrameLength, byPktType,
-								    wCurrentRate, bNeedAck, uFragIdx,
-								    cbLastFragmentSize, uMACfragNum,
-								    byFBOption));
-		}
+	if (is_pspoll) {
+		__le16 dur = cpu_to_le16(pDevice->current_aid | BIT(14) | BIT(15));
 
-		buf->time_stamp_off = vnt_time_stamp_off(pDevice, wCurrentRate);
-		return buf->duration;
+		buf->duration = dur;
+	} else {
+		/* Get Duration and TimeStampOff */
+		buf->duration =
+			cpu_to_le16((u16)s_uGetDataDuration(pDevice, DATADUR_B, cbFrameLength, byPktType,
+							    wCurrentRate, bNeedAck, uFragIdx,
+							    cbLastFragmentSize, uMACfragNum,
+							    byFBOption));
 	}
-	return 0;
+
+	buf->time_stamp_off = vnt_time_stamp_off(pDevice, wCurrentRate);
+	return buf->duration;
 }
 
 static
Signature · 1 line
2.28.0
#4 lore raw

Re: [Outreachy kernel] [PATCH 3/3] staging: vt6655: Remove useless else

Quoted 14 lines · Marcos Antonio de Jesus Filho

The else statement is not useful due to the presence of a return statement on the if block. Remove the else statement, adjust the indentation of the code and remove useless return statement. Reported by checkpatch.

---
 drivers/staging/vt6655/rxtx.c | 38 +++++++++++++++++------------------
 1 file changed, 19 insertions(+), 19 deletions(-)
drivers/staging/vt6655/rxtx.c +0 -0
index 9db4317f9a42..508e1bd7d76e 100644

drivers/staging/vt6655/rxtx.c s_uFillDataHead( · line 444

Quoted 5 lines
drivers/staging/vt6655/rxtx.c +2 -0
@@ -440,6 +440,8 @@ s_uFillDataHead(
 	bool is_pspoll
 )
 {
+	struct vnt_tx_datahead_ab *buf = pTxDataHead;
+

This part of the patch isn't related to what is described in the log message.

julia

Quoted 58 lines
drivers/staging/vt6655/rxtx.c +17 -20
 	if (!pTxDataHead)
 		return 0;
 
@@ -544,29 +546,27 @@ s_uFillDataHead(
 
 		buf->time_stamp_off = vnt_time_stamp_off(pDevice, wCurrentRate);
 		return buf->duration;
-	} else {
-		struct vnt_tx_datahead_ab *buf = pTxDataHead;
-		/* Get SignalField, ServiceField & Length */
-		vnt_get_phy_field(pDevice, cbFrameLength, wCurrentRate,
-				  byPktType, &buf->ab);
+	}
 
-		if (is_pspoll) {
-			__le16 dur = cpu_to_le16(pDevice->current_aid | BIT(14) | BIT(15));
+	/* Get SignalField, ServiceField & Length */
+	vnt_get_phy_field(pDevice, cbFrameLength, wCurrentRate,
+			  byPktType, &buf->ab);
 
-			buf->duration = dur;
-		} else {
-			/* Get Duration and TimeStampOff */
-			buf->duration =
-				cpu_to_le16((u16)s_uGetDataDuration(pDevice, DATADUR_B, cbFrameLength, byPktType,
-								    wCurrentRate, bNeedAck, uFragIdx,
-								    cbLastFragmentSize, uMACfragNum,
-								    byFBOption));
-		}
+	if (is_pspoll) {
+		__le16 dur = cpu_to_le16(pDevice->current_aid | BIT(14) | BIT(15));
 
-		buf->time_stamp_off = vnt_time_stamp_off(pDevice, wCurrentRate);
-		return buf->duration;
+		buf->duration = dur;
+	} else {
+		/* Get Duration and TimeStampOff */
+		buf->duration =
+			cpu_to_le16((u16)s_uGetDataDuration(pDevice, DATADUR_B, cbFrameLength, byPktType,
+							    wCurrentRate, bNeedAck, uFragIdx,
+							    cbLastFragmentSize, uMACfragNum,
+							    byFBOption));
 	}
-	return 0;
+
+	buf->time_stamp_off = vnt_time_stamp_off(pDevice, wCurrentRate);
+	return buf->duration;
 }
 
 static
--

2.28.0

--
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 view this discussion on the web visit https://groups.google.com/d/msgid/outreachy-kernel/a794bc3814ffac8027cef21e2993de67fa7e30d0.1604133727.git.mdejesusfilho%40gmail.com.

#5 lore raw

Re: [Outreachy kernel] [PATCH 3/3] staging: vt6655: Remove useless else

In reply to Marcos Antonio de Jesus Filho
Quoted 14 lines · Marcos Antonio de Jesus Filho

The else statement is not useful due to the presence of a return statement on the if block. Remove the else statement, adjust the indentation of the code and remove useless return statement. Reported by checkpatch.

---
 drivers/staging/vt6655/rxtx.c | 38 +++++++++++++++++------------------
 1 file changed, 19 insertions(+), 19 deletions(-)
drivers/staging/vt6655/rxtx.c +0 -0
index 9db4317f9a42..508e1bd7d76e 100644

drivers/staging/vt6655/rxtx.c s_uFillDataHead( · line 444

Quoted 5 lines
drivers/staging/vt6655/rxtx.c +2 -0
@@ -440,6 +440,8 @@ s_uFillDataHead(
 	bool is_pspoll
 )
 {
+	struct vnt_tx_datahead_ab *buf = pTxDataHead;
+

I'm not sure what was the goal of the above addition, but it also looks strange to declare the variable buf and then, on immediately the next line, not to use it.

julia

Quoted 58 lines
drivers/staging/vt6655/rxtx.c +17 -20
 	if (!pTxDataHead)
 		return 0;
 
@@ -544,29 +546,27 @@ s_uFillDataHead(
 
 		buf->time_stamp_off = vnt_time_stamp_off(pDevice, wCurrentRate);
 		return buf->duration;
-	} else {
-		struct vnt_tx_datahead_ab *buf = pTxDataHead;
-		/* Get SignalField, ServiceField & Length */
-		vnt_get_phy_field(pDevice, cbFrameLength, wCurrentRate,
-				  byPktType, &buf->ab);
+	}
 
-		if (is_pspoll) {
-			__le16 dur = cpu_to_le16(pDevice->current_aid | BIT(14) | BIT(15));
+	/* Get SignalField, ServiceField & Length */
+	vnt_get_phy_field(pDevice, cbFrameLength, wCurrentRate,
+			  byPktType, &buf->ab);
 
-			buf->duration = dur;
-		} else {
-			/* Get Duration and TimeStampOff */
-			buf->duration =
-				cpu_to_le16((u16)s_uGetDataDuration(pDevice, DATADUR_B, cbFrameLength, byPktType,
-								    wCurrentRate, bNeedAck, uFragIdx,
-								    cbLastFragmentSize, uMACfragNum,
-								    byFBOption));
-		}
+	if (is_pspoll) {
+		__le16 dur = cpu_to_le16(pDevice->current_aid | BIT(14) | BIT(15));
 
-		buf->time_stamp_off = vnt_time_stamp_off(pDevice, wCurrentRate);
-		return buf->duration;
+		buf->duration = dur;
+	} else {
+		/* Get Duration and TimeStampOff */
+		buf->duration =
+			cpu_to_le16((u16)s_uGetDataDuration(pDevice, DATADUR_B, cbFrameLength, byPktType,
+							    wCurrentRate, bNeedAck, uFragIdx,
+							    cbLastFragmentSize, uMACfragNum,
+							    byFBOption));
 	}
-	return 0;
+
+	buf->time_stamp_off = vnt_time_stamp_off(pDevice, wCurrentRate);
+	return buf->duration;
 }
 
 static
--

2.28.0

--
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 view this discussion on the web visit https://groups.google.com/d/msgid/outreachy-kernel/a794bc3814ffac8027cef21e2993de67fa7e30d0.1604133727.git.mdejesusfilho%40gmail.com.

#7 lore raw
In reply to Marcos Antonio de Jesus Filho
Quoted 11 lines · Marcos Antonio de Jesus Filho

This patchset removes multiples useless else statements after return statements. Reported by check patch.

Observation
-----------

After cleaning up the code I noticed that the code from 530 to 548 repeats at 551,569 and that it can be removed and one of the conditional statements can be simplified.

Marcos Antonio de Jesus Filho (3):
staging: vt6655: Remove useless else
staging: vt6655: Remove useless else
staging: vt6655: Remove useless else

The patches need different subject lines.

julia

Quoted 12 lines
 drivers/staging/vt6655/rxtx.c | 99 ++++++++++++++++++-----------------
 1 file changed, 51 insertions(+), 48 deletions(-)

--
2.28.0

--
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 view this discussion on the web visit https://groups.google.com/d/msgid/outreachy-kernel/cover.1604133727.git.mdejesusfilho%40gmail.com.

#8 lore raw
Quoted 9 lines · Julia Lawall
Quoted 5 lines · Marcos Antonio de Jesus Filho

This patchset removes multiples useless else statements after return statements. Reported by check patch.

Observation
-----------

Quoted 8 lines
Quoted 6 lines

After cleaning up the code I noticed that the code from 530 to 548 repeats at 551,569 and that it can be removed and one of the conditional statements can be simplified.

Marcos Antonio de Jesus Filho (3):
staging: vt6655: Remove useless else
staging: vt6655: Remove useless else
staging: vt6655: Remove useless else

The patches need different subject lines.

How would I name patchs like this, that do the same thing but in different parts of the code?

Quoted 15 lines

julia

Quoted 12 lines
 drivers/staging/vt6655/rxtx.c | 99 ++++++++++++++++++-----------------
 1 file changed, 51 insertions(+), 48 deletions(-)

--
2.28.0

--
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 view this discussion on the web visit https://groups.google.com/d/msgid/outreachy-kernel/cover.1604133727.git.mdejesusfilho%40gmail.com.

#6 lore raw

Re: [Outreachy kernel] [PATCH 3/3] staging: vt6655: Remove useless else

In reply to Julia Lawall
Quoted 13 lines · Julia Lawall
Quoted 9 lines · Marcos Antonio de Jesus Filho

The else statement is not useful due to the presence of a return statement on the if block. Remove the else statement, adjust the indentation of the code and remove useless return statement. Reported by checkpatch.

---
 drivers/staging/vt6655/rxtx.c | 38 +++++++++++++++++------------------
 1 file changed, 19 insertions(+), 19 deletions(-)
Quoted 14 lines

drivers/staging/vt6655/rxtx.c s_uFillDataHead( · line 444

Quoted 10 lines
drivers/staging/vt6655/rxtx.c +2 -0
index 9db4317f9a42..508e1bd7d76e 100644
@@ -440,6 +440,8 @@ s_uFillDataHead(
 	bool is_pspoll
 )
 {
+	struct vnt_tx_datahead_ab *buf = pTxDataHead;
+

I'm not sure what was the goal of the above addition, but it also looks strange to declare the variable buf and then, on immediately the next line, not to use it.

The goal of this change is to make the fix and not introduce a build warning, because I can not mix variable declaration and code, otherwise I would get an "ISO C90 forbids mixed declarations and code in C" warning.

Marcos

#9 lore raw
In reply to Marcos Antonio de Jesus Filho
Quoted 12 lines · Marcos Antonio de Jesus Filho
Quoted 11 lines · Julia Lawall
Quoted 7 lines · Marcos Antonio de Jesus Filho

This patchset removes multiples useless else statements after return statements. Reported by check patch.

Observation
-----------

After cleaning up the code I noticed that the code from 530 to 548 repeats at 551,569 and that it can be removed and one of the conditional statements can be simplified.

Quoted 8 lines
Quoted 6 lines
Quoted 4 lines

Marcos Antonio de Jesus Filho (3):
staging: vt6655: Remove useless else
staging: vt6655: Remove useless else
staging: vt6655: Remove useless else

The patches need different subject lines.

How would I name patchs like this, that do the same thing but in different parts of the code?

Since it's always the same file, it could be one patch.

Or I guess you could add the name of the affected function to the subject line.

julia

Quoted 17 lines
Quoted 16 lines

julia

Quoted 12 lines
 drivers/staging/vt6655/rxtx.c | 99 ++++++++++++++++++-----------------
 1 file changed, 51 insertions(+), 48 deletions(-)

--
2.28.0

--
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 view this discussion on the web visit https://groups.google.com/d/msgid/outreachy-kernel/cover.1604133727.git.mdejesusfilho%40gmail.com.