Checks to see if unsigned integers < 0
Volker Lendecke
Volker.Lendecke at SerNet.DE
Mon Jul 15 09:05:24 MDT 2013
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?
Volker
--
SerNet GmbH, Bahnhofsallee 1b, 37081 Göttingen
phone: +49-551-370000-0, fax: +49-551-370000-9
AG Göttingen, HRB 2816, GF: Dr. Johannes Loxen
http://www.sernet.de, mailto:kontakt at sernet.de
More information about the samba-technical
mailing list