libc/stdio: Don't count the output length repeatly in vsprintf_internal

let's reuse the counting from lib_outstream_s::nput instead

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
This commit is contained in:
Xiang Xiao 2022-11-26 02:13:34 +08:00 committed by Petro Karashchenko
parent 33e35c6ce3
commit 7568a0df22

View File

@ -73,7 +73,7 @@
# undef putc
#endif
#define putc(c,stream) (total_len++, (stream)->put(stream, c))
#define putc(c,stream) (stream)->put(stream, c)
/* Order is relevant here and matches order in format string */
@ -201,9 +201,9 @@ static int vsprintf_internal(FAR struct lib_outstream_s *stream,
FAR const char *pnt;
size_t size;
unsigned char len;
int total_len = 0;
#ifdef CONFIG_LIBC_NUMBERED_ARGS
int total_len = 0;
int argnumber = 0;
#endif
@ -1357,7 +1357,11 @@ tail:
}
ret:
return total_len;
#ifdef CONFIG_LIBC_NUMBERED_ARGS
return stream ? stream->nput : total_len;
#else
return stream->nput;
#endif
}
/****************************************************************************