summaryrefslogtreecommitdiff
path: root/ubi-utils/src/libubi_int.h
diff options
context:
space:
mode:
Diffstat (limited to 'ubi-utils/src/libubi_int.h')
-rw-r--r--ubi-utils/src/libubi_int.h16
1 files changed, 14 insertions, 2 deletions
diff --git a/ubi-utils/src/libubi_int.h b/ubi-utils/src/libubi_int.h
index 6490864..5b186a7 100644
--- a/ubi-utils/src/libubi_int.h
+++ b/ubi-utils/src/libubi_int.h
@@ -23,14 +23,26 @@
#ifndef __LIBUBI_INT_H__
#define __LIBUBI_INT_H__
+#include <string.h>
+#include <errno.h>
+
#ifdef __cplusplus
extern "C" {
#endif
/* Error messages */
-#define errmsg(fmt, ...) do { \
+#define errmsg(fmt, ...) ({ \
fprintf(stderr, "libubi error: " fmt "\n", ##__VA_ARGS__); \
-} while(0)
+ -1; \
+})
+
+/* System error messages */
+#define sys_errmsg(fmt, ...) ({ \
+ int _err = errno; \
+ fprintf(stderr, "libubi error: " fmt "\n", ##__VA_ARGS__); \
+ fprintf(stderr, "error %d (%s)", _err, strerror(_err)); \
+ -1; \
+})
/*
* The below are pre-define UBI file and directory names.