diff mbox

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

Message ID 1363248561-11974-1-git-send-email-sbabic@denx.de
State Superseded
Delegated to: Stefano Babic
Headers show

Commit Message

Stefano Babic March 14, 2013, 8:09 a.m. UTC
From: "fabio.estevam@freescale.com" <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>
Signed-off-by: Stefano Babic <sbabic@denx.de>
---

Changes since V2:
	- move casting inside expression to force using unsigned long

 board/boundary/nitrogen6x/nitrogen6x.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Wolfgang Denk March 14, 2013, 11:38 a.m. UTC | #1
Dear Stefano Babic,

In message <1363248561-11974-1-git-send-email-sbabic@denx.de> you wrote:
> 
> 2GB can not fit in 32-bits, so use ulong instead.

<nitpick>

unsigned long is 32 bits, too.

And, strictly speaking, GB is a decimal unit, so 2 GB = 2e9 = 0x77359400
which fits nicely into a signed 32 bit number.

What you actually mean is:
	
	2 GiB cannot be expressed as a 32 bit signed number.

</nitpick>

Best regards,

Wolfgang Denk
Fabio Estevam March 14, 2013, 12:25 p.m. UTC | #2
On Thu, Mar 14, 2013 at 8:38 AM, Wolfgang Denk <wd@denx.de> wrote:

> What you actually mean is:
>
>         2 GiB cannot be expressed as a 32 bit signed number.

Good point, I will change and re-submit it.

Thanks,

Fabio Estevam
Albert ARIBAUD March 14, 2013, 1:15 p.m. UTC | #3
Hi Stefano,

On Thu, 14 Mar 2013 09:09:21 +0100, Stefano Babic <sbabic@denx.de>
wrote:

> From: "fabio.estevam@freescale.com" <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>
> Signed-off-by: Stefano Babic <sbabic@denx.de>

This somehow is redundant with Fabio's patch 2/2 with the same summary,
right?

Stefano: once Fabio's series is OK,

- either you rollback your ToT, apply Fabio's series before it, and
  then send out an amended PR, which is more work but makes your tree
  build-clean;

- or I apply Fabio's series then your existing PR, which is less
  work but leaves your current ToT non-build-clean until you merge back
  from ARM (or mainline once I do my own PR).

What do you prefer? I would favor the first option, FWIW.

Amicalement,
Stefano Babic March 14, 2013, 2:09 p.m. UTC | #4
On 14/03/2013 14:15, Albert ARIBAUD wrote:
> Hi Stefano,
> 
> On Thu, 14 Mar 2013 09:09:21 +0100, Stefano Babic <sbabic@denx.de>
> wrote:
> 
>> From: "fabio.estevam@freescale.com" <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>
>> Signed-off-by: Stefano Babic <sbabic@denx.de>
> 
> This somehow is redundant with Fabio's patch 2/2 with the same summary,
> right?
> 

We sent quite at the same time - I will discharge mine.

> Stefano: once Fabio's series is OK,
> 
> - either you rollback your ToT, apply Fabio's series before it, and
>   then send out an amended PR, which is more work but makes your tree
>   build-clean;
> 
> - or I apply Fabio's series then your existing PR, which is less
>   work but leaves your current ToT non-build-clean until you merge back
>   from ARM (or mainline once I do my own PR).
> 
> What do you prefer? I would favor the first option, FWIW.

I prefer to apply Fabio's patches on top of u-boot-imx and send an
amended PR. This is also my favorite option. What do you mean with
rollback the ToT ? As I have already pushed on the server, I do not like
to rebase it or things like that. My idea is only to apply the patches
and send after that a new PR to you.

Stefano
Albert ARIBAUD March 14, 2013, 3:18 p.m. UTC | #5
Hi Stefano,

On Thu, 14 Mar 2013 15:09:15 +0100, Stefano Babic <sbabic@denx.de>
wrote:

> On 14/03/2013 14:15, Albert ARIBAUD wrote:
> > Hi Stefano,
> > 
> > On Thu, 14 Mar 2013 09:09:21 +0100, Stefano Babic <sbabic@denx.de>
> > wrote:
> > 
> >> From: "fabio.estevam@freescale.com" <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>
> >> Signed-off-by: Stefano Babic <sbabic@denx.de>
> > 
> > This somehow is redundant with Fabio's patch 2/2 with the same summary,
> > right?
> > 
> 
> We sent quite at the same time - I will discharge mine.
> 
> > Stefano: once Fabio's series is OK,
> > 
> > - either you rollback your ToT, apply Fabio's series before it, and
> >   then send out an amended PR, which is more work but makes your tree
> >   build-clean;
> > 
> > - or I apply Fabio's series then your existing PR, which is less
> >   work but leaves your current ToT non-build-clean until you merge back
> >   from ARM (or mainline once I do my own PR).
> > 
> > What do you prefer? I would favor the first option, FWIW.
> 
> I prefer to apply Fabio's patches on top of u-boot-imx and send an
> amended PR. This is also my favorite option. What do you mean with
> rollback the ToT ? As I have already pushed on the server, I do not like
> to rebase it or things like that. My idea is only to apply the patches
> and send after that a new PR to you.

That's fine. :)

> Stefano

Amicalement,
diff mbox

Patch

diff --git a/board/boundary/nitrogen6x/nitrogen6x.c b/board/boundary/nitrogen6x/nitrogen6x.c
index 0dbb6d2..229c237 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;
 }