Date: Tue, 11 Oct 2011 11:56:17 +0200 From: =?utf-8?Q?Dag-Erling_Sm=C3=B8rgrav?= <des@des.no> To: Jaakko Heinonen <jh@FreeBSD.org> Cc: svn-src-head@freebsd.org, svn-src-all@freebsd.org, src-committers@freebsd.org Subject: Re: svn commit: r226151 - head/usr.bin/kdump Message-ID: <868vorkg1q.fsf@ds4.des.no> In-Reply-To: <20111011090049.GA69508@jh> (Jaakko Heinonen's message of "Tue, 11 Oct 2011 12:00:50 %2B0300") References: <201110081221.p98CLpWq062285@svn.freebsd.org> <20111010145642.GA2057@a91-153-123-205.elisa-laajakaista.fi> <86hb3gj7ja.fsf@ds4.des.no> <20111011090049.GA69508@jh>
next in thread | previous in thread | raw e-mail | index | archive | help
Jaakko Heinonen <jh@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@des.no
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?868vorkg1q.fsf>
