From owner-freebsd-ipfw@FreeBSD.ORG Sat Mar 6 21:22:34 2004 Return-Path: Delivered-To: freebsd-ipfw@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 98FD416A4CE; Sat, 6 Mar 2004 21:22:34 -0800 (PST) Received: from xorpc.icir.org (xorpc.icir.org [192.150.187.68]) by mx1.FreeBSD.org (Postfix) with ESMTP id 8B5FC43D1F; Sat, 6 Mar 2004 21:22:34 -0800 (PST) (envelope-from rizzo@icir.org) Received: from xorpc.icir.org (localhost [127.0.0.1]) by xorpc.icir.org (8.12.9p1/8.12.8) with ESMTP id i275MX9Q057340; Sat, 6 Mar 2004 21:22:33 -0800 (PST) (envelope-from rizzo@xorpc.icir.org) Received: (from rizzo@localhost) by xorpc.icir.org (8.12.9p1/8.12.3/Submit) id i275MXba057339; Sat, 6 Mar 2004 21:22:33 -0800 (PST) (envelope-from rizzo) Date: Sat, 6 Mar 2004 21:22:33 -0800 From: Luigi Rizzo To: Johan Karlsson Message-ID: <20040306212233.A56351@xorpc.icir.org> References: <20040306111922.GA64109@numeri.campus.luth.se> <20040306082625.B34490@xorpc.icir.org> <20040306173219.GB64109@numeri.campus.luth.se> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.2.5.1i In-Reply-To: <20040306173219.GB64109@numeri.campus.luth.se>; from johan@freebsd.org on Sat, Mar 06, 2004 at 06:32:19PM +0100 cc: ipfw@freebsd.org Subject: Re: where do %j/uintmax_t stand in terms of standards? [WAS: Re: WARNS cleanup for ipfw X-BeenThere: freebsd-ipfw@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: IPFW Technical Discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 07 Mar 2004 05:22:34 -0000 On Sat, Mar 06, 2004 at 06:32:19PM +0100, Johan Karlsson wrote: > [lets move this from ipfw@ to standars@ to get an answer] > > > On Sat, Mar 06, 2004 at 08:26 (-0800) +0000, Luigi Rizzo wrote: > > On Sat, Mar 06, 2004 at 12:19:22PM +0100, Johan Karlsson wrote: > > > Hi > > > > > > the attached patch makes ipfw WARNS=2 clean by using the > > > %j/(uintmax_t) combo where so needed. If there are no > > > objections I intend to commit this patch. > > First of all, %j/uintmax_t is used since uint64_t does not match > long long on all our platforms. Hence to print this without warning > we need to do this. ok, given that our counters _are_ 64 bits on all platforms, and that it would be nice to use the same code on 4.x and 5.x (at least, I'd hate to see a large number of differences for something trivial as a printf specifier), i suggest to leave the print format as "%llu", which is supported on all versions and platforms, and change align_uint64() as following: -static __inline uint64_t +static unsigned long long align_uint64(uint64_t *pll) { uint64_t ret; + /* make sure the value is correctly aligned, as pll might be not */ bcopy (pll, &ret, sizeof(ret)); - return ret; + return (unsigned long long)ret; }; (we do not care about __inline since this is always called within a *printf() which is way more expensive). This should close the issue, and is a lot more readable and portable than the proposed patch or my previous suggestion. cheers luigi