diff options
author | Beniamino Galvani <bgalvani@redhat.com> | 2019-02-20 17:59:37 +0100 |
---|---|---|
committer | Beniamino Galvani <bgalvani@redhat.com> | 2019-02-20 19:18:52 +0100 |
commit | 787a18c467c41d1e5bd8ec05af4afc29df63ea3d (patch) | |
tree | 4c94970e5902190d11d3cceda53ca6693b226a92 /shared/systemd/src/basic/util.h | |
parent | 209ff015e26f295bdb7c396962a4e9b4199398fb (diff) | |
parent | 62e6df1f1cd2b3588086dabd38172a30d1253901 (diff) | |
download | NetworkManager-bg/systemd.tar.gz |
systemd: merge branch systemd into masterbg/systemd
Diffstat (limited to 'shared/systemd/src/basic/util.h')
-rw-r--r-- | shared/systemd/src/basic/util.h | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/shared/systemd/src/basic/util.h b/shared/systemd/src/basic/util.h index f009d37d4c..dc33d66067 100644 --- a/shared/systemd/src/basic/util.h +++ b/shared/systemd/src/basic/util.h @@ -174,12 +174,21 @@ static inline void *mempset(void *s, int c, size_t n) { } static inline void _reset_errno_(int *saved_errno) { + if (*saved_errno < 0) /* Invalidated by UNPROTECT_ERRNO? */ + return; + errno = *saved_errno; } #define PROTECT_ERRNO \ _cleanup_(_reset_errno_) _unused_ int _saved_errno_ = errno +#define UNPROTECT_ERRNO \ + do { \ + errno = _saved_errno_; \ + _saved_errno_ = -1; \ + } while (false) + static inline int negative_errno(void) { /* This helper should be used to shut up gcc if you know 'errno' is * negative. Instead of "return -errno;", use "return negative_errno();" |