After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 638768 - fd < 0 to fd == -1 in gkeyfile.c
fd < 0 to fd == -1 in gkeyfile.c
Status: RESOLVED FIXED
Product: glib
Classification: Platform
Component: general
2.26.x
Other Windows
: Normal normal
: ---
Assigned To: gtkdev
gtkdev
Depends on:
Blocks:
 
 
Reported: 2011-01-05 20:32 UTC by Hanro
Modified: 2011-06-03 20:03 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
patch gkeyfile.c (1.39 KB, patch)
2011-01-08 22:06 UTC, Hanro
committed Details | Review

Description Hanro 2011-01-05 20:32:21 UTC
In gkeyfile.c we have some statements:
if (fd < 0).

This is not precise according to the description of results of g_open() respectively POSIX open().
If an error occurred, the result is exactly -1.

For example in wince, the file descriptors are valid with a value of fd < -1.
But in such cases the program is aborted. That's not correct.

Therefore and for real cross compatibility the statements in gkeyfile.c should be changed to:
if (fd == -1).
Comment 1 Matthias Clasen 2011-01-07 17:15:40 UTC
A patch would be welcome.
Comment 2 Hanro 2011-01-08 22:06:49 UTC
Created attachment 177849 [details] [review]
patch gkeyfile.c
Comment 3 Christian Persch 2011-01-09 19:53:42 UTC
The same pattern exists in some other files in glib, and also some places in gio.
Comment 4 Colin Walters 2011-06-02 19:56:49 UTC
Wow, CE uses negative fds?  That's rather sadistic, but I assume it's mapping the file identifier from some other Windows-internal handle.

Anyways Hanro, I have turned your patch into a "git format-patch" style patch and committed it.  Please see:
http://live.gnome.org/GnomeLove/SubmittingPatches
for more information on submitting patches.  It saves a lot of time if you write the commit message.

commit 16bdb12e6dcb690d56baf52a34ba674052d39b6e
Author: Hanro <hanro@gmx.de>
Date:   Thu Jun 2 15:44:19 2011 -0400

    gkeyfile: Only test file descriptors against -1
    
    Windows CE at least will return other (valid) negative values.

    Commit message written by Colin Walters <walters@verbum.org>