chiark
/
gitweb
/
~ianmdlvl
/
elogind.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
util: add a bit of syntactic sugar for saving/restoring errno
[elogind.git]
/
src
/
shared
/
util.h
diff --git
a/src/shared/util.h
b/src/shared/util.h
index d1cdd901a04fc2a31603351f788eb09dec7585a0..7f050758a0088b9ebdb87d11c91557b1b5b5abde 100644
(file)
--- 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);
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