summaryrefslogtreecommitdiff
path: root/ubi-utils/src/libubi_int.h
diff options
context:
space:
mode:
authorArtem Bityutskiy <Artem.Bityutskiy@nokia.com>2008-02-06 18:59:15 +0200
committerArtem Bityutskiy <Artem.Bityutskiy@nokia.com>2008-02-06 18:59:15 +0200
commita71f0ce8c5f80757096f6e4d0ebca27ccbe14da9 (patch)
tree07645e323044fcfb331df157a80a84b624cdab51 /ubi-utils/src/libubi_int.h
parentf3d507be006c46870818c549b8f7dc0b4daccf03 (diff)
ubi-tools: improve printing macros
Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
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.