[PATCH] stdio: fix nano-vfprintf pointer formating with long pointers

Peter A. Bigot pab@pabigot.com
Wed Nov 19 17:02:00 GMT 2014


On the MSP430 when building with -mlarge sizeof(void*) is larger than
sizeof(int), resulting in an offset error extracting arguments to format
strings that include %p.

stdio/ChangeLog:
2014-11-19  Peter A. Bigot  <pab@pabigot.com>

        * libc/stdio/nano-vfprintf_i.c (_printf_i): Use LONGINT when void* is
        larger than an int.

Cc: nickc@redhat.com
Signed-off-by: Peter A. Bigot <pab@pabigot.com>
---
 newlib/libc/stdio/nano-vfprintf_i.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/newlib/libc/stdio/nano-vfprintf_i.c b/newlib/libc/stdio/nano-vfprintf_i.c
index b75a142..992173b 100644
--- a/newlib/libc/stdio/nano-vfprintf_i.c
+++ b/newlib/libc/stdio/nano-vfprintf_i.c
@@ -150,8 +150,10 @@ _printf_i (struct _reent *data, struct _prt_data_t *pdata, FILE *fp,
        * defined manner.''
        *	-- ANSI X3J11
        */
-      /* NOSTRICT.  */
       pdata->flags |= HEXPREFIX;
+      if (sizeof(void*) > sizeof(int))
+        pdata->flags |= LONGINT;
+      /* NOSTRICT.  */
     case 'x':
       pdata->l_buf[2] = 'x';
       xdigs = "0123456789abcdef";
-- 
1.8.5.5



More information about the Newlib mailing list