staging: vt6655: Remove useless else
PATCH 1/1 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 | 36 +++++++++++++++++------------------ 1 file changed, 18 insertions(+), 18 deletions(-)
drivers/staging/vt6655/rxtx.c +18 -18
@@ -519,28 +519,28 @@ 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 )); +struct vnt_tx_datahead_ab *buf = pTxDataHead; +/* 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
Greg Kroah-Hartman
maintainerQuoted 48 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 and adjust the indentation of the code. Reported by checkpatch.
Signed-off-by Marcos Antonio de Jesus Filho <[email protected]>--- drivers/staging/vt6655/rxtx.c | 36 +++++++++++++++++------------------ 1 file changed, 18 insertions(+), 18 deletions(-)drivers/staging/vt6655/rxtx.c +10
-18@@ -519,28 +519,28 @@ 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 )); +struct vnt_tx_datahead_ab *buf = pTxDataHead; +/* 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 */
drivers/staging/vt6655/rxtx.c s_uFillDataHead( · line 544
Quoted 10 lines
drivers/staging/vt6655/rxtx.c +8
-0+ 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 {
You do the same thing here, right? Shouldn't this else be dropped?
thanks,
greg k-h
Quoted 53 lines · Greg Kroah-Hartman
Quoted 52 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 and adjust the indentation of the code. Reported by checkpatch.
Signed-off-by Marcos Antonio de Jesus Filho <[email protected]>--- drivers/staging/vt6655/rxtx.c | 36 +++++++++++++++++------------------ 1 file changed, 18 insertions(+), 18 deletions(-)drivers/staging/vt6655/rxtx.c +14
-18@@ -519,28 +519,28 @@ 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 )); +struct vnt_tx_datahead_ab *buf = pTxDataHead; +/* 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,
Quoted 8 lines
drivers/staging/vt6655/rxtx.c s_uFillDataHead( · line 544
Quoted 6 lines
drivers/staging/vt6655/rxtx.c +4
-0+ byFBOption)); } + + buf->time_stamp_off =vnt_time_stamp_off (pDevice, wCurrentRate); +return buf->duration; }else {You do the same thing here, right? Shouldn't this else be dropped?
Definitely. I did not do it because we are instructed to solve one 'Warning' at time. I was going to do it in another patch. Should I edit this patch and fix it now?
Quoted 4 lines
thanks,
greg k-h
Quoted 63 lines · Marcos Antonio de Jesus Filho
Quoted 53 lines · Greg Kroah-Hartman
Quoted 52 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 and adjust the indentation of the code. Reported by checkpatch.
Signed-off-by Marcos Antonio de Jesus Filho <[email protected]>--- drivers/staging/vt6655/rxtx.c | 36 +++++++++++++++++------------------ 1 file changed, 18 insertions(+), 18 deletions(-)drivers/staging/vt6655/rxtx.c +14
-18@@ -519,28 +519,28 @@ 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 )); +struct vnt_tx_datahead_ab *buf = pTxDataHead; +/* 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,Quoted 8 lines
drivers/staging/vt6655/rxtx.c s_uFillDataHead( · line 544
Quoted 6 lines
drivers/staging/vt6655/rxtx.c +4
-0+ byFBOption)); } + + buf->time_stamp_off =vnt_time_stamp_off (pDevice, wCurrentRate); +return buf->duration; }else {You do the same thing here, right? Shouldn't this else be dropped?
Quoted 7 lines
Definitely. I did not do it because we are instructed to solve one 'Warning' at time. I was going to do it in another patch. Should I edit this patch and fix it now?
Quoted 4 lines
thanks,
greg k-h
I notice that after removing the else statement I get the compilation error "ISO C90 forbids mixed declarations and code", because we eliminate the scope of the else block. Should I leave as it is?
Greg Kroah-Hartman
maintainerQuoted 68 lines · Marcos Antonio de Jesus Filho
Quoted 67 lines · Marcos Antonio de Jesus Filho
Quoted 53 lines · Greg Kroah-Hartman
Quoted 52 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 and adjust the indentation of the code. Reported by checkpatch.
Signed-off-by Marcos Antonio de Jesus Filho <[email protected]>--- drivers/staging/vt6655/rxtx.c | 36 +++++++++++++++++------------------ 1 file changed, 18 insertions(+), 18 deletions(-)drivers/staging/vt6655/rxtx.c +14
-18@@ -519,28 +519,28 @@ 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 )); +struct vnt_tx_datahead_ab *buf = pTxDataHead; +/* 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,Quoted 8 lines
drivers/staging/vt6655/rxtx.c s_uFillDataHead( · line 544
Quoted 6 lines
drivers/staging/vt6655/rxtx.c +4
-0+ byFBOption)); } + + buf->time_stamp_off =vnt_time_stamp_off (pDevice, wCurrentRate); +return buf->duration; }else {You do the same thing here, right? Shouldn't this else be dropped?
Definitely. I did not do it because we are instructed to solve one 'Warning' at time. I was going to do it in another patch. Should I edit this patch and fix it now?
Quoted 1 line
Quoted 5 lines
Quoted 3 lines
Quoted 3 lines
thanks,
greg k-h
I notice that after removing the else statement I get the compilation error "ISO C90 forbids mixed declarations and code", because we eliminate the scope of the else block. Should I leave as it is?
You can not add build warnings to the kernel, so fix this up in a patch series where you do one step at a time, and keep everything building properly at each patch.
thanks,
greg k-h