From owner-svn-src-head@FreeBSD.ORG Fri Aug 13 09:06:53 2010 Return-Path: Delivered-To: svn-src-head@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 6022F1065693; Fri, 13 Aug 2010 09:06:53 +0000 (UTC) (envelope-from brde@optusnet.com.au) Received: from mail04.syd.optusnet.com.au (mail04.syd.optusnet.com.au [211.29.132.185]) by mx1.freebsd.org (Postfix) with ESMTP id E8E778FC1A; Fri, 13 Aug 2010 09:06:52 +0000 (UTC) Received: from c122-106-147-41.carlnfd1.nsw.optusnet.com.au (c122-106-147-41.carlnfd1.nsw.optusnet.com.au [122.106.147.41]) by mail04.syd.optusnet.com.au (8.13.1/8.13.1) with ESMTP id o7D96mN1007845 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Fri, 13 Aug 2010 19:06:50 +1000 Date: Fri, 13 Aug 2010 19:06:48 +1000 (EST) From: Bruce Evans X-X-Sender: bde@delplex.bde.org To: Takanori Watanabe In-Reply-To: <201008130045.o7D0jUW6043601@svn.freebsd.org> Message-ID: <20100813190247.I12761@delplex.bde.org> References: <201008130045.o7D0jUW6043601@svn.freebsd.org> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII; format=flowed Cc: svn-src-head@FreeBSD.org, svn-src-all@FreeBSD.org, src-committers@FreeBSD.org Subject: Re: svn commit: r211252 - head/usr.sbin/acpi/acpidump X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 13 Aug 2010 09:06:53 -0000 On Fri, 13 Aug 2010, Takanori Watanabe wrote: > Log: > Fix build on amd64 and ia64. Why not fix it on all arches? > Modified: head/usr.sbin/acpi/acpidump/acpi.c > ============================================================================== > --- head/usr.sbin/acpi/acpidump/acpi.c Fri Aug 13 00:21:32 2010 (r211251) > +++ head/usr.sbin/acpi/acpidump/acpi.c Fri Aug 13 00:45:30 2010 (r211252) > ... > @@ -623,7 +622,7 @@ acpi_handle_tcpa(ACPI_TABLE_HEADER *sdp) > { > struct TCPAbody *tcpa; > struct TCPAevent *event; > - u_int64_t len, paddr; > + uint64_t len, paddr; > unsigned char *vaddr = NULL; > unsigned char *vend = NULL; > > @@ -647,7 +646,7 @@ acpi_handle_tcpa(ACPI_TABLE_HEADER *sdp) > printf(END_COMMENT); > return; > } > - printf("\tClass %d Base Address 0x%jx Length %" PRIu64 "\n\n", > + printf("\tClass %u Base Address 0x%jx Length %ju\n\n", > tcpa->platform_class, paddr, len); > > if (len == 0) { For `len', this used to assume that variables of type u_int64_t can be printed using PRIu64. Why the PRIu64 abomination should never be used, this assumption is valid. For `len', this now assumes that variables of type uint64_t can be printed using %ju format. %ju format is for printing variables of type uintmax_t, so this assumption is invalid unless uint64_t is the same as uintmax_t. This assumption happens to be valid on all supported arches, although it should not be (e.g., on amd64, uint64_t and uintmax_t both happen to be u_long, but this is illogical since uintmax_t is supposed to be the largest unsigned integer type but u_long is logically shorter than unsigned long long). Fixing these arches might expose many printf format errors like the above. For `paddr', this used to and still invalidly assumes that variables of type uint64_t can be printed using %ju format. PRIu64 is "lu" on both amd64 and ia64, and __uint64_t is u_long on both amd64 and ia64, so I don't see how the original version failed. In fact, it doesn't fail for me. __uintmax_t is u_long on both amd64 and ia64, so the modified version should work too, though accidentally, just like the unmodified version works accidentally for `paddr'. To expose even more printf format errors like the above, make __uintmax_t unsigned long long on amd64 and keep it as the illogical u_long on amd64. Bruce