aboutsummaryrefslogtreecommitdiff
path: root/ubifs-utils/common/defs.h
diff options
context:
space:
mode:
authorZhihao Cheng <chengzhihao1@huawei.com>2024-11-11 16:36:35 +0800
committerDavid Oberhollenzer <david.oberhollenzer@sigma-star.at>2024-11-11 10:32:45 +0100
commit14aa5e63ab989e4f85495e96a74f34d18813caf6 (patch)
treef9ab236f25f8047216f1ca2754cb4d9e3f7df392 /ubifs-utils/common/defs.h
parentbc85302b02f8a1af351d05050f9de8a54c68ba09 (diff)
ubifs-utils: Clean up error message printing functions
Functions 'err_msg' and 'sys_err_msg' are almost same with 'errmsg' and 'sys_errmsg', since 'errmsg' and 'sys_errmsg' can print programe name, so replace error message printing functions (ubifs-utils) with common lib functions(include/common.h). Signed-off-by: Zhihao Cheng <chengzhihao1@huawei.com> Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
Diffstat (limited to 'ubifs-utils/common/defs.h')
-rw-r--r--ubifs-utils/common/defs.h21
1 files changed, 8 insertions, 13 deletions
diff --git a/ubifs-utils/common/defs.h b/ubifs-utils/common/defs.h
index 143f6c6..3dafc6d 100644
--- a/ubifs-utils/common/defs.h
+++ b/ubifs-utils/common/defs.h
@@ -12,6 +12,13 @@
#include <byteswap.h>
#include <errno.h>
+#include "ubifs.h"
+
+/* common.h requires the PROGRAM_NAME macro */
+extern struct ubifs_info info_;
+#define PROGRAM_NAME (info_.program_name)
+#include "common.h"
+
#define MKFS_PROGRAM_NAME "mkfs.ubifs"
enum { MKFS_PROGRAM_TYPE = 0 };
@@ -19,21 +26,9 @@ enum { MKFS_PROGRAM_TYPE = 0 };
extern int debug_level;
#define dbg_msg(lvl, fmt, ...) do {if (debug_level >= lvl) \
- printf("mkfs.ubifs: %s: " fmt "\n", __FUNCTION__, ##__VA_ARGS__); \
+ printf("%s: %s: " fmt "\n", PROGRAM_NAME, __FUNCTION__, ##__VA_ARGS__); \
} while(0)
-#define err_msg(fmt, ...) ({ \
- fprintf(stderr, "Error: " fmt "\n", ##__VA_ARGS__); \
- -1; \
-})
-
-#define sys_err_msg(fmt, ...) ({ \
- int err_ = errno; \
- fprintf(stderr, "Error: " fmt "\n", ##__VA_ARGS__); \
- fprintf(stderr, " %s (error %d)\n", strerror(err_), err_); \
- -1; \
-})
-
#define t16(x) ({ \
uint16_t __b = (x); \
(__LITTLE_ENDIAN==__BYTE_ORDER) ? __b : bswap_16(__b); \