diff mbox

[U-Boot,v2,2/2] nitrogen: Use unsigned long to specify the total RAM size

Message ID 1363215553-27684-2-git-send-email-festevam@gmail.com
State Changes Requested
Delegated to: Stefano Babic
Headers show

Commit Message

Fabio Estevam March 13, 2013, 10:59 p.m. UTC
From: Fabio Estevam <fabio.estevam@freescale.com>>

When building for the nitrogen boards with 2GB the following warning happens:

nitrogen6x.c:89:38: warning: integer overflow in expression [-Woverflow]

2GB can not fit in 32-bits, so use ulong instead.

Reported-by: Albert Aribaud <albert.u.boot@aribaud.net>
Signed-off-by: Fabio Estevam <fabio.estevam@freescale.com>
---
Changes since v1:
- No changes
 board/boundary/nitrogen6x/nitrogen6x.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Stefano Babic March 14, 2013, 7:42 a.m. UTC | #1
On 13/03/2013 23:59, Fabio Estevam wrote:
> From: Fabio Estevam <fabio.estevam@freescale.com>>
> 
> When building for the nitrogen boards with 2GB the following warning happens:
> 
> nitrogen6x.c:89:38: warning: integer overflow in expression [-Woverflow]
> 
> 2GB can not fit in 32-bits, so use ulong instead.
> 
> Reported-by: Albert Aribaud <albert.u.boot@aribaud.net>
> Signed-off-by: Fabio Estevam <fabio.estevam@freescale.com>
> ---

Hi Fabio,

> Changes since v1:
> - No changes
>  board/boundary/nitrogen6x/nitrogen6x.c |    2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/board/boundary/nitrogen6x/nitrogen6x.c b/board/boundary/nitrogen6x/nitrogen6x.c
> index 0dbb6d2..e5634d8 100644
> --- a/board/boundary/nitrogen6x/nitrogen6x.c
> +++ b/board/boundary/nitrogen6x/nitrogen6x.c
> @@ -86,7 +86,7 @@ DECLARE_GLOBAL_DATA_PTR;
>  
>  int dram_init(void)
>  {
> -	gd->ram_size = CONFIG_DDR_MB * 1024 * 1024;
> +	gd->ram_size = (ulong)(CONFIG_DDR_MB * 1024 * 1024);

This does not fix the issue. You're casting, but the value does not fit
in 32 bit and the warning still remains.

I am afraid that 32 bit for gd->ram_size are not enough anymore...

We can fix the warning setting maybe a lower amout of memory (I am
expecting that now the value is truncated and a wrong output is shown on
the console), but for the future gd->ram_size should move to 64 bit.

Best regards,
Stefano
diff mbox

Patch

diff --git a/board/boundary/nitrogen6x/nitrogen6x.c b/board/boundary/nitrogen6x/nitrogen6x.c
index 0dbb6d2..e5634d8 100644
--- a/board/boundary/nitrogen6x/nitrogen6x.c
+++ b/board/boundary/nitrogen6x/nitrogen6x.c
@@ -86,7 +86,7 @@  DECLARE_GLOBAL_DATA_PTR;
 
 int dram_init(void)
 {
-	gd->ram_size = CONFIG_DDR_MB * 1024 * 1024;
+	gd->ram_size = (ulong)(CONFIG_DDR_MB * 1024 * 1024);
 
 	return 0;
 }