libc/stdio: Add _s suffix for struct arg in lib_libvsprintf.c

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
This commit is contained in:
Xiang Xiao 2022-03-08 15:14:53 +08:00 committed by Alan Carvalho de Assis
parent bfedbf1c05
commit 0c01f0ce5a

View File

@ -124,7 +124,7 @@
* Private Types * Private Types
****************************************************************************/ ****************************************************************************/
struct arg struct arg_s
{ {
unsigned char type; unsigned char type;
union union
@ -150,7 +150,7 @@ static const char g_nullstring[] = "(null)";
****************************************************************************/ ****************************************************************************/
static int vsprintf_internal(FAR struct lib_outstream_s *stream, static int vsprintf_internal(FAR struct lib_outstream_s *stream,
FAR struct arg *arglist, int numargs, FAR struct arg_s *arglist, int numargs,
FAR const IPTR char *fmt, va_list ap); FAR const IPTR char *fmt, va_list ap);
/**************************************************************************** /****************************************************************************
@ -175,7 +175,7 @@ static int sprintf_internal(FAR struct lib_outstream_s *stream,
#endif #endif
static int vsprintf_internal(FAR struct lib_outstream_s *stream, static int vsprintf_internal(FAR struct lib_outstream_s *stream,
FAR struct arg *arglist, int numargs, FAR struct arg_s *arglist, int numargs,
FAR const IPTR char *fmt, va_list ap) FAR const IPTR char *fmt, va_list ap)
{ {
unsigned char c; /* Holds a char from the format string */ unsigned char c; /* Holds a char from the format string */
@ -203,9 +203,7 @@ static int vsprintf_internal(FAR struct lib_outstream_s *stream,
int total_len = 0; int total_len = 0;
#ifdef CONFIG_LIBC_NUMBERED_ARGS #ifdef CONFIG_LIBC_NUMBERED_ARGS
int argnumber; int argnumber;
#endif #endif
for (; ; ) for (; ; )
@ -297,8 +295,7 @@ static int vsprintf_internal(FAR struct lib_outstream_s *stream,
{ {
int index; int index;
flags &= ~FL_ASTERISK; flags &= ~FL_ASTERISK;
if ((flags & FL_PREC) == 0) if ((flags & FL_PREC) == 0)
{ {
index = width; index = width;
@ -559,7 +556,6 @@ static int vsprintf_internal(FAR struct lib_outstream_s *stream,
} }
#ifdef CONFIG_LIBC_NUMBERED_ARGS #ifdef CONFIG_LIBC_NUMBERED_ARGS
if ((flags & FL_ARGNUMBER) != 0) if ((flags & FL_ARGNUMBER) != 0)
{ {
if (argnumber > 0 && argnumber <= numargs) if (argnumber > 0 && argnumber <= numargs)
@ -612,7 +608,6 @@ static int vsprintf_internal(FAR struct lib_outstream_s *stream,
{ {
continue; /* We do only parsing */ continue; /* We do only parsing */
} }
#endif #endif
#ifdef CONFIG_LIBC_FLOATINGPOINT #ifdef CONFIG_LIBC_FLOATINGPOINT
@ -964,7 +959,7 @@ static int vsprintf_internal(FAR struct lib_outstream_s *stream,
#else #else
buf[0] = va_arg(ap, int); buf[0] = va_arg(ap, int);
#endif #endif
pnt = (FAR char *) buf; pnt = (FAR char *)buf;
size = 1; size = 1;
goto str_lpad; goto str_lpad;
@ -1319,7 +1314,6 @@ tail:
} }
ret: ret:
return total_len; return total_len;
} }
@ -1331,9 +1325,9 @@ int lib_vsprintf(FAR struct lib_outstream_s *stream,
FAR const IPTR char *fmt, va_list ap) FAR const IPTR char *fmt, va_list ap)
{ {
#ifdef CONFIG_LIBC_NUMBERED_ARGS #ifdef CONFIG_LIBC_NUMBERED_ARGS
int i; struct arg_s arglist[NL_ARGMAX];
struct arg arglist[NL_ARGMAX];
int numargs; int numargs;
int i;
/* We do 2 passes of parsing and fill the arglist between the passes. */ /* We do 2 passes of parsing and fill the arglist between the passes. */
@ -1348,6 +1342,7 @@ int lib_vsprintf(FAR struct lib_outstream_s *stream,
arglist[i].value.ull = va_arg(ap, unsigned long long); arglist[i].value.ull = va_arg(ap, unsigned long long);
break; break;
#endif #endif
case TYPE_LONG: case TYPE_LONG:
arglist[i].value.ul = va_arg(ap, unsigned long); arglist[i].value.ul = va_arg(ap, unsigned long);
break; break;
@ -1367,10 +1362,7 @@ int lib_vsprintf(FAR struct lib_outstream_s *stream,
} }
return vsprintf_internal(stream, arglist, numargs, fmt, ap); return vsprintf_internal(stream, arglist, numargs, fmt, ap);
#else #else
return vsprintf_internal(stream, NULL, 0, fmt, ap); return vsprintf_internal(stream, NULL, 0, fmt, ap);
#endif #endif
} }