Re: reason for fd<0 for g_open?

On Mon, Jan 03, 2011 at 12:39:27PM +0100, Schneider Hanro wrote:
> I use and implement the key-value file parser on wince. In gkeyfile.c
> we have some calls of g_open(). The resulting descriptor of g_open
> sometimes has a negativ sign. This means a succesfull opened file, if
> less than -1. But the statements "fd < 0" in gkeyfile.c generally
> cause errors. Is there a reason for  "fd < 0" instead of "fd != -1"
> according to the exact definition of g_open? For example, in
> glocalfaile.c, glocalfileoutputstream.c, gmappedfile.c we have the
> exact query to -1. Would it be possible to change the statements to
> "fd != -1" in gkeyfile.c? 

Hi Hanro,

there are more parts in glib/gtk where the fd<0 test is used, which I do
like more than fd != -1, though you seem to be right that windows allows
fd<-1 for valid file descriptors, that is virtually impossible on unix

I think inside a windows system, the file handle is a global object,
while the file descriptor in a unix system is private to the process.

But as glib/gtk+ should be cross platforms, the tests should be changed
to fd!=-1, which is POSIX conformant.

All reasons for fd<0 will be quite academic or a tribute to the lazy


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