linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] staging: rtl8188eu: remove dead code in do-while conditional step
@ 2019-09-23 19:48 Connor Kuehl
  2019-09-23 20:38 ` Larry Finger
                   ` (2 more replies)
  0 siblings, 3 replies; 7+ messages in thread
From: Connor Kuehl @ 2019-09-23 19:48 UTC (permalink / raw)
  To: Larry.Finger, gregkh, straube.linux, devel; +Cc: linux-kernel, kernel-janitors

The local variable 'bcmd_down' is always set to true almost immediately
before the do-while's condition is checked. As a result, !bcmd_down
evaluates to false which short circuits the logical AND operator meaning
that the second operand is never reached and is therefore dead code.

Addresses-Coverity: ("Logically dead code")

Signed-off-by: Connor Kuehl <connor.kuehl@canonical.com>
---
 drivers/staging/rtl8188eu/hal/rtl8188e_cmd.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/staging/rtl8188eu/hal/rtl8188e_cmd.c b/drivers/staging/rtl8188eu/hal/rtl8188e_cmd.c
index 47352f210c0b..a4b317937b23 100644
--- a/drivers/staging/rtl8188eu/hal/rtl8188e_cmd.c
+++ b/drivers/staging/rtl8188eu/hal/rtl8188e_cmd.c
@@ -48,7 +48,6 @@ static u8 _is_fw_read_cmd_down(struct adapter *adapt, u8 msgbox_num)
 static s32 FillH2CCmd_88E(struct adapter *adapt, u8 ElementID, u32 CmdLen, u8 *pCmdBuffer)
 {
 	u8 bcmd_down = false;
-	s32 retry_cnts = 100;
 	u8 h2c_box_num;
 	u32 msgbox_addr;
 	u32 msgbox_ex_addr;
@@ -103,7 +102,7 @@ static s32 FillH2CCmd_88E(struct adapter *adapt, u8 ElementID, u32 CmdLen, u8 *p
 		adapt->HalData->LastHMEBoxNum =
 			(h2c_box_num+1) % RTL88E_MAX_H2C_BOX_NUMS;
 
-	} while ((!bcmd_down) && (retry_cnts--));
+	} while (!bcmd_down);
 
 	ret = _SUCCESS;
 
-- 
2.17.1


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

* Re: [PATCH] staging: rtl8188eu: remove dead code in do-while conditional step
  2019-09-23 19:48 [PATCH] staging: rtl8188eu: remove dead code in do-while conditional step Connor Kuehl
@ 2019-09-23 20:38 ` Larry Finger
  2019-09-23 20:49   ` Connor Kuehl
  2019-09-24  6:17   ` Dan Carpenter
  2019-09-24  6:15 ` Dan Carpenter
  2019-09-24 14:25 ` NACK: " Connor Kuehl
  2 siblings, 2 replies; 7+ messages in thread
From: Larry Finger @ 2019-09-23 20:38 UTC (permalink / raw)
  To: Connor Kuehl, gregkh, straube.linux, devel; +Cc: linux-kernel, kernel-janitors

On 9/23/19 2:48 PM, Connor Kuehl wrote:
> The local variable 'bcmd_down' is always set to true almost immediately
> before the do-while's condition is checked. As a result, !bcmd_down
> evaluates to false which short circuits the logical AND operator meaning
> that the second operand is never reached and is therefore dead code.
> 
> Addresses-Coverity: ("Logically dead code")
> 
> Signed-off-by: Connor Kuehl <connor.kuehl@canonical.com>
> ---
>   drivers/staging/rtl8188eu/hal/rtl8188e_cmd.c | 3 +--
>   1 file changed, 1 insertion(+), 2 deletions(-)
> 
> diff --git a/drivers/staging/rtl8188eu/hal/rtl8188e_cmd.c b/drivers/staging/rtl8188eu/hal/rtl8188e_cmd.c
> index 47352f210c0b..a4b317937b23 100644
> --- a/drivers/staging/rtl8188eu/hal/rtl8188e_cmd.c
> +++ b/drivers/staging/rtl8188eu/hal/rtl8188e_cmd.c
> @@ -48,7 +48,6 @@ static u8 _is_fw_read_cmd_down(struct adapter *adapt, u8 msgbox_num)
>   static s32 FillH2CCmd_88E(struct adapter *adapt, u8 ElementID, u32 CmdLen, u8 *pCmdBuffer)
>   {
>   	u8 bcmd_down = false;
> -	s32 retry_cnts = 100;
>   	u8 h2c_box_num;
>   	u32 msgbox_addr;
>   	u32 msgbox_ex_addr;
> @@ -103,7 +102,7 @@ static s32 FillH2CCmd_88E(struct adapter *adapt, u8 ElementID, u32 CmdLen, u8 *p
>   		adapt->HalData->LastHMEBoxNum =
>   			(h2c_box_num+1) % RTL88E_MAX_H2C_BOX_NUMS;
>   
> -	} while ((!bcmd_down) && (retry_cnts--));
> +	} while (!bcmd_down);
>   
>   	ret = _SUCCESS;

This patch is correct; however, the do..while loop will always be executed once, 
thus you could remove the loop and the loop variable bcmd_down.

@greg: If you would prefer a two-step process, then this one is OK.

Larry


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

* Re: [PATCH] staging: rtl8188eu: remove dead code in do-while conditional step
  2019-09-23 20:38 ` Larry Finger
