From owner-svn-src-head@FreeBSD.ORG Tue Feb 14 14:50:46 2012 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 C937D1065670; Tue, 14 Feb 2012 14:50:46 +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 673A38FC16; Tue, 14 Feb 2012 14:50:46 +0000 (UTC) Received: from c211-30-171-136.carlnfd1.nsw.optusnet.com.au (c211-30-171-136.carlnfd1.nsw.optusnet.com.au [211.30.171.136]) by mail04.syd.optusnet.com.au (8.13.1/8.13.1) with ESMTP id q1EEocn9032432 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Wed, 15 Feb 2012 01:50:40 +1100 Date: Wed, 15 Feb 2012 01:50:38 +1100 (EST) From: Bruce Evans X-X-Sender: bde@besplex.bde.org To: Tijl Coosemans In-Reply-To: <201202141233.08733.tijl@coosemans.org> Message-ID: <20120215012213.M2798@besplex.bde.org> References: <201202141124.q1EBOOdE095840@svn.freebsd.org> <201202141233.08733.tijl@coosemans.org> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII; format=flowed Cc: svn-src-head@FreeBSD.org, src-committers@FreeBSD.org Subject: Re: svn commit: r231669 - head/sys/fs/tmpfs 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: Tue, 14 Feb 2012 14:50:46 -0000 On Tue, 14 Feb 2012, Tijl Coosemans wrote: > On Tuesday 14 February 2012 12:24:24 Tijl Coosemans wrote: >> Log: >> Replace PRIdMAX with "jd" in a printf call. Cast the corresponding value to >> intmax_t instead of uintmax_t, because the original type is off_t. > > There should really be a better way to print 64 bit numbers than (ab)using > intmax_t. I'm sort of interested in adding an int128_t type and that would > make intmax_t 128 bit. off_t isn't necessarily a 64-bit number. It needs to be 65 bits just to work without hacks for /dev/kmem on 64-bit machines. It might use your 128-bit type for that :-). This would be too wasteful for just that of course. The right way to print N-bit numbers is %I[AaeEFgGxX], where the compiler replaces %I in the string literal by the correct format for the arg (this might be %d, %u, %ld, ..., %ju, %f) instead of complaining that the format doesn't match the arg. Hex formats need and floating point formats other than %f need an extra letter. Floating point variadic args can only be double or long double IIRC, so %I is less needed for them (it lets the compiler handle the 'L's that specify long doubles). Field widths and precisions that separate the % from the I don't effect the meaning of the I. This only works if the types can be checked at compile time. Message catalogues can have more limited simplifications which I haven't thought about much. Language extensions that are not as standard as -Wformat seem to be needed even to detect type mismatches. Once they are detected, they can be fixed up by rewriting the format non-literal. The compiler can help a bit by rewriting the initial string literal and subsequent args in a form that is easier to rewrite. Bruce