Electronics & Programming

develissimo

Open Source electronics development and programming

  • You are not logged in.
  • Root
  • » GTK+
  • » reason for fd<0 for g_open? [RSS Feed]

#1 Jan. 3, 2011 11:39:48

Schneider H.
Registered: 2009-11-02
Reputation: +  0  -
Profile   Send e-mail  

reason for fd<0 for g_open?


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?

Regards
Hanro
--
Empfehlen Sie GMX DSL Ihren Freunden und Bekannten und wir
belohnen Sie mit bis zu 50,- Euro!https://freundschaftswerbung.gmx.de_______________________________________________
gtk-list mailing list
gtk-list@gnome.orghttp://mail.gnome.org/mailman/listinfo/gtk-list

Offline

#2 Jan. 3, 2011 22:50:35

Ingo K.
Registered: 2009-11-02
Reputation: +  0  -
Profile   Send e-mail  

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
systems.

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
typist.

Regards,
Ingo
_______________________________________________
gtk-list mailing list
gtk-list@gnome.orghttp://mail.gnome.org/mailman/listinfo/gtk-list

Offline

Board footer

Moderator control

Enjoy the 12th of December
PoweredBy

The Forums are managed by develissimo stuff members, if you find any issues or misplaced content please help us to fix it. Thank you! Tell us via Contact Options
Leave a Message
Welcome to Develissimo Live Support