@ 2019-09-23 20:49   ` Connor Kuehl
  2019-09-24  6:17   ` Dan Carpenter
  1 sibling, 0 replies; 7+ messages in thread
From: Connor Kuehl @ 2019-09-23 20:49 UTC (permalink / raw)
  To: Larry Finger, gregkh, straube.linux, devel; +Cc: linux-kernel, kernel-janitors

On 9/23/19 1:38 PM, Larry Finger wrote:
> On 9/23/19 2:48 PM, Connor Kuehl wrote:
>> The local variable 'bcmd_down' is always set to true almost immediately
>> before the do-while's condition is checked. As a result, !bcmd_down
>> evaluates to false which short circuits the logical AND operator meaning
>> that the second operand is never reached and is therefore dead code.
>>
>> Addresses-Coverity: ("Logically dead code")
>>
>> Signed-off-by: Connor Kuehl <connor.kuehl@canonical.com>
>> ---
>>   drivers/staging/rtl8188eu/hal/rtl8188e_cmd.c | 3 +--
>>   1 file changed, 1 insertion(+), 2 deletions(-)
>>
>> diff --git a/drivers/staging/rtl8188eu/hal/rtl8188e_cmd.c 
>> b/drivers/staging/rtl8188eu/hal/rtl8188e_cmd.c
>> index 47352f210c0b..a4b317937b23 100644
>> --- a/drivers/staging/rtl8188eu/hal/rtl8188e_cmd.c
>> +++ b/drivers/staging/rtl8188eu/hal/rtl8188e_cmd.c
>> @@ -48,7 +48,6 @@ static u8 _is_fw_read_cmd_down(struct adapter 
>> *adapt, u8 msgbox_num)
>>   static s32 FillH2CCmd_88E(struct adapter *adapt, u8 ElementID, u32 
>> CmdLen, u8 *pCmdBuffer)
>>   {
>>       u8 bcmd_down = false;
>> -    s32 retry_cnts = 100;
>>       u8 h2c_box_num;
>>       u32 msgbox_addr;
>>       u32 msgbox_ex_addr;
>> @@ -103,7 +102,7 @@ static s32 FillH2CCmd_88E(struct adapter *adapt, 
>> u8 ElementID, u32 CmdLen, u8 *p
>>           adapt->HalData->LastHMEBoxNum =
>>               (h2c_box_num+1) % RTL88E_MAX_H2C_BOX_NUMS;
>> -    } while ((!bcmd_down) && (retry_cnts--));
>> +    } while (!bcmd_down);
>>       ret = _SUCCESS;
> 
> This patch is correct; however, the do..while loop will always be 
> executed once, thus you could remove the loop and the loop variable 
> bcmd_down.

Ah, yes! That makes sense, good catch.

> 
> @greg: If you would prefer a two-step process, then this one is OK.

I'll do whichever is preferred. I'm happy to NACK this and send a v2 
with the dead code and loop removed or I can send a separate patch based 
on this one to remove the loop.

Thank you,

Connor

> 
> Larry
> 


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

