Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 12 Aug 2010 11:35:03 -0400
From:      John Baldwin <jhb@FreeBSD.org>
To:        =?UTF-8?B?RGFnLUVybGluZyBTbcO4cmdyYXY=?= <des@des.no>
Cc:        svn-src-head@freebsd.org, Takanori Watanabe <takawata@FreeBSD.org>, svn-src-all@freebsd.org, src-committers@freebsd.org
Subject:   Re: svn commit: r211221 - head/usr.sbin/acpi/acpidump
Message-ID:  <4C6414A7.6020306@FreeBSD.org>
In-Reply-To: <86pqxn50vr.fsf@ds4.des.no>
References:  <201008121358.o7CDwk0d098768@svn.freebsd.org> <86pqxn50vr.fsf@ds4.des.no>

next in thread | previous in thread | raw e-mail | index | archive | help
Dag-Erling Smørgrav wrote:
> Takanori Watanabe <takawata@FreeBSD.org> writes:
>> -	printf("\tClass %d Base Address 0x%jx Length %llu\n\n",
>> +	printf("\tClass %d Base Address 0x%jx Length %" PRIu64 "\n\n",
>>  	    tcpa->platform_class, paddr, len);
> 
> This is just as wrong as the previous attempt.
> 
> 1) platform_class is not an int.
> 2) paddr is not a uintmax_t.
> 3) so far, we've avoided using the PRI macros.
> 
> Slightly better:
> 
> 	printf("\tClass %u Base Address 0x%jx Length %ju\n\n",
>   	    (unsigned int)tcpa->platform_class, (uintmax_t)paddr, (uintmax_t)len);
> 
> but it would probably be easier to define paddr and len as unsigned long
> long instead of the misspelled u_int64_t, and use %llx and %llu.

Depends.  If the table defines a field to be a 64-bit integer, it is 
better to use an explicitly-64-bit integer type such as uint64_t rather 
than assuming that 'long long' is 64-bit.  Other ACPI table definitions 
all use fixed-size types like uint32_t and uint64_t since the tables are 
defined as fixed-size fields, not as 'long' and 'int'.  Using %j with 
uintmax_t casts is the solution used for other 64-bit fields in ACPI tables.

-- 
John Baldwin



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?4C6414A7.6020306>