This is the mail archive of the
newlib@sourceware.org
mailing list for the newlib project.
[PATCH v2] 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, amker dot cheng at gmail dot com
- Date: Thu, 20 Nov 2014 05:41:32 -0600
- Subject: [PATCH v2] stdio: fix nano-vfprintf pointer formating with long pointers
- Authentication-results: sourceware.org; auth=none
- References: <CAHFci281K74V_yhxrmUuC=hURPEzA+5Zf3m+b7Gu35ZA5m7=Ow at mail dot gmail dot com>
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.
Signed-off-by: Peter A. Bigot <pab@pabigot.com>
---
v2: conform to coding standards
Cc: nickc@redhat.com
Cc: amker.cheng@gmail.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..46945b3 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