From owner-svn-src-all@FreeBSD.ORG Fri Aug 13 14:35:22 2010 Return-Path: Delivered-To: svn-src-all@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id AD90210656E0; Fri, 13 Aug 2010 14:35:22 +0000 (UTC) (envelope-from brde@optusnet.com.au) Received: from mail02.syd.optusnet.com.au (mail02.syd.optusnet.com.au [211.29.132.183]) by mx1.freebsd.org (Postfix) with ESMTP id 3E8E18FC1A; Fri, 13 Aug 2010 14:35:21 +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 mail02.syd.optusnet.com.au (8.13.1/8.13.1) with ESMTP id o7DEZD6X027221 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Sat, 14 Aug 2010 00:35:15 +1000 Date: Sat, 14 Aug 2010 00:35:13 +1000 (EST) From: Bruce Evans X-X-Sender: bde@delplex.bde.org To: =?utf-8?Q?Dag-Erling_Sm=C3=B8rgrav?= In-Reply-To: <86iq3ess5a.fsf@ds4.des.no> Message-ID: <20100814001308.N12943@delplex.bde.org> References: <201008121358.o7CDwk0d098768@svn.freebsd.org> <86pqxn50vr.fsf@ds4.des.no> <4C6414A7.6020306@FreeBSD.org> <868w4bda7e.fsf@ds4.des.no> <4C643352.5010508@FreeBSD.org> <20100813200216.U12816@delplex.bde.org> <86iq3ess5a.fsf@ds4.des.no> MIME-Version: 1.0 Content-Type: MULTIPART/MIXED; BOUNDARY="0-1088411302-1281710113=:12943" Cc: src-committers@FreeBSD.org, John Baldwin , Takanori Watanabe , svn-src-all@FreeBSD.org, Bruce Evans , svn-src-head@FreeBSD.org Subject: Re: svn commit: r211221 - head/usr.sbin/acpi/acpidump X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 13 Aug 2010 14:35:22 -0000 This message is in MIME format. The first part should be readable text, while the remaining parts are likely unreadable without MIME-aware tools. --0-1088411302-1281710113=:12943 Content-Type: TEXT/PLAIN; charset=X-UNKNOWN; format=flowed Content-Transfer-Encoding: QUOTED-PRINTABLE On Fri, 13 Aug 2010, [utf-8] Dag-Erling Sm=C3=B8rgrav wrote: > Bruce Evans writes: >> - `platform_class' has type uint16_t. u_int is larger than that on all >> supported machines, and also on unsupported ones with 16-31 bit u_ints= =2E >> Thus the cast has almost no effect, and has no effect on the result. > > you have to cast it to *something*, unless you're willing to assume > blindly that uint16_t =3D=3D unsigned short (and use %h). No, all function parameters are converted to *something*, and as I partly explained above, the default something is always int or u_int, with the lofical sign error for the int not causing any problems. Various cases: - K&R compiler, or C90-C99 compiler with no prototype in scope: integer parameters are converted to int or u_int if they are smaller than that to start, else they are not converted. - variadic function for a parameter after `...': same as for K&R. - %h format for printf: makes little or no difference except for bogus parameters. The parameter must end up as int or u_int after the default promotion. The %h causes the parameter to be downcast to short or u_sho= rt. This is different from taking a short or u_short parameter. You just can't pass a short or a u_short to a variadic function, Here uint16_t is converted to u_int on machines with 16-bit ints, else it is converted to int. >> Anyway, almost all typedefed types should be cast to [u]intmax_t for >> printing, so that you don't have to know too much about what they are. > > long or even int is fine in many cases, e.g. uid_t, mode_t Though it works now, it might break someday. 32-bit ino_t and printing it with %u should have broken already. Bruce --0-1088411302-1281710113=:12943--