From a71f0ce8c5f80757096f6e4d0ebca27ccbe14da9 Mon Sep 17 00:00:00 2001 From: Artem Bityutskiy Date: Wed, 6 Feb 2008 18:59:15 +0200 Subject: ubi-tools: improve printing macros Signed-off-by: Artem Bityutskiy --- ubi-utils/src/libubi_int.h | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) (limited to 'ubi-utils/src/libubi_int.h') 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 +#include + #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. -- cgit v1.2.3