From 901a3ba023fd64e29309637f5ad835218e1bb2ac Mon Sep 17 00:00:00 2001 From: Carl-Daniel Hailfinger Date: Mon, 14 May 2012 22:54:58 +0000 Subject: Convert printf to msg_* where appropriate Clean up cli_output.c to be more readable. Use enum instead of #define for message levels. Kill a few exit(0) calls. Print the command line arguments in verbose mode. Move actions (--list-supported etc.) after argument sanity checks. Reduce the number of code paths which have their own programmer_shutdown(). Corresponding to flashrom svn r1536. Signed-off-by: Carl-Daniel Hailfinger Acked-by: Stefan Tauner --- flash.h | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) (limited to 'flash.h') diff --git a/flash.h b/flash.h index 0dac13d..0c14ce1 100644 --- a/flash.h +++ b/flash.h @@ -268,13 +268,15 @@ int write_buf_to_file(unsigned char *buf, unsigned long size, const char *filena #define ERROR_FLASHROM_LIMIT -201 /* cli_output.c */ +enum msglevel { + MSG_ERROR = 0, + MSG_INFO = 1, + MSG_DEBUG = 2, + MSG_DEBUG2 = 3, + MSG_SPEW = 4, +}; /* Let gcc and clang check for correct printf-style format strings. */ -int print(int type, const char *fmt, ...) __attribute__((format(printf, 2, 3))); -#define MSG_ERROR 0 -#define MSG_INFO 1 -#define MSG_DEBUG 2 -#define MSG_DEBUG2 3 -#define MSG_BARF 4 +int print(enum msglevel level, const char *fmt, ...) __attribute__((format(printf, 2, 3))); #define msg_gerr(...) print(MSG_ERROR, __VA_ARGS__) /* general errors */ #define msg_perr(...) print(MSG_ERROR, __VA_ARGS__) /* programmer errors */ #define msg_cerr(...) print(MSG_ERROR, __VA_ARGS__) /* chip errors */ @@ -287,9 +289,9 @@ int print(int type, const char *fmt, ...) __attribute__((format(printf, 2, 3))); #define msg_gdbg2(...) print(MSG_DEBUG2, __VA_ARGS__) /* general debug2 */ #define msg_pdbg2(...) print(MSG_DEBUG2, __VA_ARGS__) /* programmer debug2 */ #define msg_cdbg2(...) print(MSG_DEBUG2, __VA_ARGS__) /* chip debug2 */ -#define msg_gspew(...) print(MSG_BARF, __VA_ARGS__) /* general debug barf */ -#define msg_pspew(...) print(MSG_BARF, __VA_ARGS__) /* programmer debug barf */ -#define msg_cspew(...) print(MSG_BARF, __VA_ARGS__) /* chip debug barf */ +#define msg_gspew(...) print(MSG_SPEW, __VA_ARGS__) /* general debug spew */ +#define msg_pspew(...) print(MSG_SPEW, __VA_ARGS__) /* programmer debug spew */ +#define msg_cspew(...) print(MSG_SPEW, __VA_ARGS__) /* chip debug spew */ /* layout.c */ int register_include_arg(char *name); -- cgit v1.1