diff options
author | Lennart Poettering <lennart@poettering.net> | 2013-04-02 16:31:55 +0200 |
---|---|---|
committer | Lennart Poettering <lennart@poettering.net> | 2013-04-02 17:47:59 +0200 |
commit | 5c0aa72a4999bdcf03fe93ed5c8213c2b4c681f0 (patch) | |
tree | 470f285684f6b3e79f9ff8c561deaa07a166cb07 /src/shared/util.h | |
parent | 2875e22b65452896d5569eecb3a08265dd658173 (diff) |
util: add a bit of syntactic sugar for saving/restoring errno
Diffstat (limited to 'src/shared/util.h')
-rw-r--r-- | src/shared/util.h | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/src/shared/util.h b/src/shared/util.h index d1cdd901a0..7f050758a0 100644 --- a/src/shared/util.h +++ b/src/shared/util.h @@ -615,3 +615,9 @@ char *strextend(char **x, ...); char *strrep(const char *s, unsigned n); void* greedy_realloc(void **p, size_t *allocated, size_t need); + +static inline void reset_errno(int *saved_errno) { + errno = *saved_errno; +} + +#define PROTECT_ERRNO __attribute__((cleanup(reset_errno))) int _saved_errno_ = errno |