From owner-freebsd-current Sun Mar 12 16: 6:32 2000 Delivered-To: freebsd-current@freebsd.org Received: from mail.originative.co.uk (mailgate.originative.co.uk [194.217.50.228]) by hub.freebsd.org (Postfix) with ESMTP id DAD5137B50E for ; Sun, 12 Mar 2000 16:06:20 -0800 (PST) (envelope-from paul@originative.co.uk) Received: from originative.co.uk (lobster.originative.co.uk [194.217.50.241]) by mail.originative.co.uk (Postfix) with ESMTP id 388821D132; Mon, 13 Mar 2000 00:06:19 +0000 (GMT) Message-ID: <38CC30FB.FC417909@originative.co.uk> Date: Mon, 13 Mar 2000 00:06:19 +0000 From: Paul Richards Organization: Originative Solutions Ltd X-Mailer: Mozilla 4.7 [en] (X11; I; FreeBSD 4.0-CURRENT i386) X-Accept-Language: en-GB, en MIME-Version: 1.0 To: keramida@ceid.upatras.gr Cc: John Polstra , current@FreeBSD.ORG Subject: Re: MAX_UID ? References: <38CAD957.3C839375@originative.co.uk> <200003120430.UAA49807@vashon.polstra.com> <38CB322D.D12ED0B0@originative.co.uk> <20000313015009.A5653@hades.hell.gr> Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Sender: owner-freebsd-current@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG Giorgos Keramidas wrote: > > On Sun, Mar 12, 2000 at 05:59:09AM +0000, Paul Richards wrote: > > > > Are expressions like ((uid_t)0-1) portable/safe ? Maybe that's a better > > way of approaching this. > > To get the all-1's number, maybe it's better to use ((uid_t)~0), but > that is a rather controversial topic anyway. Well it would be worth deciding on some standard way of dealing with this problem. I've been wandering around the code for the last few days and the same issue crops up all over the place i.e. bounds checking. There are a lot of programs that currently work on alpha only because no-one is hitting the boundary conditions e.g. ipfw checks for rule number limits based upon ULONG_MAX rather than the size of the field that holds the rule number. We could create a new include file that we use for constants that are related to FreeBSD specific types or we can agree on a coding style for performing bounds checking using tricks like ((uid_t)0-1) The code solution is robust in that if the type changes size the code still works. Using constants has the advantage that it is easy to document what the limits are on certain paramters such as IPFW rule numbers since you'll be able to look them up. All we have to do then is write all the bounds checking code :-) Paul. To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-current" in the body of the message