summaryrefslogtreecommitdiffstats
path: root/lib/libc/stdio/snprintf.c
diff options
context:
space:
mode:
authorjhb <jhb@FreeBSD.org>2010-03-11 17:03:32 +0000
committerjhb <jhb@FreeBSD.org>2010-03-11 17:03:32 +0000
commit2684d78c89ad7cfd18346398691e6e03d263f6c6 (patch)
treee077a892f44aba8196f30652e58ab6d758a2af4a /lib/libc/stdio/snprintf.c
parent03101f1cf6eaf4791f0ae5844d6c40b9f282a3ef (diff)
downloadFreeBSD-src-2684d78c89ad7cfd18346398691e6e03d263f6c6.zip
FreeBSD-src-2684d78c89ad7cfd18346398691e6e03d263f6c6.tar.gz
- Use an initializer macro to initialize fields in 'fake' FILE objects used
by *sprintf(), etc. - Explicitly initialize _fl_mutex to PTHREAD_MUTEX_INITIALIZER for all FILE objects. This is currently a nop on FreeBSD, but is import for other platforms (or in the future) where PTHREAD_MUTEX_INITIALIZER is not simply zero. PR: threads/141198 Reported by: Jeremy Huddleston @ Apple MFC after: 2 weeks
Diffstat (limited to 'lib/libc/stdio/snprintf.c')
-rw-r--r--lib/libc/stdio/snprintf.c5
1 files changed, 1 insertions, 4 deletions
diff --git a/lib/libc/stdio/snprintf.c b/lib/libc/stdio/snprintf.c
index 0470a33..e6d7115 100644
--- a/lib/libc/stdio/snprintf.c
+++ b/lib/libc/stdio/snprintf.c
@@ -48,7 +48,7 @@ snprintf(char * __restrict str, size_t n, char const * __restrict fmt, ...)
size_t on;
int ret;
va_list ap;
- FILE f;
+ FILE f = FAKE_FILE;
on = n;
if (n != 0)
@@ -56,12 +56,9 @@ snprintf(char * __restrict str, size_t n, char const * __restrict fmt, ...)
if (n > INT_MAX)
n = INT_MAX;
va_start(ap, fmt);
- f._file = -1;
f._flags = __SWR | __SSTR;
f._bf._base = f._p = (unsigned char *)str;
f._bf._size = f._w = n;
- f._orientation = 0;
- memset(&f._mbstate, 0, sizeof(mbstate_t));
ret = __vfprintf(&f, fmt, ap);
if (on > 0)
*f._p = '\0';
OpenPOWER on IntegriCloud