All of lore.kernel.org
 help / color / mirror / Atom feed
* [U-Boot] [PATCH] board_f: drop 'dead code' in ram_top computation
@ 2018-07-27  9:16 Philipp Tomsich
  2018-07-27  9:24 ` Bin Meng
  2018-07-27  9:32 ` Dr. Philipp Tomsich
  0 siblings, 2 replies; 3+ messages in thread
From: Philipp Tomsich @ 2018-07-27  9:16 UTC (permalink / raw)
  To: u-boot

gd->ram_top is assigned to twice on consecutive lines and the compiler
won't be able to tell that the first assignment is dead (including its
r-value) due to the r-value containing a (side-effect free) function
call.

This drops the first assignment.

Signed-off-by: Philipp Tomsich <philipp.tomsich@theobroma-systems.com>
---

 common/board_f.c | 1 -
 1 file changed, 1 deletion(-)

diff --git a/common/board_f.c b/common/board_f.c
index 88d7700..1b8a003 100644
--- a/common/board_f.c
+++ b/common/board_f.c
@@ -283,7 +283,6 @@ static int setup_dest_addr(void)
 #ifdef CONFIG_SYS_SDRAM_BASE
 	gd->ram_base = CONFIG_SYS_SDRAM_BASE;
 #endif
-	gd->ram_top = gd->ram_base + get_effective_memsize();
 	gd->ram_top = board_get_usable_ram_top(gd->mon_len);
 	gd->relocaddr = gd->ram_top;
 	debug("Ram top: %08lX\n", (ulong)gd->ram_top);
-- 
2.1.4

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* [U-Boot] [PATCH] board_f: drop 'dead code' in ram_top computation
  2018-07-27  9:16 [U-Boot] [PATCH] board_f: drop 'dead code' in ram_top computation Philipp Tomsich
@ 2018-07-27  9:24 ` Bin Meng
  2018-07-27  9:32 ` Dr. Philipp Tomsich
  1 sibling, 0 replies; 3+ messages in thread
From: Bin Meng @ 2018-07-27  9:24 UTC (permalink / raw)
  To: u-boot

On Fri, Jul 27, 2018 at 5:16 PM, Philipp Tomsich
<philipp.tomsich@theobroma-systems.com> wrote:
> gd->ram_top is assigned to twice on consecutive lines and the compiler
> won't be able to tell that the first assignment is dead (including its
> r-value) due to the r-value containing a (side-effect free) function
> call.
>
> This drops the first assignment.
>
> Signed-off-by: Philipp Tomsich <philipp.tomsich@theobroma-systems.com>
> ---
>
>  common/board_f.c | 1 -
>  1 file changed, 1 deletion(-)
>

Reviewed-by: Bin Meng <bmeng.cn@gmail.com>

^ permalink raw reply	[flat|nested] 3+ messages in thread

* [U-Boot] [PATCH] board_f: drop 'dead code' in ram_top computation
  2018-07-27  9:16 [U-Boot] [PATCH] board_f: drop 'dead code' in ram_top computation Philipp Tomsich
  2018-07-27  9:24 ` Bin Meng
@ 2018-07-27  9:32 ` Dr. Philipp Tomsich
  1 sibling, 0 replies; 3+ messages in thread
From: Dr. Philipp Tomsich @ 2018-07-27  9:32 UTC (permalink / raw)
  To: u-boot


> On 27 Jul 2018, at 11:16, Philipp Tomsich <philipp.tomsich@theobroma-systems.com> wrote:
> 
> gd->ram_top is assigned to twice on consecutive lines and the compiler
> won't be able to tell that the first assignment is dead (including its
> r-value) due to the r-value containing a (side-effect free) function
> call.
> 
> This drops the first assignment.
> 
> Signed-off-by: Philipp Tomsich <philipp.tomsich@theobroma-systems.com>
> ---
> 
> common/board_f.c | 1 -
> 1 file changed, 1 deletion(-)
> 
> diff --git a/common/board_f.c b/common/board_f.c
> index 88d7700..1b8a003 100644
> --- a/common/board_f.c
> +++ b/common/board_f.c
> @@ -283,7 +283,6 @@ static int setup_dest_addr(void)
> #ifdef CONFIG_SYS_SDRAM_BASE
> 	gd->ram_base = CONFIG_SYS_SDRAM_BASE;
> #endif
> -	gd->ram_top = gd->ram_base + get_effective_memsize();
> 	gd->ram_top = board_get_usable_ram_top(gd->mon_len);
> 	gd->relocaddr = gd->ram_top;
> 	debug("Ram top: %08lX\n", (ulong)gd->ram_top);
> -- 
> 2.1.4
> 

Oh my, I’ll need to revise, as board_get_usable_ram_top is implemented as follows:
> /* Get the top of usable RAM */
> __weak ulong board_get_usable_ram_top(ulong total_size)
> {
> #ifdef CONFIG_SYS_SDRAM_BASE
> 	/*                                                                      
>          * Detect whether we have so much RAM that it goes past the end of our  
>          * 32-bit address space. If so, clip the usable RAM so it doesn't.      
>          */
> 	if (gd->ram_top < CONFIG_SYS_SDRAM_BASE)
> 		/*                                                              
>                  * Will wrap back to top of 32-bit space when reservations      
>                  * are made.                                                    
>                  */
>                 return 0;
> #endif
>       	return gd->ram_top;
> }

I.e. it consumes the previous value of gd->ram_top and ignores its argument.
I’ll clean this up before someone else falls into the same pit.

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2018-07-27  9:32 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-07-27  9:16 [U-Boot] [PATCH] board_f: drop 'dead code' in ram_top computation Philipp Tomsich
2018-07-27  9:24 ` Bin Meng
2018-07-27  9:32 ` Dr. Philipp Tomsich

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.