aboutgitcodelistschat:MatrixIRC
path: root/common
diff options
context:
space:
mode:
Diffstat (limited to 'common')
-rw-r--r--common/util.h12
1 files changed, 12 insertions, 0 deletions
diff --git a/common/util.h b/common/util.h
index 102b55b..ad2192b 100644
--- a/common/util.h
+++ b/common/util.h
@@ -8,6 +8,7 @@
#include <string.h>
#include <stdint.h>
+#include <errno.h>
#define BIT(n) (1UL << (n))
@@ -33,6 +34,17 @@ void debug(const char *format, ...);
exit(EXIT_FAILURE); \
} while (0)
+#define ret_err(e, ...) \
+ do { \
+ if (errno == 0) { \
+ err(__VA_ARGS__); \
+ } else { \
+ fprintf(stderr, __VA_ARGS__); \
+ fprintf(stderr, ": %s\n", strerror(errno)); \
+ } \
+ return (e); \
+ } while (0)
+
/**
* From the Linux kernel, include/linux/log2.h:
*