[PATCH 2/6] staging: rtl8723bs: Initialize variables at declaration in odm_HWConfig.c

Erick Karanja posted 6 patches 8 months, 1 week ago
There is a newer version of this series
[PATCH 2/6] staging: rtl8723bs: Initialize variables at declaration in odm_HWConfig.c
Posted by Erick Karanja 8 months, 1 week ago
Make the code more concise and readable by integrating the initialization
directly into the variable declaration in cases where the initialization
is simple and doesn't depend on other variables or complex expressions.

Signed-off-by: Erick Karanja <karanja99erick@gmail.com>
---
 drivers/staging/rtl8723bs/hal/odm_HWConfig.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/staging/rtl8723bs/hal/odm_HWConfig.c b/drivers/staging/rtl8723bs/hal/odm_HWConfig.c
index 994b8c578e7a..85cda5c3a5b5 100644
--- a/drivers/staging/rtl8723bs/hal/odm_HWConfig.c
+++ b/drivers/staging/rtl8723bs/hal/odm_HWConfig.c
@@ -52,9 +52,8 @@ static u8 odm_evm_db_to_percentage(s8 value)
 	/*  */
 	/*  -33dB~0dB to 0%~99% */
 	/*  */
-	s8 ret_val;
+	s8 ret_val = value;
 
-	ret_val = value;
 	ret_val /= 2;
 
 	if (ret_val >= 0)
-- 
2.43.0
Re: [PATCH 2/6] staging: rtl8723bs: Initialize variables at declaration in odm_HWConfig.c
Posted by Dan Carpenter 8 months, 1 week ago
On Thu, Apr 10, 2025 at 04:06:07PM +0300, Erick Karanja wrote:
> Make the code more concise and readable by integrating the initialization
> directly into the variable declaration in cases where the initialization
> is simple and doesn't depend on other variables or complex expressions.
> 
> Signed-off-by: Erick Karanja <karanja99erick@gmail.com>
> ---
>  drivers/staging/rtl8723bs/hal/odm_HWConfig.c | 3 +--
>  1 file changed, 1 insertion(+), 2 deletions(-)
> 
> diff --git a/drivers/staging/rtl8723bs/hal/odm_HWConfig.c b/drivers/staging/rtl8723bs/hal/odm_HWConfig.c
> index 994b8c578e7a..85cda5c3a5b5 100644
> --- a/drivers/staging/rtl8723bs/hal/odm_HWConfig.c
> +++ b/drivers/staging/rtl8723bs/hal/odm_HWConfig.c
> @@ -52,9 +52,8 @@ static u8 odm_evm_db_to_percentage(s8 value)
>  	/*  */
>  	/*  -33dB~0dB to 0%~99% */
>  	/*  */
> -	s8 ret_val;
> +	s8 ret_val = value;
>  
> -	ret_val = value;
>  	ret_val /= 2;

Better to write this one as:

	s8 ret_val = value / 2;

regards,
dan carpenter

>  
>  	if (ret_val >= 0)
> -- 
> 2.43.0
>