Date: Mon, 13 Mar 2000 00:06:19 +0000 From: Paul Richards <paul@originative.co.uk> To: keramida@ceid.upatras.gr Cc: John Polstra <jdp@polstra.com>, current@FreeBSD.ORG Subject: Re: MAX_UID ? Message-ID: <38CC30FB.FC417909@originative.co.uk> References: <38CAD957.3C839375@originative.co.uk> <200003120430.UAA49807@vashon.polstra.com> <38CB322D.D12ED0B0@originative.co.uk> <20000313015009.A5653@hades.hell.gr>
next in thread | previous in thread | raw e-mail | index | archive | help
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
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?38CC30FB.FC417909>