From owner-svn-src-all@freebsd.org Tue Aug 16 15:58:48 2016 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 40C6FBBC3FD; Tue, 16 Aug 2016 15:58:48 +0000 (UTC) (envelope-from brde@optusnet.com.au) Received: from mail106.syd.optusnet.com.au (mail106.syd.optusnet.com.au [211.29.132.42]) by mx1.freebsd.org (Postfix) with ESMTP id 0A9661D6A; Tue, 16 Aug 2016 15:58:47 +0000 (UTC) (envelope-from brde@optusnet.com.au) Received: from c122-106-149-109.carlnfd1.nsw.optusnet.com.au (c122-106-149-109.carlnfd1.nsw.optusnet.com.au [122.106.149.109]) by mail106.syd.optusnet.com.au (Postfix) with ESMTPS id C90133C1F0B; Wed, 17 Aug 2016 01:29:49 +1000 (AEST) Date: Wed, 17 Aug 2016 01:29:49 +1000 (EST) From: Bruce Evans X-X-Sender: bde@besplex.bde.org To: Ed Schouten cc: Emmanuel Vadot , src-committers , svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: Re: svn commit: r304221 - head/sys/boot/efi/boot1 In-Reply-To: Message-ID: <20160817010752.S2142@besplex.bde.org> References: <201608161423.u7GENZJi021956@repo.freebsd.org> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII; format=flowed X-Optus-CM-Score: 0 X-Optus-CM-Analysis: v=2.1 cv=CoZCCSMD c=1 sm=1 tr=0 a=R/f3m204ZbWUO/0rwPSMPw==:117 a=L9H7d07YOLsA:10 a=9cW_t1CCXrUA:10 a=s5jvgZ67dGcA:10 a=kj9zAlcOel0A:10 a=4GrCeSYe2VWqUJf7sEoA:9 a=CjuIK1q_8ugA:10 X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.22 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: Tue, 16 Aug 2016 15:58:48 -0000 On Tue, 16 Aug 2016, Ed Schouten wrote: > Hi Emmanuel, >> >> Log: >> Use %ju modifier for u_int64_t and %jd modifier for off_t. >> off_t is long long on arm32 and long on amd64 > > I think both of these should be solved differently: > > - For uint64_t, you can use 's PRIu64 in the formatting > string. In kernel space, I suspect you need to use something like > . Ugh. > - For off_t, it's all right to print it with %jd, but then be sure to > also add a cast to the argument itself. It may not necessarily be > equal to an intmax_t. This shows how stupid the PRI* macros are. They might be available for 0.1% of typedefed types in a medium-sized source tree. But to use them, you have to know their exact type, and change all printfs using them whenever the typedef is changed. If it is changed to a non-fixed width type, then the printfs need lots of editing to change to a cast. Their only advantage is that they are more space and time efficient, especially on 16-bit systems. Extensive use of fixed-width type is another bug. It asks for a fixed ABI at any cost to efficiency or space. FreeBSD almost never uses "fast" or "least" integer types. However, if you use these types, there are PRI* mistakes for them too. The SCN* macros are not quite as stupid as PRI*, but they should never be used. scanf() is already unusable since it gives undefined behaviour on overflow. These macros are not quite as stupid as PRI* since casts don't work so well for input. The corrsponding thing is to scan input into variables of type [u]intmax_t and convert to the corresponding type, of course without any bounds checking so that you get similar undefined behaviour on overflow as when using SCN*. Bruce