From 49b3a0d2cedd3693d77924fdc0a7719a75bd28da Mon Sep 17 00:00:00 2001 From: Szabolcs Nagy Date: Mon, 7 Oct 2013 13:22:24 +0000 Subject: minor vfprintf and vfwprintf changes to please static code analyzers add missing va_end and remove some unnecessary code. --- src/stdio/vfprintf.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'src/stdio/vfprintf.c') diff --git a/src/stdio/vfprintf.c b/src/stdio/vfprintf.c index a2b287bd..b5948bd2 100644 --- a/src/stdio/vfprintf.c +++ b/src/stdio/vfprintf.c @@ -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) */ 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); @@ -660,8 +659,12 @@ int vfprintf(FILE *restrict f, const char *restrict fmt, va_list ap) unsigned char internal_buf[80], *saved_buf = 0; int ret; + /* the copy allows passing va_list* even if va_list is an array */ 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); if (!f->buf_size) { -- cgit v1.2.1