[PATCH] fix printf "%p" output on 64-bit platform

Atsushi Nemoto anemo at mba.ocn.ne.jp
Tue Nov 7 07:36:36 UTC 2006


I found printf("%p", ...) prints only 32bit value on 64-bit platform
(length of "long" and "void *" are 64 bit).

I cooked a patch, but I'm not sure this is a right place to fix.
Please review.  Thanks.

---
Atsushi Nemoto
-------------- next part --------------
diff -ur uClibc-20061105/libc/stdio/_vfprintf.c uClibc/libc/stdio/_vfprintf.c
--- uClibc-20061105/libc/stdio/_vfprintf.c	2006-11-05 17:10:12.000000000 +0900
+++ uClibc/libc/stdio/_vfprintf.c	2006-11-07 16:03:40.000000000 +0900
@@ -1566,7 +1566,7 @@
 #endif /* __UCLIBC_MJN3_ONLY__ */
 			s = _uintmaxtostr(buf + sizeof(buf) - 1,
 							  (uintmax_t)
-							  _load_inttype(*argtype & __PA_INTMASK,
+							  _load_inttype(ppfs->conv_num == CONV_p ? PA_FLAG_LONG : *argtype & __PA_INTMASK,
 											*argptr, base), base, alphacase);
 			if (ppfs->conv_num > CONV_u) { /* signed int */
 				if (*s == '-') {


More information about the uClibc mailing list