From owner-freebsd-ipfw@FreeBSD.ORG Sun Mar 7 06:09:15 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 6298816A4CE; Sun, 7 Mar 2004 06:09:15 -0800 (PST) Received: from elvis.mu.org (elvis.mu.org [192.203.228.196]) by mx1.FreeBSD.org (Postfix) with ESMTP id 5DCA443D41; Sun, 7 Mar 2004 06:09:15 -0800 (PST) (envelope-from mux@freebsd.org) Received: by elvis.mu.org (Postfix, from userid 1920) id 537415C788; Sun, 7 Mar 2004 06:09:15 -0800 (PST) Date: Sun, 7 Mar 2004 15:09:15 +0100 From: Maxime Henrion To: Luigi Rizzo Message-ID: <20040307140915.GR35475@elvis.mu.org> References: <20040306111922.GA64109@numeri.campus.luth.se> <20040306082625.B34490@xorpc.icir.org> <20040306173219.GB64109@numeri.campus.luth.se> <20040306212233.A56351@xorpc.icir.org> <20040307113008.GC64109@numeri.campus.luth.se> <20040307051216.A74559@xorpc.icir.org> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20040307051216.A74559@xorpc.icir.org> User-Agent: Mutt/1.4.1i cc: ipfw@freebsd.org cc: Johan Karlsson 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 14:09:15 -0000 Luigi Rizzo wrote: > On Sun, Mar 07, 2004 at 12:30:08PM +0100, Johan Karlsson wrote: > ... > > Ok, how about the attached patch then? It takes care of all printf > > related warnings on -current. > > not there yet, sorry... > > No offense, but I think that rather than rushing for a commit you > should wait a few days to get some feedback from people using 64-bit > platforms (e.g. try to post to -sparc or -alpha, or ask some of > the people involved with 64-bit development), and also have a look > at how other system utilities deal with similar things (64-bit > counters and possible alignment problems -- what is the preferred > way to print out things, "%qu" or "%llu" ? I understand that > ipfw2.c does a mix of both things, i just have no idea which one is > better except that "unsigned long long" is a lot longer to > write than "u_quad_t" so that might favour "%qu" ?). > In any case, it's a weekend, give people a bit of time to read and > think about solutions. The "%llu" format is preferred over "%qu", because the latter is BSD-specific while the former is in C99 now (it was a GCC extension before). It is correct to cast to unsigned long long and use "%llu" to print an uint64_t because a long long is guaranteed to always be at least 64 bits. One should however still use uint64_t to store the type rather than unsigned long long because it may be bigger than 64 bits. So unsigned long long should only be used for the cast here. Cheers, Maxime