* Re: [PATCH] staging: rtl8188eu: remove dead code in do-while conditional step
  2019-09-23 19:48 [PATCH] staging: rtl8188eu: remove dead code in do-while conditional step Connor Kuehl
  2019-09-23 20:38 ` Larry Finger
@ 2019-09-24  6:15 ` Dan Carpenter
  2019-09-24 14:25 ` NACK: " Connor Kuehl
  2 siblings, 0 replies; 7+ messages in thread
From: Dan Carpenter @ 2019-09-24  6:15 UTC (permalink / raw)
  To: Connor Kuehl
  Cc: Larry.Finger, gregkh, straube.linux, devel, kernel-janitors,
	linux-kernel

On Mon, Sep 23, 2019 at 12:48:06PM -0700, Connor Kuehl wrote:
> @@ -103,7 +102,7 @@ static s32 FillH2CCmd_88E(struct adapter *adapt, u8 ElementID, u32 CmdLen, u8 *p
>  		adapt->HalData->LastHMEBoxNum =
>  			(h2c_box_num+1) % RTL88E_MAX_H2C_BOX_NUMS;
>  
> -	} while ((!bcmd_down) && (retry_cnts--));
> +	} while (!bcmd_down);

Just get rid of the whole do while loop, because it just goes through
one time.  It doesn't loop.   Get rid of bcmd_down as well.

regards,
dan carpenter


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

* Re: [PATCH] staging: rtl8188eu: remove dead code in do-while conditional step
  2019-09-23 20:38 ` Larry Finger
  2019-09-23 20:49   ` Connor Kuehl
@ 2019-09-24  6:17   ` Dan Carpenter
  1 sibling, 0 replies; 7+ messages in thread
From: Dan Carpenter @ 2019-09-24  6:17 UTC (permalink / raw)
  To: Larry Finger
  Cc: Connor Kuehl, gregkh, straube.linux, devel, kernel-janitors,
	linux-kernel

On Mon, Sep 23, 2019 at 03:38:39PM -0500, Larry Finger wrote:
> This patch is correct; however, the do..while loop will always be executed

s/correct/harmless/.

> once, thus you could remove the loop and the loop variable bcmd_down.
> 
> @greg: If you would prefer a two-step process, then this one is OK.

It has to be done in one step.

regards,
dan carpenter


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

* NACK: [PATCH] staging: rtl8188eu: remove dead code in do-while conditional step
  2019-09-23 19:48 [PATCH] staging: rtl8188eu: remove dead code in do-while conditional step Connor Kuehl
  2019-09-23 20:38 ` Larry Finger
  2019-09-24  6:15 ` Dan Carpenter
@ 2019-09-24 14:25 ` Connor Kuehl
  2019-09-24 15:25   ` Dan Carpenter
  2 siblings, 1 reply; 7+ messages in thread
From: Connor Kuehl @ 2019-09-24 14:25 UTC (permalink / raw)
  To: Larry.Finger, gregkh, straube.linux, devel; +Cc: linux-kernel, kernel-janitors

I'm sending a V2 with the loop removed.

Thanks,

Connor

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

* Re: NACK: [PATCH] staging: rtl8188eu: remove dead code in do-while conditional step
  2019-09-24 14:25 ` NACK: " Connor Kuehl
@ 2019-09-24 15:25   ` Dan Carpenter
  0 siblings, 0 replies; 7+ messages in thread
From: Dan Carpenter @ 2019-09-24 15:25 UTC (permalink / raw)
  To: Connor Kuehl
  Cc: Larry.Finger, gregkh, straube.linux, devel, kernel-janitors,
	linux-kernel

This email is fine, but I just want to make sure that you don't think
it's required.  We all assumed that you would send a v2.  I sort of hate
the word NACK as well because it sounds like shouting or ducks and those
are my two pet peeves.

Sometimes  people send a v2 patch without any replies to the original
email and we apply the v1 patch that's the only thing to avoid.

regards,
dan carpenter


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

end of thread, other threads:[~2019-09-24 15:25 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-09-23 19:48 [PATCH] staging: rtl8188eu: remove dead code in do-while conditional step Connor Kuehl
2019-09-23 20:38 ` Larry Finger
2019-09-23 20:49   ` Connor Kuehl
2019-09-24  6:17   ` Dan Carpenter
2019-09-24  6:15 ` Dan Carpenter
2019-09-24 14:25 ` NACK: " Connor Kuehl
2019-09-24 15:25   ` Dan Carpenter

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