diff options
author | Philip Withnall <withnall@endlessm.com> | 2017-07-31 11:30:55 +0100 |
---|---|---|
committer | Philip Withnall <withnall@endlessm.com> | 2017-08-03 10:21:13 +0100 |
commit | 5cddde1fb2b8466d8104595008eafabd0728de5d (patch) | |
tree | ea3f201272ca80118baee43c0a72babfc51244e6 /ChangeLog.pre-2-2 | |
parent | 41a4a70b433fc5a1e7b0c536fdd3d32a9c214219 (diff) | |
download | glib-5cddde1fb2b8466d8104595008eafabd0728de5d.tar.gz |
Consistently save errno immediately after the operation setting it
Prevent the situation where errno is set by function A, then function B
is called (which is typically _(), but could be anything else) and it
overwrites errno, then errno is checked by the caller.
errno is a horrific API, and we need to be careful to save its value as
soon as a function call (which might set it) returns. i.e. Follow the
pattern:
int errsv, ret;
ret = some_call_which_might_set_errno ();
errsv = errno;
if (ret < 0)
puts (strerror (errsv));
This patch implements that pattern throughout GLib. There might be a few
places in the test code which still use errno directly. They should be
ported as necessary. It doesn’t modify all the call sites like this:
if (some_call_which_might_set_errno () && errno == ESOMETHING)
since the refactoring involved is probably more harmful than beneficial
there. It does, however, refactor other call sites regardless of whether
they were originally buggy.
https://bugzilla.gnome.org/show_bug.cgi?id=785577
Diffstat (limited to 'ChangeLog.pre-2-2')
0 files changed, 0 insertions, 0 deletions