mirror of
git://git.musl-libc.org/musl
synced 2025-04-11 03:31:50 +00:00
minor vfprintf and vfwprintf changes to please static code analyzers
add missing va_end and remove some unnecessary code.
This commit is contained in:
parent
b9cd1d4d50
commit
49b3a0d2ce
@ -530,7 +530,6 @@ static int printf_core(FILE *f, const char *fmt, va_list *ap, union arg *nl_arg,
|
|||||||
/* Check validity of argument type (nl/normal) */
|
/* Check validity of argument type (nl/normal) */
|
||||||
if (st==NOARG) {
|
if (st==NOARG) {
|
||||||
if (argpos>=0) return -1;
|
if (argpos>=0) return -1;
|
||||||
else if (!f) continue;
|
|
||||||
} else {
|
} else {
|
||||||
if (argpos>=0) nl_type[argpos]=st, arg=nl_arg[argpos];
|
if (argpos>=0) nl_type[argpos]=st, arg=nl_arg[argpos];
|
||||||
else if (f) pop_arg(&arg, st, ap);
|
else if (f) pop_arg(&arg, st, ap);
|
||||||
@ -660,8 +659,12 @@ int vfprintf(FILE *restrict f, const char *restrict fmt, va_list ap)
|
|||||||
unsigned char internal_buf[80], *saved_buf = 0;
|
unsigned char internal_buf[80], *saved_buf = 0;
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
|
/* the copy allows passing va_list* even if va_list is an array */
|
||||||
va_copy(ap2, ap);
|
va_copy(ap2, ap);
|
||||||
if (printf_core(0, fmt, &ap2, nl_arg, nl_type) < 0) return -1;
|
if (printf_core(0, fmt, &ap2, nl_arg, nl_type) < 0) {
|
||||||
|
va_end(ap2);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
FLOCK(f);
|
FLOCK(f);
|
||||||
if (!f->buf_size) {
|
if (!f->buf_size) {
|
||||||
|
@ -253,7 +253,6 @@ static int wprintf_core(FILE *f, const wchar_t *fmt, va_list *ap, union arg *nl_
|
|||||||
/* Check validity of argument type (nl/normal) */
|
/* Check validity of argument type (nl/normal) */
|
||||||
if (st==NOARG) {
|
if (st==NOARG) {
|
||||||
if (argpos>=0) return -1;
|
if (argpos>=0) return -1;
|
||||||
else if (!f) continue;
|
|
||||||
} else {
|
} else {
|
||||||
if (argpos>=0) nl_type[argpos]=st, arg=nl_arg[argpos];
|
if (argpos>=0) nl_type[argpos]=st, arg=nl_arg[argpos];
|
||||||
else if (f) pop_arg(&arg, st, ap);
|
else if (f) pop_arg(&arg, st, ap);
|
||||||
@ -287,8 +286,7 @@ static int wprintf_core(FILE *f, const wchar_t *fmt, va_list *ap, union arg *nl_
|
|||||||
case 'S':
|
case 'S':
|
||||||
a = arg.p;
|
a = arg.p;
|
||||||
z = wmemchr(a, 0, p);
|
z = wmemchr(a, 0, p);
|
||||||
if (!z) z=a+p;
|
if (z) p=z-a;
|
||||||
else p=z-a;
|
|
||||||
if (w<p) w=p;
|
if (w<p) w=p;
|
||||||
if (!(fl&LEFT_ADJ)) fprintf(f, "%.*s", w-p, "");
|
if (!(fl&LEFT_ADJ)) fprintf(f, "%.*s", w-p, "");
|
||||||
out(f, a, p);
|
out(f, a, p);
|
||||||
@ -349,8 +347,12 @@ int vfwprintf(FILE *restrict f, const wchar_t *restrict fmt, va_list ap)
|
|||||||
union arg nl_arg[NL_ARGMAX];
|
union arg nl_arg[NL_ARGMAX];
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
|
/* the copy allows passing va_list* even if va_list is an array */
|
||||||
va_copy(ap2, ap);
|
va_copy(ap2, ap);
|
||||||
if (wprintf_core(0, fmt, &ap2, nl_arg, nl_type) < 0) return -1;
|
if (wprintf_core(0, fmt, &ap2, nl_arg, nl_type) < 0) {
|
||||||
|
va_end(ap2);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
FLOCK(f);
|
FLOCK(f);
|
||||||
ret = wprintf_core(f, fmt, &ap2, nl_arg, nl_type);
|
ret = wprintf_core(f, fmt, &ap2, nl_arg, nl_type);
|
||||||
|
Loading…
Reference in New Issue
Block a user