summaryrefslogtreecommitdiffstats
path: root/lib/libc/stdio/snprintf.c
diff options
context:
space:
mode:
authormillert <millert@openbsd.org>2005-05-28 00:54:50 +0000
committermillert <millert@openbsd.org>2005-05-28 00:54:50 +0000
commit03358690e98df88fec6f31dc84c5be8ac592a8c5 (patch)
treefb4ef34416b5890f6ac87cec61936bf07f879524 /lib/libc/stdio/snprintf.c
parentregression tests for pf checksum. (diff)
downloadwireguard-openbsd-03358690e98df88fec6f31dc84c5be8ac592a8c5.tar.xz
wireguard-openbsd-03358690e98df88fec6f31dc84c5be8ac592a8c5.zip
Move the va_start()/va_end() pair such that it directly backets the call
to vfprintf() like the rest of the *printf functions. This is clearer and makes the error case in asprintf() simpler. From Andrey Matveev.
Diffstat (limited to 'lib/libc/stdio/snprintf.c')
-rw-r--r--lib/libc/stdio/snprintf.c6
1 files changed, 3 insertions, 3 deletions
diff --git a/lib/libc/stdio/snprintf.c b/lib/libc/stdio/snprintf.c
index 653d0f01f08..7291c08aa66 100644
--- a/lib/libc/stdio/snprintf.c
+++ b/lib/libc/stdio/snprintf.c
@@ -31,7 +31,7 @@
*/
#if defined(LIBC_SCCS) && !defined(lint)
-static char rcsid[] = "$OpenBSD: snprintf.c,v 1.11 2005/04/30 09:25:17 espie Exp $";
+static char rcsid[] = "$OpenBSD: snprintf.c,v 1.12 2005/05/28 00:54:50 millert Exp $";
#endif /* LIBC_SCCS and not lint */
#include <limits.h>
@@ -56,14 +56,14 @@ snprintf(char *str, size_t n, const char *fmt, ...)
str = &dummy;
n = 1;
}
- va_start(ap, fmt);
_FILEEXT_SETUP(&f, &fext);
f._file = -1;
f._flags = __SWR | __SSTR;
f._bf._base = f._p = (unsigned char *)str;
f._bf._size = f._w = n - 1;
+ va_start(ap, fmt);
ret = vfprintf(&f, fmt, ap);
- *f._p = '\0';
va_end(ap);
+ *f._p = '\0';
return (ret);
}