2021-08-03 22:47:03

by Nathan Chancellor

[permalink] [raw]
Subject: [PATCH 3/4] staging: r8188eu: Remove self assignment in get_rx_power_val_by_reg()

Clang warns:

drivers/staging/r8188eu/hal/rtl8188e_rf6052.c:344:13: warning:
explicitly assigning value of variable of type 'u32' (aka 'unsigned
int') to itself [-Wself-assign]
writeVal = writeVal;
~~~~~~~~ ^ ~~~~~~~~
1 warning generated.

Remove this branch as it is useless.

Signed-off-by: Nathan Chancellor <[email protected]>
---
drivers/staging/r8188eu/hal/rtl8188e_rf6052.c | 2 --
1 file changed, 2 deletions(-)

diff --git a/drivers/staging/r8188eu/hal/rtl8188e_rf6052.c b/drivers/staging/r8188eu/hal/rtl8188e_rf6052.c
index 335b120ce603..77889dc05858 100644
--- a/drivers/staging/r8188eu/hal/rtl8188e_rf6052.c
+++ b/drivers/staging/r8188eu/hal/rtl8188e_rf6052.c
@@ -340,8 +340,6 @@ static void get_rx_power_val_by_reg(struct adapter *Adapter, u8 Channel,
/* This mechanism is only applied when Driver-Highpower-Mechanism is OFF. */
if (pdmpriv->DynamicTxHighPowerLvl == TxHighPwrLevel_BT1)
writeVal = writeVal - 0x06060606;
- else if (pdmpriv->DynamicTxHighPowerLvl == TxHighPwrLevel_BT2)
- writeVal = writeVal;
*(pOutWriteVal+rf) = writeVal;
}
}
--
2.33.0.rc0



2021-08-05 00:54:55

by Nathan Chancellor

[permalink] [raw]
Subject: Re: [PATCH 3/4] staging: r8188eu: Remove self assignment in get_rx_power_val_by_reg()

On 8/4/2021 11:37 AM, 'Nick Desaulniers' via Clang Built Linux wrote:
> On Tue, Aug 3, 2021 at 3:36 PM Nathan Chancellor <[email protected]> wrote:
>>
>> Clang warns:
>>
>> drivers/staging/r8188eu/hal/rtl8188e_rf6052.c:344:13: warning:
>> explicitly assigning value of variable of type 'u32' (aka 'unsigned
>> int') to itself [-Wself-assign]
>> writeVal = writeVal;
>> ~~~~~~~~ ^ ~~~~~~~~
>> 1 warning generated.
>>
>> Remove this branch as it is useless.
>>
>> Signed-off-by: Nathan Chancellor <[email protected]>
>> ---
>> drivers/staging/r8188eu/hal/rtl8188e_rf6052.c | 2 --
>> 1 file changed, 2 deletions(-)
>>
>> diff --git a/drivers/staging/r8188eu/hal/rtl8188e_rf6052.c b/drivers/staging/r8188eu/hal/rtl8188e_rf6052.c
>> index 335b120ce603..77889dc05858 100644
>> --- a/drivers/staging/r8188eu/hal/rtl8188e_rf6052.c
>> +++ b/drivers/staging/r8188eu/hal/rtl8188e_rf6052.c
>> @@ -340,8 +340,6 @@ static void get_rx_power_val_by_reg(struct adapter *Adapter, u8 Channel,
>> /* This mechanism is only applied when Driver-Highpower-Mechanism is OFF. */
>> if (pdmpriv->DynamicTxHighPowerLvl == TxHighPwrLevel_BT1)
>> writeVal = writeVal - 0x06060606;
>> - else if (pdmpriv->DynamicTxHighPowerLvl == TxHighPwrLevel_BT2)
>> - writeVal = writeVal;
>
> Hopefully the author didn't mean to subtract another magic constant
> like they did above. This also eliminates the last use of
> TxHighPwrLevel_BT2, but it's probably ok to keep the define in
> drivers/staging/r8188eu/include/odm.h.

For what it's worth, it seems that the DynamicTxHighPowerLvl member is
only ever assigned TxHighPwrLevel_Normal so the first if statement is
probably dead code too but I wanted to clean up the clang warnings, not
rewrite the driver, since I could do that for hours upon hours :)

> Reviewed-by: Nick Desaulniers <[email protected]>

Thanks for the review!

Cheers,
Nathan

>> *(pOutWriteVal+rf) = writeVal;
>> }
>> }
>> --
>> 2.33.0.rc0
>
>

2021-08-05 00:54:56

by Nick Desaulniers

[permalink] [raw]
Subject: Re: [PATCH 3/4] staging: r8188eu: Remove self assignment in get_rx_power_val_by_reg()

On Tue, Aug 3, 2021 at 3:36 PM Nathan Chancellor <[email protected]> wrote:
>
> Clang warns:
>
> drivers/staging/r8188eu/hal/rtl8188e_rf6052.c:344:13: warning:
> explicitly assigning value of variable of type 'u32' (aka 'unsigned
> int') to itself [-Wself-assign]
> writeVal = writeVal;
> ~~~~~~~~ ^ ~~~~~~~~
> 1 warning generated.
>
> Remove this branch as it is useless.
>
> Signed-off-by: Nathan Chancellor <[email protected]>
> ---
> drivers/staging/r8188eu/hal/rtl8188e_rf6052.c | 2 --
> 1 file changed, 2 deletions(-)
>
> diff --git a/drivers/staging/r8188eu/hal/rtl8188e_rf6052.c b/drivers/staging/r8188eu/hal/rtl8188e_rf6052.c
> index 335b120ce603..77889dc05858 100644
> --- a/drivers/staging/r8188eu/hal/rtl8188e_rf6052.c
> +++ b/drivers/staging/r8188eu/hal/rtl8188e_rf6052.c
> @@ -340,8 +340,6 @@ static void get_rx_power_val_by_reg(struct adapter *Adapter, u8 Channel,
> /* This mechanism is only applied when Driver-Highpower-Mechanism is OFF. */
> if (pdmpriv->DynamicTxHighPowerLvl == TxHighPwrLevel_BT1)
> writeVal = writeVal - 0x06060606;
> - else if (pdmpriv->DynamicTxHighPowerLvl == TxHighPwrLevel_BT2)
> - writeVal = writeVal;

Hopefully the author didn't mean to subtract another magic constant
like they did above. This also eliminates the last use of
TxHighPwrLevel_BT2, but it's probably ok to keep the define in
drivers/staging/r8188eu/include/odm.h.

Reviewed-by: Nick Desaulniers <[email protected]>

> *(pOutWriteVal+rf) = writeVal;
> }
> }
> --
> 2.33.0.rc0


--
Thanks,
~Nick Desaulniers