lynx-dev
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: lynx-dev Re: casts


From: pg
Subject: Re: lynx-dev Re: casts
Date: Tue, 19 Oct 1999 15:47:05 -0600 (MDT)

In a recent note, Webmaster Jim said:

> Date: Tue, 19 Oct 1999 17:13:58 -0400
>  
> > Casting the first parameter of FD_SET to (unsigned) looks completely
> > wrong to me.  I haven't seen any other programs that do this.
> > File descriptors on Unix are int, not unsigned.

> > If your system (with the specific Borland compiler and header files)
> > needs (unsigned), it is incompatible with most of the rest of the
> > world...  The rest of the world shouldn't have to adapt.  Rather
> > the definition/implementation of FD_SET itself do the cast itself,
> > if that's what it takes.
> 
> Presumably a Borland screw-up. I don't know what a negative file
> descriptor would mean, so assumed unsigned was just a saftey catch.
> 
Simple enough; on Solaris, "man open":

RETURN VALUES
     Upon successful completion, the function opens the file  and
     return  a  non-negative integer representing the lowest num-
     bered unused file descriptor.  Otherwise, -1 is returned and
     errno is set to indicate the error.  No files are created or
     modified if the function returns -1.

So, at least at open() time, you'd better assign the result to an
int, not an unsigned.  Reasonably, any other function that takes
a file descriptor as an argument should use the same type returned
by open()

> > So, shouldn't we get rid of some of theses casts? At least for file
> > descriptors?
> 
> Sure, if it makes the code better for all.
> 
Besides, I don't know any compiler that doesn't convert on assignment.

-- gil
-- 
StorageTek
INFORMATION made POWERFUL

reply via email to

[Prev in Thread] Current Thread [Next in Thread]