From 86a10716cd20558c2dc5f906540f34c71847f42a Mon Sep 17 00:00:00 2001 From: "Man, Jianting (Meco)" <920369182@qq.com> Date: Sun, 6 Mar 2022 12:14:22 -0500 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96ULOG=5FOUTPUT=5FFLOAT?= =?UTF-8?q?=EF=BC=8C=E9=81=BF=E5=85=8D=E4=BD=BF=E7=94=A8=E5=86=85=E7=BD=AE?= =?UTF-8?q?libc=E7=9A=84vsnprintf=E5=87=BD=E6=95=B0=20(#5632)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- components/utilities/Kconfig | 1 + components/utilities/ulog/syslog/syslog.c | 9 --------- components/utilities/ulog/ulog.c | 16 +--------------- 3 files changed, 2 insertions(+), 24 deletions(-) diff --git a/components/utilities/Kconfig b/components/utilities/Kconfig index af0fe054ae..01fd1ea3ca 100644 --- a/components/utilities/Kconfig +++ b/components/utilities/Kconfig @@ -137,6 +137,7 @@ config RT_USING_ULOG config ULOG_OUTPUT_FLOAT bool "Enable float number support. It will using more thread stack." default n + select PKG_USING_RT_VSNPRINTF_FULL help The default formater is using rt_vsnprint and it not supported float number. When enable this option then it will enable libc. The formater will change to vsnprint on libc. diff --git a/components/utilities/ulog/syslog/syslog.c b/components/utilities/ulog/syslog/syslog.c index a081db6eb6..ea1d584e74 100644 --- a/components/utilities/ulog/syslog/syslog.c +++ b/components/utilities/ulog/syslog/syslog.c @@ -14,10 +14,6 @@ #include #include "syslog.h" -#ifdef ULOG_OUTPUT_FLOAT -#include -#endif - /* * reference: * http://pubs.opengroup.org/onlinepubs/7908799/xsh/syslog.h.html @@ -227,12 +223,7 @@ RT_WEAK rt_size_t syslog_formater(char *log_buf, int level, const char *tag, rt_ #endif /* ULOG_OUTPUT_THREAD_NAME */ log_len += ulog_strcpy(log_len, log_buf + log_len, ": "); - -#ifdef ULOG_OUTPUT_FLOAT - fmt_result = vsnprintf(log_buf + log_len, ULOG_LINE_BUF_SIZE - log_len, format, args); -#else fmt_result = rt_vsnprintf(log_buf + log_len, ULOG_LINE_BUF_SIZE - log_len, format, args); -#endif /* ULOG_OUTPUT_FLOAT */ /* calculate log length */ if ((log_len + fmt_result <= ULOG_LINE_BUF_SIZE) && (fmt_result > -1)) diff --git a/components/utilities/ulog/ulog.c b/components/utilities/ulog/ulog.c index ab22e516a5..cb5914e5d2 100644 --- a/components/utilities/ulog/ulog.c +++ b/components/utilities/ulog/ulog.c @@ -16,10 +16,6 @@ #include #endif -#ifdef ULOG_OUTPUT_FLOAT -#include -#endif - #ifdef ULOG_TIME_USING_TIMESTAMP #include #endif @@ -367,12 +363,7 @@ RT_WEAK rt_size_t ulog_formater(char *log_buf, rt_uint32_t level, const char *ta #endif /* ULOG_OUTPUT_THREAD_NAME */ log_len += ulog_strcpy(log_len, log_buf + log_len, ": "); - -#ifdef ULOG_OUTPUT_FLOAT - fmt_result = vsnprintf(log_buf + log_len, ULOG_LINE_BUF_SIZE - log_len, format, args); -#else fmt_result = rt_vsnprintf(log_buf + log_len, ULOG_LINE_BUF_SIZE - log_len, format, args); -#endif /* ULOG_OUTPUT_FLOAT */ /* calculate log length */ if ((log_len + fmt_result <= ULOG_LINE_BUF_SIZE) && (fmt_result > -1)) @@ -674,15 +665,10 @@ void ulog_raw(const char *format, ...) /* lock output */ output_lock(); + /* args point to the first variable parameter */ va_start(args, format); - -#ifdef ULOG_OUTPUT_FLOAT - fmt_result = vsnprintf(log_buf, ULOG_LINE_BUF_SIZE, format, args); -#else fmt_result = rt_vsnprintf(log_buf, ULOG_LINE_BUF_SIZE, format, args); -#endif /* ULOG_OUTPUT_FLOAT */ - va_end(args); /* calculate log length */