The 'enable' parameter in Switch_DM_Func() is of type u8. Explicitly
comparing it to 'true' (which evaluates to 1) is error-prone. If the
function is ever called with any non-zero value other than 1, the
condition will evaluate to false, incorrectly clearing the hardware
register instead of setting it.
Evaluate the condition implicitly to ensure that any non-zero value
correctly triggers the set operation.
This change also resolves the following check reported by
checkpatch.pl.
Signed-off-by: Marcos Andrade <marcosandrade95963@gmail.com>
---
drivers/staging/rtl8723bs/core/rtw_wlan_util.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/staging/rtl8723bs/core/rtw_wlan_util.c b/drivers/staging/rtl8723bs/core/rtw_wlan_util.c
index 3242978da36c..41868dda3838 100644
--- a/drivers/staging/rtl8723bs/core/rtw_wlan_util.c
+++ b/drivers/staging/rtl8723bs/core/rtw_wlan_util.c
@@ -236,7 +236,7 @@ void Restore_DM_Func_Flag(struct adapter *padapter)
void Switch_DM_Func(struct adapter *padapter, u32 mode, u8 enable)
{
- if (enable == true)
+ if (enable)
rtw_hal_set_hwreg(padapter, HW_VAR_DM_FUNC_SET, (u8 *)(&mode));
else
rtw_hal_set_hwreg(padapter, HW_VAR_DM_FUNC_CLR, (u8 *)(&mode));
--
2.53.0
On Thu, Mar 26, 2026 at 01:42:20AM +0000, Marcos Andrade wrote:
> The 'enable' parameter in Switch_DM_Func() is of type u8. Explicitly
> comparing it to 'true' (which evaluates to 1) is error-prone. If the
> function is ever called with any non-zero value other than 1, the
> condition will evaluate to false, incorrectly clearing the hardware
> register instead of setting it.
>
> Evaluate the condition implicitly to ensure that any non-zero value
> correctly triggers the set operation.
>
> This change also resolves the following check reported by
> checkpatch.pl.
>
> Signed-off-by: Marcos Andrade <marcosandrade95963@gmail.com>
> ---
> drivers/staging/rtl8723bs/core/rtw_wlan_util.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/staging/rtl8723bs/core/rtw_wlan_util.c b/drivers/staging/rtl8723bs/core/rtw_wlan_util.c
> index 3242978da36c..41868dda3838 100644
> --- a/drivers/staging/rtl8723bs/core/rtw_wlan_util.c
> +++ b/drivers/staging/rtl8723bs/core/rtw_wlan_util.c
> @@ -236,7 +236,7 @@ void Restore_DM_Func_Flag(struct adapter *padapter)
>
> void Switch_DM_Func(struct adapter *padapter, u32 mode, u8 enable)
> {
> - if (enable == true)
> + if (enable)
Why not just fix the parameter to be boolean instead? That is the
correct fix, right?
thanks,
greg k-h
© 2016 - 2026 Red Hat, Inc.