mirror of
https://github.com/projectacrn/acrn-hypervisor.git
synced 2026-06-08 10:04:42 +00:00
tools:acrn-crashlog: Enhance some functions
The changes include: 1. modify the outparam only in successful cases. 2. return -1 instead of a errno-style value if error happens. 3. check return value of strrchr. Tracked-On: #971 Signed-off-by: Liu, Xinwu <xinwu.liu@intel.com> Acked-by: Chen Gang <gang.c.chen@intel.com>
This commit is contained in:
@@ -17,9 +17,7 @@ void do_log(const int level,
|
||||
va_list args;
|
||||
char *fmt;
|
||||
char log[MAX_LOG_LEN];
|
||||
char *msg_log;
|
||||
int n = 0;
|
||||
int msg_len = 0;
|
||||
#ifdef DEBUG_ACRN_CRASHLOG
|
||||
const char header_fmt[] = "<%-20s%5d>: ";
|
||||
#endif
|
||||
@@ -42,10 +40,8 @@ void do_log(const int level,
|
||||
if (n < 0 || (size_t)n >= sizeof(log))
|
||||
n = 0;
|
||||
#endif
|
||||
msg_log = log + n;
|
||||
msg_len = sizeof(log) - n;
|
||||
/* msg */
|
||||
vsnprintf(msg_log, msg_len, fmt, args);
|
||||
vsnprintf(log + n, sizeof(log) - (size_t)n, fmt, args);
|
||||
log[sizeof(log) - 1] = 0;
|
||||
va_end(args);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user