From 9fd215b0281c44300572e74cf6cf8eaeef1db9f3 Mon Sep 17 00:00:00 2001 From: Johny Mattsson Date: Wed, 27 Jan 2016 19:32:10 +1100 Subject: [PATCH] Corrected sprintf() prototype & behaviour. --- app/libc/c_stdio.c | 6 ++++-- app/libc/c_stdio.h | 2 +- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/app/libc/c_stdio.c b/app/libc/c_stdio.c index e52f2ffc..36aae1ce 100644 --- a/app/libc/c_stdio.c +++ b/app/libc/c_stdio.c @@ -1094,12 +1094,14 @@ exponent(char *p, int exp, int fmtch) #endif /* FLOATINGPT */ -void c_sprintf(char *s, char *fmt, ...) +int c_sprintf(char *s, const char *fmt, ...) { + int n; va_list arg; va_start(arg, fmt); - vsprintf(s, fmt, arg); + n = vsprintf(s, fmt, arg); va_end(arg); + return n; } #endif diff --git a/app/libc/c_stdio.h b/app/libc/c_stdio.h index c652f0bf..631f5c3a 100644 --- a/app/libc/c_stdio.h +++ b/app/libc/c_stdio.h @@ -60,7 +60,7 @@ extern void output_redirect(const char *str); #define c_sprintf os_sprintf #else #include "c_stdarg.h" -void c_sprintf(char* s,char *fmt, ...); +int c_sprintf(char* s,const char *fmt, ...); #endif // #define c_vsprintf ets_vsprintf