[PATCH v2 2/4] boot: fdt: Clean up env_get_bootm_size()

Laurent Pinchart laurent.pinchart at ideasonboard.com
Mon Mar 18 17:18:13 CET 2024


Hi Marek,

Thank you for the patch.

On Mon, Mar 18, 2024 at 04:00:45PM +0100, Marek Vasut wrote:
> Clean up tmp variable use and type cast in env_get_bootm_size().
> No functional change.

The code change looks fine, but you may want to expand the commit
message to explain why this patch improves the code.

> Signed-off-by: Marek Vasut <marek.vasut+renesas at mailbox.org>
> ---
> Cc: Heinrich Schuchardt <xypron.glpk at gmx.de>
> Cc: Kuninori Morimoto <kuninori.morimoto.gx at renesas.com>
> Cc: Laurent Pinchart <laurent.pinchart at ideasonboard.com>
> Cc: Simon Glass <sjg at chromium.org>
> Cc: Tom Rini <trini at konsulko.com>
> ---
> V2: - New patch
> ---
>  boot/image-board.c | 8 +++-----
>  1 file changed, 3 insertions(+), 5 deletions(-)
> 
> diff --git a/boot/image-board.c b/boot/image-board.c
> index 3263497a1d5..e3d63745299 100644
> --- a/boot/image-board.c
> +++ b/boot/image-board.c
> @@ -129,10 +129,8 @@ phys_size_t env_get_bootm_size(void)
>  	phys_addr_t start;
>  	char *s = env_get("bootm_size");
>  
> -	if (s) {
> -		tmp = (phys_size_t)simple_strtoull(s, NULL, 16);
> -		return tmp;
> -	}
> +	if (s)
> +		return simple_strtoull(s, NULL, 16);
>  
>  	start = gd->ram_base;
>  	size = gd->ram_size;
> @@ -142,7 +140,7 @@ phys_size_t env_get_bootm_size(void)
>  
>  	s = env_get("bootm_low");
>  	if (s)
> -		tmp = (phys_size_t)simple_strtoull(s, NULL, 16);
> +		tmp = simple_strtoull(s, NULL, 16);
>  	else
>  		tmp = start;
>  

Maybe you could even drop the tmp variable completely by writing this

	if (s)
		size -= simple_strtoull(s, NULL, 16) - start;

	return size;

I've never liked variables named tmp :-)

-- 
Regards,

Laurent Pinchart


More information about the U-Boot mailing list