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 658315 - g_key_file_get_keys() should set length to 0 if there is an error
g_key_file_get_keys() should set length to 0 if there is an error
Status: RESOLVED NOTABUG
Product: glib
Classification: Platform
Component: general
unspecified
Other Linux
: Normal normal
: ---
Assigned To: gtkdev
gtkdev
Depends on:
Blocks:
 
 
Reported: 2011-09-06 05:42 UTC by Guillaume Desmottes
Modified: 2012-01-16 04:19 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
g_key_file_get_keys: set length to 0 if an error is raised (828 bytes, patch)
2011-09-06 05:43 UTC, Guillaume Desmottes
none Details | Review

Description Guillaume Desmottes 2011-09-06 05:42:39 UTC
That's what I would have expected and makes things easier if one don't care if an error has been returned or not.
Comment 1 Guillaume Desmottes 2011-09-06 05:43:42 UTC
Created attachment 195751 [details] [review]
g_key_file_get_keys: set length to 0 if an error is raised
Comment 2 Dan Winship 2011-09-06 13:40:39 UTC
I feel like the default assumption with GError is that if an error is thrown, then you can't depend on the values of out variables.

http://developer.gnome.org/glib/stable/glib-Error-Reporting.html does not say either way though...
Comment 3 Matthias Clasen 2011-09-10 14:35:02 UTC
There's no general rule that 'out variables shall always be set'. So, if a function wants to guarantee that they will be set to known values even in the error case, that needs to be documented. 

That isn't the case case for g_key_file_get_keys().

As Dan says, we should probably clarify the expectations in the GError docs.
Comment 4 Matthias Clasen 2012-01-16 04:19:33 UTC
Documented this now