Merge pull request #3287 from rgw5267/fix_ulog

ulogbuffer增加1,为\0预留空间
This commit is contained in:
Bernard Xiong 2019-12-24 11:17:41 +08:00 committed by GitHub
commit 20d1c13be6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 4 additions and 2 deletions

View File

@ -81,12 +81,12 @@ struct rt_ulog
/* all backends */ /* all backends */
rt_slist_t backend_list; rt_slist_t backend_list;
/* the thread log's line buffer */ /* the thread log's line buffer */
char log_buf_th[ULOG_LINE_BUF_SIZE]; char log_buf_th[ULOG_LINE_BUF_SIZE + 1];
#ifdef ULOG_USING_ISR_LOG #ifdef ULOG_USING_ISR_LOG
/* the ISR log's line buffer */ /* the ISR log's line buffer */
rt_base_t output_locker_isr_lvl; rt_base_t output_locker_isr_lvl;
char log_buf_isr[ULOG_LINE_BUF_SIZE]; char log_buf_isr[ULOG_LINE_BUF_SIZE + 1];
#endif /* ULOG_USING_ISR_LOG */ #endif /* ULOG_USING_ISR_LOG */
#ifdef ULOG_USING_ASYNC_OUTPUT #ifdef ULOG_USING_ASYNC_OUTPUT
@ -728,6 +728,8 @@ void ulog_hexdump(const char *tag, rt_size_t width, rt_uint8_t *buf, rt_size_t s
} }
/* package newline sign */ /* package newline sign */
log_len += ulog_strcpy(log_len, log_buf + log_len, ULOG_NEWLINE_SIGN); log_len += ulog_strcpy(log_len, log_buf + log_len, ULOG_NEWLINE_SIGN);
/*add string end sign*/
log_buf[log_len] = '\0';
/* do log output */ /* do log output */
do_output(LOG_LVL_DBG, NULL, RT_TRUE, log_buf, log_len); do_output(LOG_LVL_DBG, NULL, RT_TRUE, log_buf, log_len);
} }