Checks to see if unsigned integers < 0
simo
idra at samba.org
Mon Jul 15 11:35:34 MDT 2013
On Mon, 2013-07-15 at 17:05 +0200, Volker Lendecke wrote:
> On Mon, Jul 15, 2013 at 08:47:12AM -0400, simo wrote:
> > On Mon, 2013-07-15 at 11:28 +0200, Volker Lendecke wrote:
> > > On Fri, Jul 12, 2013 at 08:36:13PM +0200, Herwin Weststrate wrote:
> > > > (Issues were found compiling with clang, so it's a kind of static
> > > > code analysis)
> > > >
> > > > A number of times some checks are run to see if an unsigned integer
> > > > is smaller than zero. Of course this cannot be true, this patch
> > > > removes these checks.
> > >
> > > Question -- is it guaranteed by Posix that uid_t is unsigned?
> > >
> > > Volker
> > >
> >
> > All I can find about uids in Posix:
> >
> > 3.430 User ID
> > A non-negative integer that is used to identify a system user.
> > When the identity of a user is associated with a process, a user
> > ID value is referred to as a real user ID, an effective user ID,
> > or a saved set-user-ID.
> >
> > It says the id must be a non-negative integer. Granted it could be
> > represented by a signed integer with the prohibition to use its negative
> > values, but that is highly unlikely. It is more likely that all
> > platforms simply typedef a unsigned int to uid_t
>
> With this vague statement I am a bit reluctant to remove the
> uid<0 checks just because the most popular platform has that
> as an unsigned. Maybe we should #ifdef that somehow if it is
> a real problem?
Let's put it another way, do you know of any platform that does not
define it as a unsigned integer ?
Anyway I do not really have a strong opinion on removing the checks.
Simo.
More information about the samba-technical
mailing list