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 639771 - g_dir_read_name() can also return NULL on error
g_dir_read_name() can also return NULL on error
Status: RESOLVED FIXED
Product: glib
Classification: Platform
Component: general
2.26.x
Other Linux
: Normal minor
: ---
Assigned To: gtkdev
gtkdev
Depends on:
Blocks:
 
 
Reported: 2011-01-17 18:05 UTC by Emmanuel Gamby
Modified: 2012-07-06 02:25 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
Improve the g_dir_read_name documentation (1.49 KB, patch)
2012-07-06 02:25 UTC, Matthias Clasen
committed Details | Review

Description Emmanuel Gamby 2011-01-17 18:05:23 UTC
g_dir_read_name() returns the entry's name or NULL if there are no more entries.

On POSIX systems, g_dir_read_name() is based on readdir() that can also return NULL if an error occurs. Checking errno allows normally to distinct between the two cases.

See example at http://pubs.opengroup.org/onlinepubs/007908799/xsh/readdir.html

The documentation should maybe be updated to inform the user to check errno when g_dir_read_name() returns NULL.
Comment 1 Matthias Clasen 2012-07-06 02:25:56 UTC
The following fix has been pushed:
ab4cc22 Improve the g_dir_read_name documentation
Comment 2 Matthias Clasen 2012-07-06 02:25:59 UTC
Created attachment 218144 [details] [review]
Improve the g_dir_read_name documentation

This function can return NULL in error cases as well. Document
this, and explain how to discriminate the cases.