diff options
author | Szabolcs Nagy <nsz@port70.net> | 2013-10-07 13:22:24 +0000 |
---|---|---|
committer | Szabolcs Nagy <nsz@port70.net> | 2013-10-07 13:22:24 +0000 |
commit | 49b3a0d2cedd3693d77924fdc0a7719a75bd28da (patch) | |
tree | 684fee09f08b8b13004e2bebd5e32b11af8a001f /src/stdio/vfwprintf.c | |
parent | b9cd1d4d5073eba4c3afbe7666fc2d9c77b42c7c (diff) | |
download | musl-49b3a0d2cedd3693d77924fdc0a7719a75bd28da.tar.gz musl-49b3a0d2cedd3693d77924fdc0a7719a75bd28da.tar.xz musl-49b3a0d2cedd3693d77924fdc0a7719a75bd28da.zip |
minor vfprintf and vfwprintf changes to please static code analyzers
add missing va_end and remove some unnecessary code.
Diffstat (limited to 'src/stdio/vfwprintf.c')
-rw-r--r-- | src/stdio/vfwprintf.c | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/src/stdio/vfwprintf.c b/src/stdio/vfwprintf.c index 3557678f..984ff7b7 100644 --- a/src/stdio/vfwprintf.c +++ b/src/stdio/vfwprintf.c @@ -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) */ if (st==NOARG) { if (argpos>=0) return -1; - else if (!f) continue; } else { if (argpos>=0) nl_type[argpos]=st, arg=nl_arg[argpos]; 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': a = arg.p; z = wmemchr(a, 0, p); - if (!z) z=a+p; - else p=z-a; + if (z) p=z-a; if (w<p) w=p; if (!(fl&LEFT_ADJ)) fprintf(f, "%.*s", w-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]; int ret; + /* the copy allows passing va_list* even if va_list is an array */ 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); ret = wprintf_core(f, fmt, &ap2, nl_arg, nl_type); |