aboutgitcodelistschat:MatrixIRC
path: root/common
diff options
context:
space:
mode:
authorAlice Frosi <afrosi@redhat.com>2023-05-10 15:19:49 +0200
committerAlice Frosi <afrosi@redhat.com>2023-05-11 10:52:53 +0200
commit94df2efe2d2221bf0c4d77510142c95283d76f2b (patch)
tree68a137ca71de1f8d5f552d78de3ea3111230067b /common
parentb29288b8b000730bbd416b0e1f4f4c694e346e20 (diff)
downloadseitan-94df2efe2d2221bf0c4d77510142c95283d76f2b.tar
seitan-94df2efe2d2221bf0c4d77510142c95283d76f2b.tar.gz
seitan-94df2efe2d2221bf0c4d77510142c95283d76f2b.tar.bz2
seitan-94df2efe2d2221bf0c4d77510142c95283d76f2b.tar.lz
seitan-94df2efe2d2221bf0c4d77510142c95283d76f2b.tar.xz
seitan-94df2efe2d2221bf0c4d77510142c95283d76f2b.tar.zst
seitan-94df2efe2d2221bf0c4d77510142c95283d76f2b.zip
Clean-up error message and test
Refactoring error messages: - standardize error messages and functions - return on error instead of exit - test error when target doesn't exist - include ability to capture stderr and stdout in the tests
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:
*