svn commit: r226151 - head/usr.bin/kdump
Dag-Erling Smørgrav
des at des.no
Tue Oct 11 09:56:19 UTC 2011
Jaakko Heinonen <jh at FreeBSD.org> writes:
> I am not sure if you understood what I meant here. Casting to uintmax_t
> is obviously more correct but print_number() will still print the
> negative range in "64-bit" format on i386.
Hmm, you are right, it would have worked if *i was first cast to an
unsigned type of the correct size. Unfortunately, the print_number()
macro does not know the correct size, so we have to play games with
sizeof() and hope the compiler optimizes away the unused code:
@@ -113,6 +114,8 @@
#define print_number(i,n,c) do { \
if (decimal) \
printf("%c%jd", c, (intmax_t)*i); \
+ else if (sizeof(*i) == sizeof(long)) \
+ printf("%c%#lx", c, (unsigned long)*i); \
else \
printf("%c%#jx", c, (uintmax_t)*i); \
i++; \
The root of the problem is that register_t is signed, which it shouldn't
be, IMHO.
DES
--
Dag-Erling Smørgrav - des at des.no
More information about the svn-src-all
mailing list