From 6e124e1581fc6af6499a27822fc8e4f4efc3bdee Mon Sep 17 00:00:00 2001 From: XuanZe <119524428@qq.com> Date: Sat, 2 Jun 2018 18:35:03 +0800 Subject: [PATCH 1/2] =?UTF-8?q?=E4=BF=AE=E5=BE=A9:=E5=86=85=E5=AD=98?= =?UTF-8?q?=E6=BA=A2=E5=87=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 此处的地址应该多-1,地址最大应该是 log_buf + ELOG_LINE_BUF_SIZE -1即&log_buf[ELOG_LINE_BUF_SIZE -1] --- easylogger/src/elog.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/easylogger/src/elog.c b/easylogger/src/elog.c index 8377d3d..5c8c012 100644 --- a/easylogger/src/elog.c +++ b/easylogger/src/elog.c @@ -404,7 +404,7 @@ void elog_output(uint8_t level, const char *tag, const char *file, const char *f if (level > elog.filter.level) { return; } else if (!strstr(tag, elog.filter.tag)) { /* tag filter */ - //TODO ԿDzKMPģʽƥַ + //TODO 可以考虑采用KMP及朴素模式匹配字符串,提升性能 return; } /* args point to the first variable parameter */ @@ -478,7 +478,7 @@ void elog_output(uint8_t level, const char *tag, const char *file, const char *f } /* package thread info */ if (get_fmt_enabled(level, ELOG_FMT_LINE)) { - //TODO snprintfԴռÿܽϸߣŻ + //TODO snprintf资源占用可能较高,待优化 snprintf(line_num, ELOG_LINE_NUM_MAX_LEN, "%ld", line); log_len += elog_strcpy(log_len, log_buf + log_len, line_num); } @@ -498,7 +498,7 @@ void elog_output(uint8_t level, const char *tag, const char *file, const char *f /* keyword filter */ if (!strstr(log_buf, elog.filter.keyword)) { - //TODO ԿDzKMPģʽƥַ + //TODO 可以考虑采用KMP及朴素模式匹配字符串,提升性能 /* unlock output */ elog_output_unlock(); return; @@ -510,7 +510,7 @@ void elog_output(uint8_t level, const char *tag, const char *file, const char *f } else { log_len = ELOG_LINE_BUF_SIZE; /* copy newline sign */ - strcpy(log_buf + ELOG_LINE_BUF_SIZE - newline_len, ELOG_NEWLINE_SIGN); + strcpy(log_buf + ELOG_LINE_BUF_SIZE -1 - newline_len, ELOG_NEWLINE_SIGN); } /* output log */ #if defined(ELOG_ASYNC_OUTPUT_ENABLE) From a3b1015026557947b90d25acc086e5d5a4e9f0ce Mon Sep 17 00:00:00 2001 From: XuanZe <119524428@qq.com> Date: Mon, 4 Jun 2018 10:21:08 +0800 Subject: [PATCH 2/2] Update elog.c MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 修改代码 --- easylogger/src/elog.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/easylogger/src/elog.c b/easylogger/src/elog.c index 5c8c012..1436b0f 100644 --- a/easylogger/src/elog.c +++ b/easylogger/src/elog.c @@ -510,7 +510,7 @@ void elog_output(uint8_t level, const char *tag, const char *file, const char *f } else { log_len = ELOG_LINE_BUF_SIZE; /* copy newline sign */ - strcpy(log_buf + ELOG_LINE_BUF_SIZE -1 - newline_len, ELOG_NEWLINE_SIGN); + strcpy(log_buf + ELOG_LINE_BUF_SIZE - (newline_len + 1), ELOG_NEWLINE_SIGN); } /* output log */ #if defined(ELOG_ASYNC_OUTPUT_ENABLE)