diff mbox

[U-Boot,1/2] tools/atmelimage.c: Fix warning when debug is enabled

Message ID 1440616883-20885-1-git-send-email-trini@konsulko.com
State Changes Requested
Delegated to: Tom Rini
Headers show

Commit Message

Tom Rini Aug. 26, 2015, 7:21 p.m. UTC
Otherwise we get:
tools/atmelimage.c:134:3: warning: format ‘%d’ expects argument of type ‘int’, but argument 2 has type ‘size_t’ [-Wformat=]
debug("atmelimage: interrupt vector #%d is 0x%08X\n", pos+1,
^

Signed-off-by: Tom Rini <trini@konsulko.com>
---
 tools/atmelimage.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Andreas Bießmann Aug. 27, 2015, 10:37 a.m. UTC | #1
Hi Tom,

On 08/26/2015 09:21 PM, Tom Rini wrote:
> Otherwise we get:
> tools/atmelimage.c:134:3: warning: format ‘%d’ expects argument of type ‘int’, but argument 2 has type ‘size_t’ [-Wformat=]
> debug("atmelimage: interrupt vector #%d is 0x%08X\n", pos+1,
> ^
> 
> Signed-off-by: Tom Rini <trini@konsulko.com>
> ---
>  tools/atmelimage.c |    2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/tools/atmelimage.c b/tools/atmelimage.c
> index 5b72ac5..0979eef 100644
> --- a/tools/atmelimage.c
> +++ b/tools/atmelimage.c
> @@ -131,7 +131,7 @@ static int atmel_verify_header(unsigned char *ptr, int image_size,
>  
>  	/* check the seven interrupt vectors of binary */
>  	for (pos = 0; pos < 7; pos++) {
> -		debug("atmelimage: interrupt vector #%d is 0x%08X\n", pos+1,
> +		debug("atmelimage: interrupt vector #%ld is 0x%08X\n", pos+1,

I'd rather use the '%zu' modifier here. On 32 Bit systems the size_t
might be a simple int and not a long int which also leads to warnings.

Andreas

>  		      ints[pos]);
>  		/*
>  		 * all vectors except the 6'th one must contain valid
>
Tom Rini Aug. 27, 2015, 11:26 a.m. UTC | #2
On Thu, Aug 27, 2015 at 12:37:52PM +0200, Andreas Bießmann wrote:
> Hi Tom,
> 
> On 08/26/2015 09:21 PM, Tom Rini wrote:
> > Otherwise we get:
> > tools/atmelimage.c:134:3: warning: format ‘%d’ expects argument of type ‘int’, but argument 2 has type ‘size_t’ [-Wformat=]
> > debug("atmelimage: interrupt vector #%d is 0x%08X\n", pos+1,
> > ^
> > 
> > Signed-off-by: Tom Rini <trini@konsulko.com>
> > ---
> >  tools/atmelimage.c |    2 +-
> >  1 file changed, 1 insertion(+), 1 deletion(-)
> > 
> > diff --git a/tools/atmelimage.c b/tools/atmelimage.c
> > index 5b72ac5..0979eef 100644
> > --- a/tools/atmelimage.c
> > +++ b/tools/atmelimage.c
> > @@ -131,7 +131,7 @@ static int atmel_verify_header(unsigned char *ptr, int image_size,
> >  
> >  	/* check the seven interrupt vectors of binary */
> >  	for (pos = 0; pos < 7; pos++) {
> > -		debug("atmelimage: interrupt vector #%d is 0x%08X\n", pos+1,
> > +		debug("atmelimage: interrupt vector #%ld is 0x%08X\n", pos+1,
> 
> I'd rather use the '%zu' modifier here. On 32 Bit systems the size_t
> might be a simple int and not a long int which also leads to warnings.

Oh that's right, %zu is what you should do for size_t.  I thought I was
doing something wrong but couldn't recall.  Thanks, I'll v2 later today.
Andreas Bießmann Aug. 28, 2015, 7:20 a.m. UTC | #3
+u-boot ML

On 08/27/2015 07:54 PM, Tom Rini wrote:
> Otherwise we get:
> tools/atmelimage.c:134:3: warning: format ‘%d’ expects argument of type ‘int’, but argument 2 has type ‘size_t’ [-Wformat=]
> debug("atmelimage: interrupt vector #%d is 0x%08X\n", pos+1,
> ^
> 
> Cc: Andreas Bießmann <andreas.devel@googlemail.com>
> Signed-off-by: Tom Rini <trini@konsulko.com>

Reviewed-by: Andreas Bießmann <andreas.devel@googlemail.com>

> 
> ---
> Changes in v2:
> - Use %zu not %ld as noted by Andreas Bießmann
> ---
>  tools/atmelimage.c |    2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/tools/atmelimage.c b/tools/atmelimage.c
> index 5b72ac5..6b5603e 100644
> --- a/tools/atmelimage.c
> +++ b/tools/atmelimage.c
> @@ -131,7 +131,7 @@ static int atmel_verify_header(unsigned char *ptr, int image_size,
>  
>  	/* check the seven interrupt vectors of binary */
>  	for (pos = 0; pos < 7; pos++) {
> -		debug("atmelimage: interrupt vector #%d is 0x%08X\n", pos+1,
> +		debug("atmelimage: interrupt vector #%zu is 0x%08X\n", pos+1,
>  		      ints[pos]);
>  		/*
>  		 * all vectors except the 6'th one must contain valid
>
Tom Rini Aug. 28, 2015, 9:05 p.m. UTC | #4
On Fri, Aug 28, 2015 at 09:20:18AM +0200, Andreas Bießmann wrote:

> +u-boot ML
> 
> On 08/27/2015 07:54 PM, Tom Rini wrote:
> > Otherwise we get:
> > tools/atmelimage.c:134:3: warning: format ‘%d’ expects argument of type ‘int’, but argument 2 has type ‘size_t’ [-Wformat=]
> > debug("atmelimage: interrupt vector #%d is 0x%08X\n", pos+1,
> > ^
> > 
> > Cc: Andreas Bießmann <andreas.devel@googlemail.com>
> > Signed-off-by: Tom Rini <trini@konsulko.com>
> 
> Reviewed-by: Andreas Bießmann <andreas.devel@googlemail.com>

Applied to u-boot/master, thanks!
diff mbox

Patch

diff --git a/tools/atmelimage.c b/tools/atmelimage.c
index 5b72ac5..0979eef 100644
--- a/tools/atmelimage.c
+++ b/tools/atmelimage.c
@@ -131,7 +131,7 @@  static int atmel_verify_header(unsigned char *ptr, int image_size,
 
 	/* check the seven interrupt vectors of binary */
 	for (pos = 0; pos < 7; pos++) {
-		debug("atmelimage: interrupt vector #%d is 0x%08X\n", pos+1,
+		debug("atmelimage: interrupt vector #%ld is 0x%08X\n", pos+1,
 		      ints[pos]);
 		/*
 		 * all vectors except the 6'th one must contain valid