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

Dan Carpenter <[email protected]> Sat, 12 Apr 2025 20:36:09 +0300
Newsgroups dev.linux.lists.outreachy,dev.linux.lists.linux-staging,org.kernel.vger.linux-kernel
Message-ID <[email protected]>
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 <[email protected]>
> ---
>  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
>