🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: gnu.gcc.help
Article #50536

Re: ?Comparison always 0|1 ....???

#50536
From: D. Erway
Date: Tue, 21 Sep 1993 18:42
26 lines
1661 bytes
>>>>> On 17 Sep 1993 21:07:44 GMT, jgraf@lsil.com (Jim Graf) said:

 jgraf> Using gcc-2.3.3 on SunOS 4.1.3 I have been seeing these types of
 jgraf> warnings: ftpd.c: In function `makedir': ftpd.c:2151: warning:
 jgraf> comparison is always 1 due to limited range of data type

 jgraf> the code is:
 jgraf> makedir(char *name)
 jgraf> {
 jgraf>    uid_t uid = (uid_t) -1;
 jgraf>    gid_t gid = (gid_t) -1;
 jgraf>    uid_t oldid;
 jgraf> [deleted... ]
 jgraf>     if (uid >= 0) {            <-------- the offending line...
 jgraf> [deleted...]
 jgraf>     }

 jgraf> and uid_t is defined as unsigned short in /usr/include/sys/types.h

an unsigned value can NEVER be less than 0, therefore it is ALWAYS greater
than or equal to 0.

Also, setting them to -1 is actually setting them to 0xffff.

	-DOn
Technical Details
Message-ID: <DERWAY.93Sep21114220@alumni.cco.caltech.edu>
Path: arc1-ca.pugleaf.net!gmd.de!newsserver.jvnc.net!udel!wupost!howland.reston.ans.net!math.ohio-state.edu!cs.utexas.edu!uunet!news.claremont.edu!nntp-server.caltech.edu!nntp-server.caltech.edu!derway
References: <27d8v0$7ic@lsi.lsil.com>

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: 11318c,d4faafc586a6bfca
X-Google-Attributes: gid11318c,public
X-Google-ArrivalTime: 1993-09-21 12:15:30 PST
Path: arc1-ca.pugleaf.net!gmd.de!newsserver.jvnc.net!udel!wupost!howland.reston.ans.net!math.ohio-state.edu!cs.utexas.edu!uunet!news.claremont.edu!nntp-server.caltech.edu!nntp-server.caltech.edu!derway
From: derway@alumni.cco.caltech.edu (D. Erway)
Newsgroups: gnu.gcc.help
Subject: Re: ?Comparison always 0|1 ....???
Followup-To: gnu.gcc.help
Date: 21 Sep 1993 18:42:20 GMT
Organization: California Institute of Technology CCO Unix cluster
Lines: 26
Distribution: world
Message-ID: <DERWAY.93Sep21114220@alumni.cco.caltech.edu>
References: <27d8v0$7ic@lsi.lsil.com>
NNTP-Posting-Host: alumni.caltech.edu
In-reply-to: jgraf@lsil.com's message of 17 Sep 1993 21:07:44 GMT