sim/microblaze/interp.c: Use long int format instead of int to avoid compiling warnings

Message ID 20150308072453.GV12857@vapier
State Committed
Headers

Commit Message

Mike Frysinger March 8, 2015, 7:24 a.m. UTC
  On 02 Aug 2014 13:21, Mike Frysinger wrote:
> On Tue 01 Jul 2014 08:14:46 Chen Gang wrote:
> 
> sim patches only go to gdb-patches, so don't include cgen/binutils in the 
> future please
> 
> > --- a/sim/microblaze/interp.c
> > +++ b/sim/microblaze/interp.c
> > 
> >    if (len > (int) sizeof (unsigned long))
> >      printf ("That operation is not available on integers of more than "
> > -	    "%d bytes.", sizeof (unsigned long));
> > +	    "%ld bytes.", sizeof (unsigned long));
> 
> unfortunately, i don't believe this is correct.  pretty sure the right answer 
> is %zu as sizeof() is a size_t.

i've committed this now
-mike

From 3e95021c775db2c483e87033ebef3d42ff99c7e0 Mon Sep 17 00:00:00 2001
From: Mike Frysinger <vapier@gentoo.org>
Date: Sun, 8 Mar 2015 03:24:03 -0400
Subject: [PATCH] sim: microblaze: fix printf string

Since sizeof returns a size_t, use %zu to display it.
---
 sim/microblaze/ChangeLog | 4 ++++
 sim/microblaze/interp.c  | 2 +-
 2 files changed, 5 insertions(+), 1 deletion(-)
  

Comments

Chen Gang March 8, 2015, 9:30 p.m. UTC | #1
On 3/8/15 15:24, Mike Frysinger wrote:
> 
> i've committed this now
> -mike
> 

Thank you for your work.

I shall try to make another patches for binutils/gdb within this month.
(before 2015-03-15, I am mainly focus on Linux kernel and qemu, after
2015-03-15, I am mainly focus on gcc/binutils).

Thanks.

> From 3e95021c775db2c483e87033ebef3d42ff99c7e0 Mon Sep 17 00:00:00 2001
> From: Mike Frysinger <vapier@gentoo.org>
> Date: Sun, 8 Mar 2015 03:24:03 -0400
> Subject: [PATCH] sim: microblaze: fix printf string
> 
> Since sizeof returns a size_t, use %zu to display it.
> ---
>  sim/microblaze/ChangeLog | 4 ++++
>  sim/microblaze/interp.c  | 2 +-
>  2 files changed, 5 insertions(+), 1 deletion(-)
> 
> diff --git a/sim/microblaze/ChangeLog b/sim/microblaze/ChangeLog
> index 0a068ff..e34a21d 100644
> --- a/sim/microblaze/ChangeLog
> +++ b/sim/microblaze/ChangeLog
> @@ -1,3 +1,7 @@
> +2015-03-08  Mike Frysinger  <vapier@gentoo.org>
> +
> +	* interp.c (microblaze_extract_unsigned_integer): Change %ld to %zu.
> +
>  2015-02-20  Mike Frysinger  <vapier@gentoo.org>
>  
>  	* interp.c: Delete sysdep.h and netinet/in.h includes.
> diff --git a/sim/microblaze/interp.c b/sim/microblaze/interp.c
> index 64850ef..ac2adb8 100644
> --- a/sim/microblaze/interp.c
> +++ b/sim/microblaze/interp.c
> @@ -51,7 +51,7 @@ microblaze_extract_unsigned_integer (unsigned char *addr, int len)
>  
>    if (len > (int) sizeof (unsigned long))
>      printf ("That operation is not available on integers of more than "
> -	    "%ld bytes.", sizeof (unsigned long));
> +	    "%zu bytes.", sizeof (unsigned long));
>  
>    /* Start at the most significant end of the integer, and work towards
>       the least significant.  */
>
  

Patch

diff --git a/sim/microblaze/ChangeLog b/sim/microblaze/ChangeLog
index 0a068ff..e34a21d 100644
--- a/sim/microblaze/ChangeLog
+++ b/sim/microblaze/ChangeLog
@@ -1,3 +1,7 @@ 
+2015-03-08  Mike Frysinger  <vapier@gentoo.org>
+
+	* interp.c (microblaze_extract_unsigned_integer): Change %ld to %zu.
+
 2015-02-20  Mike Frysinger  <vapier@gentoo.org>
 
 	* interp.c: Delete sysdep.h and netinet/in.h includes.
diff --git a/sim/microblaze/interp.c b/sim/microblaze/interp.c
index 64850ef..ac2adb8 100644
--- a/sim/microblaze/interp.c
+++ b/sim/microblaze/interp.c
@@ -51,7 +51,7 @@  microblaze_extract_unsigned_integer (unsigned char *addr, int len)
 
   if (len > (int) sizeof (unsigned long))
     printf ("That operation is not available on integers of more than "
-	    "%ld bytes.", sizeof (unsigned long));
+	    "%zu bytes.", sizeof (unsigned long));
 
   /* Start at the most significant end of the integer, and work towards
      the least significant.  */