This is the mail archive of the
newlib@sourceware.org
mailing list for the newlib project.
[PATCH] stdio: fix nano-vfprintf pointer formating with long pointers
- From: "Peter A. Bigot" <pab at pabigot dot com>
- To: newlib at sourceware dot org
- Cc: "Peter A. Bigot" <pab at pabigot dot com>, nickc at redhat dot com
- Date: Wed, 19 Nov 2014 11:01:37 -0600
- Subject: [PATCH] stdio: fix nano-vfprintf pointer formating with long pointers
- Authentication-results: sourceware.org; auth=none
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