From 5e19b71eca9a9333c3de5434b832cde85b1d0f1a Mon Sep 17 00:00:00 2001 From: Meco Man <920369182@qq.com> Date: Tue, 16 Nov 2021 03:41:26 -0500 Subject: [PATCH] =?UTF-8?q?=E5=B0=86=E8=BF=94=E5=9B=9E=E5=80=BC=E7=B1=BB?= =?UTF-8?q?=E5=9E=8B=E7=94=B1signed=20int=E6=94=B9=E4=B8=BAint=EF=BC=8C?= =?UTF-8?q?=E7=AC=A6=E5=90=88ISO=20C=E6=A0=87=E5=87=86=EF=BC=8C=E9=98=B2?= =?UTF-8?q?=E6=AD=A2=E7=BC=96=E8=AF=91=E5=99=A8=E6=8A=A5=E9=94=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- include/rtthread.h | 10 +++++----- src/kservice.c | 12 +++++++----- 2 files changed, 12 insertions(+), 10 deletions(-) diff --git a/include/rtthread.h b/include/rtthread.h index 83be7d1ebc..8089ca07de 100644 --- a/include/rtthread.h +++ b/include/rtthread.h @@ -537,14 +537,14 @@ void rt_components_board_init(void); #define rt_kprintf(...) #define rt_kputs(str) #else -void rt_kprintf(const char *fmt, ...); +int rt_kprintf(const char *fmt, ...); void rt_kputs(const char *str); #endif -rt_int32_t rt_vsprintf(char *dest, const char *format, va_list arg_ptr); -rt_int32_t rt_vsnprintf(char *buf, rt_size_t size, const char *fmt, va_list args); -rt_int32_t rt_sprintf(char *buf, const char *format, ...); -rt_int32_t rt_snprintf(char *buf, rt_size_t size, const char *format, ...); +int rt_vsprintf(char *dest, const char *format, va_list arg_ptr); +int rt_vsnprintf(char *buf, rt_size_t size, const char *fmt, va_list args); +int rt_sprintf(char *buf, const char *format, ...); +int rt_snprintf(char *buf, rt_size_t size, const char *format, ...); #if defined(RT_USING_DEVICE) && defined(RT_USING_CONSOLE) rt_device_t rt_console_set_device(const char *name); diff --git a/src/kservice.c b/src/kservice.c index 525aacd7fd..6493c58b6a 100644 --- a/src/kservice.c +++ b/src/kservice.c @@ -844,7 +844,7 @@ static char *print_number(char *buf, * * @return The number of characters actually written to buffer. */ -RT_WEAK rt_int32_t rt_vsnprintf(char *buf, +RT_WEAK int rt_vsnprintf(char *buf, rt_size_t size, const char *fmt, va_list args) @@ -1121,7 +1121,7 @@ RTM_EXPORT(rt_vsnprintf); * * @return The number of characters actually written to buffer. */ -rt_int32_t rt_snprintf(char *buf, rt_size_t size, const char *fmt, ...) +int rt_snprintf(char *buf, rt_size_t size, const char *fmt, ...) { rt_int32_t n; va_list args; @@ -1145,7 +1145,7 @@ RTM_EXPORT(rt_snprintf); * * @return The number of characters actually written to buffer. */ -rt_int32_t rt_vsprintf(char *buf, const char *format, va_list arg_ptr) +int rt_vsprintf(char *buf, const char *format, va_list arg_ptr) { return rt_vsnprintf(buf, (rt_size_t) - 1, format, arg_ptr); } @@ -1160,7 +1160,7 @@ RTM_EXPORT(rt_vsprintf); * * @return The number of characters actually written to buffer. */ -rt_int32_t rt_sprintf(char *buf, const char *format, ...) +int rt_sprintf(char *buf, const char *format, ...) { rt_int32_t n; va_list arg_ptr; @@ -1261,7 +1261,7 @@ void rt_kputs(const char *str) * * @param fmt is the format parameters. */ -RT_WEAK void rt_kprintf(const char *fmt, ...) +RT_WEAK int rt_kprintf(const char *fmt, ...) { va_list args; rt_size_t length; @@ -1289,6 +1289,8 @@ RT_WEAK void rt_kprintf(const char *fmt, ...) rt_hw_console_output(rt_log_buf); #endif /* RT_USING_DEVICE */ va_end(args); + + return length; /* the total number of printed characters */ } RTM_EXPORT(rt_kprintf); #endif /* RT_USING_CONSOLE */