diff options
author | Jeff Johnston <jjohnstn@redhat.com> | 2005-02-08 01:33:19 +0000 |
---|---|---|
committer | Jeff Johnston <jjohnstn@redhat.com> | 2005-02-08 01:33:19 +0000 |
commit | 1159e0fd94bd0fffdd9cc64d0e7daa5fcf1ad52f (patch) | |
tree | 153d007292a6cf8d95c5c88b8d9dde8812e510c5 /newlib/libc/stdio | |
parent | 3d915670882af692d4a10e1f2559fb7e37194b6b (diff) | |
download | cygnal-1159e0fd94bd0fffdd9cc64d0e7daa5fcf1ad52f.tar.gz cygnal-1159e0fd94bd0fffdd9cc64d0e7daa5fcf1ad52f.tar.bz2 cygnal-1159e0fd94bd0fffdd9cc64d0e7daa5fcf1ad52f.zip |
2005-02-07 Antony King <antony.king@st.com>
* libc/stdio/clearerr.c (clearerr): Ensure CHECK_INIT() is
called before _flockfile to prevent lock object use before
initialisation. _REENT_SMALL_CHECK_INIT() and CHECK_INIT()
take a struct _reent * instead of a FILE *.
* libc/stdio/fclose.c (_fclose_r): Ditto.
* libc/stdio/feof.c (feof): Ditto.
* libc/stdio/ferror.c (ferror): Ditto.
* libc/stdio/fflush.c (fflush): Ditto.
* libc/stdio/fgetc.c (fgetc): Ditto.
* libc/stdio/fgets.c (fgets): Ditto.
* libc/stdio/fileno.c (fileno): Ditto.
* libc/stdio/fputc.c (fputc): Ditto.
* libc/stdio/fputs.c (fputs): Ditto.
* libc/stdio/fread.c (fread): Ditto.
* libc/stdio/freopen.c (_freopen_r): Ditto.
* libc/stdio/fseek.c (_fseek_r): Ditto.
* libc/stdio/ftell.c (_ftell_r): Ditto.
* libc/stdio/fwrite.c (fwrite): Ditto.
* libc/stdio/getc.c (getc): Ditto.
* libc/stdio/getdelim.c (__getdelim): Ditto.
* libc/stdio/putc.c (putc): Ditto.
* libc/stdio/setvbuf.c (setvbuf): Ditto.
* libc/stdio/ungetc.c (_ungetc_r): Ditto.
* libc/stdio/vfprintf.c (_VFPRINTF_R): Ditto.
* libc/stdio64/freopen64.c (_freopen64_r): Ditto.
* libc/stdio64/fseeko64.c (_fseeko64_r): Ditto.
* libc/stdio64/ftello64.c (_ftello64_r): Ditto.
* libc/stdio/local.h (CHECK_INIT): Argument is now a struct
_reent * instead of a FILE * and so replace incorrect use of
_REENT with argument.
* libc/sys/arm/syscalls.c (CHECK_INIT): Ditto.
* libc/stdio/getchar.c (getchar): _REENT_SMALL_CHECK_INIT() and
CHECK_INIT() take a struct _reent * instead of a FILE *.
* libc/stdio/iprintf.c (iprintf, _iprintf_r): Ditto.
* libc/stdio/iscanf.c (iscanf, _iscanf_r): Ditto.
* libc/stdio/perror.c (perror): Ditto.
* libc/stdio/printf.c (printf, _printf_r): Ditto.
* libc/stdio/putchar.c (putchar): Ditto.
* libc/stdio/puts.c (puts): Ditto.
* libc/stdio/refill.c (__srefill): Ditto.
* libc/stdio/scanf.c (scanf, _scanf_r): Ditto.
* libc/stdio/vfscanf.c (VFSCANF, _VFSCANF_R): Ditto.
* libc/stdio/viprintf.c (viprintf, _viprintf_r): Ditto.
* libc/stdio/viscanf.c (viscanf, _viscanf_r): Ditto.
* libc/stdio/vprintf.c (vprintf, _vprintf_r): Ditto.
* libc/stdio/vscanf.c (vscanf, _vscanf_r): Ditto.
* libc/stdio/wbuf.c (__swbuf): Ditto.
* libc/stdio/wsetup.c (__swsetup): Ditto.
* libc/stdlib/mallocr.c (malloc_stats): Ditto.
* libc/stdlib/mstats.c (_mstats_r): Ditto.
* libc/include/sys/reent.h (_REENT_SMALL_CHECK_INIT): Ditto.
* libc/machine/powerpc/vfscanf.c (vfscanf): Ditto.
* libc/stdio/fgetpos.c (_fgetpos_r): Removed unnecessary calls
to _flockfile and _funlockfile; rely on locking in _ftell_r.
* libc/stdio64/fgetpos64.c (_fgetpos64_r): Ditto (_ftello64_r).
* libc/machine/powerpc/vfprintf.c (__sbprintf): Removed unnecessary
initialision of _data field in FILE structure.
* libc/machine/powerpc/vfprintf.c (VFPRINTF): Added CHECK_INIT() call.
Diffstat (limited to 'newlib/libc/stdio')
39 files changed, 78 insertions, 53 deletions
diff --git a/newlib/libc/stdio/clearerr.c b/newlib/libc/stdio/clearerr.c index e242ff5e1..0923ff84d 100644 --- a/newlib/libc/stdio/clearerr.c +++ b/newlib/libc/stdio/clearerr.c @@ -54,12 +54,17 @@ No supporting OS subroutines are required. #include <_ansi.h> #include <stdio.h> +#include "local.h" + +/* A subroutine version of the macro clearerr. */ + #undef clearerr _VOID _DEFUN(clearerr, (fp), FILE * fp) { + CHECK_INIT(_REENT); _flockfile (fp); __sclearerr (fp); _funlockfile (fp); diff --git a/newlib/libc/stdio/fclose.c b/newlib/libc/stdio/fclose.c index f9fd17cb0..66d71c2d4 100644 --- a/newlib/libc/stdio/fclose.c +++ b/newlib/libc/stdio/fclose.c @@ -76,10 +76,10 @@ _DEFUN(_fclose_r, (rptr, fp), __sfp_lock_acquire (); + CHECK_INIT (rptr); + _flockfile (fp); - CHECK_INIT (fp); - if (fp->_flags == 0) /* not open! */ { _funlockfile (fp); diff --git a/newlib/libc/stdio/feof.c b/newlib/libc/stdio/feof.c index 5372f2f37..aff4e84c8 100644 --- a/newlib/libc/stdio/feof.c +++ b/newlib/libc/stdio/feof.c @@ -46,6 +46,9 @@ No supporting OS subroutines are required. */ #include <stdio.h> +#include "local.h" + +/* A subroutine version of the macro feof. */ #undef feof @@ -54,6 +57,7 @@ _DEFUN(feof, (fp), FILE * fp) { int result; + CHECK_INIT(_REENT); _flockfile (fp); result = __sfeof (fp); _funlockfile (fp); diff --git a/newlib/libc/stdio/ferror.c b/newlib/libc/stdio/ferror.c index 6f665d4c8..ea701bec7 100644 --- a/newlib/libc/stdio/ferror.c +++ b/newlib/libc/stdio/ferror.c @@ -55,6 +55,7 @@ static char sccsid[] = "%W% (Berkeley) %G%"; #include <_ansi.h> #include <stdio.h> +#include "local.h" /* A subroutine version of the macro ferror. */ @@ -65,6 +66,7 @@ _DEFUN(ferror, (fp), FILE * fp) { int result; + CHECK_INIT(_REENT); _flockfile (fp); result = __sferror (fp); _funlockfile (fp); diff --git a/newlib/libc/stdio/fflush.c b/newlib/libc/stdio/fflush.c index 0b157d0ce..b417e5424 100644 --- a/newlib/libc/stdio/fflush.c +++ b/newlib/libc/stdio/fflush.c @@ -67,9 +67,9 @@ _DEFUN(fflush, (fp), if (fp == NULL) return _fwalk (_GLOBAL_REENT, fflush); - _flockfile (fp); + CHECK_INIT (_REENT); - CHECK_INIT (fp); + _flockfile (fp); t = fp->_flags; if ((t & __SWR) == 0 || (p = fp->_bf._base) == NULL) diff --git a/newlib/libc/stdio/fgetc.c b/newlib/libc/stdio/fgetc.c index 5d5ad9a00..020b2da3a 100644 --- a/newlib/libc/stdio/fgetc.c +++ b/newlib/libc/stdio/fgetc.c @@ -55,12 +55,14 @@ Supporting OS subroutines required: <<close>>, <<fstat>>, <<isatty>>, #include <_ansi.h> #include <stdio.h> +#include "local.h" int _DEFUN(fgetc, (fp), FILE * fp) { int result; + CHECK_INIT(_REENT); _flockfile (fp); result = __sgetc (fp); _funlockfile (fp); diff --git a/newlib/libc/stdio/fgetpos.c b/newlib/libc/stdio/fgetpos.c index a89d88f03..21a63789d 100644 --- a/newlib/libc/stdio/fgetpos.c +++ b/newlib/libc/stdio/fgetpos.c @@ -81,15 +81,12 @@ _DEFUN(_fgetpos_r, (ptr, fp, pos), FILE * fp _AND _fpos_t * pos) { - _flockfile (fp); *pos = _ftell_r (ptr, fp); if (*pos != -1) { - _funlockfile (fp); return 0; } - _funlockfile (fp); return 1; } diff --git a/newlib/libc/stdio/fgets.c b/newlib/libc/stdio/fgets.c index 8c5147ac9..f5dde4903 100644 --- a/newlib/libc/stdio/fgets.c +++ b/newlib/libc/stdio/fgets.c @@ -80,6 +80,8 @@ _DEFUN(fgets, (buf, n, fp), s = buf; + CHECK_INIT(_REENT); + _flockfile (fp); #ifdef __SCLE if (fp->_flags & __SCLE) diff --git a/newlib/libc/stdio/fileno.c b/newlib/libc/stdio/fileno.c index 57d091274..b202cc5e3 100644 --- a/newlib/libc/stdio/fileno.c +++ b/newlib/libc/stdio/fileno.c @@ -54,8 +54,8 @@ _DEFUN(fileno, (f), FILE * f) { int result; + CHECK_INIT (_REENT); _flockfile (f); - CHECK_INIT (f); result = __sfileno (f); _funlockfile (f); return result; diff --git a/newlib/libc/stdio/fputc.c b/newlib/libc/stdio/fputc.c index 026ccfb83..422f6753a 100644 --- a/newlib/libc/stdio/fputc.c +++ b/newlib/libc/stdio/fputc.c @@ -59,6 +59,7 @@ Supporting OS subroutines required: <<close>>, <<fstat>>, <<isatty>>, #include <_ansi.h> #include <stdio.h> +#include "local.h" int _DEFUN(fputc, (ch, file), @@ -66,6 +67,7 @@ _DEFUN(fputc, (ch, file), FILE * file) { int result; + CHECK_INIT(_REENT); _flockfile (file); result = putc (ch, file); _funlockfile (file); diff --git a/newlib/libc/stdio/fputs.c b/newlib/libc/stdio/fputs.c index 8d605c0df..8d02107df 100644 --- a/newlib/libc/stdio/fputs.c +++ b/newlib/libc/stdio/fputs.c @@ -51,6 +51,7 @@ Supporting OS subroutines required: <<close>>, <<fstat>>, <<isatty>>, #include <stdio.h> #include <string.h> #include "fvwrite.h" +#include "local.h" /* * Write the given string to the given file. @@ -69,6 +70,9 @@ _DEFUN(fputs, (s, fp), iov.iov_len = uio.uio_resid = strlen (s); uio.uio_iov = &iov; uio.uio_iovcnt = 1; + + CHECK_INIT(_REENT); + _flockfile (fp); result = __sfvwrite (fp, &uio); _funlockfile (fp); diff --git a/newlib/libc/stdio/fread.c b/newlib/libc/stdio/fread.c index a90c50bf4..1354c04ba 100644 --- a/newlib/libc/stdio/fread.c +++ b/newlib/libc/stdio/fread.c @@ -125,6 +125,8 @@ _DEFUN(fread, (buf, size, count, fp), if ((resid = count * size) == 0) return 0; + CHECK_INIT(_REENT); + _flockfile (fp); if (fp->_r < 0) fp->_r = 0; diff --git a/newlib/libc/stdio/freopen.c b/newlib/libc/stdio/freopen.c index d4a65e77b..995100b27 100644 --- a/newlib/libc/stdio/freopen.c +++ b/newlib/libc/stdio/freopen.c @@ -91,9 +91,9 @@ _DEFUN(_freopen_r, (ptr, file, mode, fp), __sfp_lock_acquire (); - _flockfile (fp); + CHECK_INIT (ptr); - CHECK_INIT (fp); + _flockfile (fp); if ((flags = __sflags (ptr, mode, &oflags)) == 0) { diff --git a/newlib/libc/stdio/fseek.c b/newlib/libc/stdio/fseek.c index b3df7f04e..2ad98551c 100644 --- a/newlib/libc/stdio/fseek.c +++ b/newlib/libc/stdio/fseek.c @@ -129,11 +129,11 @@ _DEFUN(_fseek_r, (ptr, fp, offset, whence), struct stat st; int havepos; - _flockfile (fp); - /* Make sure stdio is set up. */ - CHECK_INIT (fp); + CHECK_INIT (ptr); + + _flockfile (fp); /* If we've been doing some writing, and we're in append mode then we don't really know where the filepos is. */ diff --git a/newlib/libc/stdio/ftell.c b/newlib/libc/stdio/ftell.c index b273c8bc9..74d6d906c 100644 --- a/newlib/libc/stdio/ftell.c +++ b/newlib/libc/stdio/ftell.c @@ -105,11 +105,11 @@ _DEFUN(_ftell_r, (ptr, fp), { _fpos_t pos; - _flockfile (fp); - /* Ensure stdio is set up. */ - CHECK_INIT (fp); + CHECK_INIT (ptr); + + _flockfile (fp); if (fp->_seek == NULL) { diff --git a/newlib/libc/stdio/fwrite.c b/newlib/libc/stdio/fwrite.c index 18514ec2e..663fff62c 100644 --- a/newlib/libc/stdio/fwrite.c +++ b/newlib/libc/stdio/fwrite.c @@ -99,6 +99,8 @@ _DEFUN(fwrite, (buf, size, count, fp), * generally slow and since this occurs whenever size==0. */ + CHECK_INIT(_REENT); + _flockfile (fp); if (__sfvwrite (fp, &uio) == 0) { diff --git a/newlib/libc/stdio/getc.c b/newlib/libc/stdio/getc.c index 0aa5ce313..9628a8740 100644 --- a/newlib/libc/stdio/getc.c +++ b/newlib/libc/stdio/getc.c @@ -64,6 +64,7 @@ static char sccsid[] = "%W% (Berkeley) %G%"; #include <_ansi.h> #include <stdio.h> +#include "local.h" /* * A subroutine version of the macro getc. @@ -76,8 +77,8 @@ _DEFUN(getc, (fp), register FILE *fp) { int result; + CHECK_INIT (_REENT); _flockfile (fp); - /* CHECK_INIT is called (eventually) by __srefill. */ result = __sgetc (fp); _funlockfile (fp); return result; diff --git a/newlib/libc/stdio/getchar.c b/newlib/libc/stdio/getchar.c index 8bb46ef57..19301c113 100644 --- a/newlib/libc/stdio/getchar.c +++ b/newlib/libc/stdio/getchar.c @@ -82,7 +82,7 @@ int _DEFUN(_getchar_r, (f), struct _reent *f) { - _REENT_SMALL_CHECK_INIT (_stdin_r (f)); + _REENT_SMALL_CHECK_INIT (f); return getc (_stdin_r (f)); } diff --git a/newlib/libc/stdio/getdelim.c b/newlib/libc/stdio/getdelim.c index 6c3e298d8..dad8feeb2 100644 --- a/newlib/libc/stdio/getdelim.c +++ b/newlib/libc/stdio/getdelim.c @@ -79,9 +79,9 @@ _DEFUN(__getdelim, (bufptr, n, delim, fp), *n = DEFAULT_LINE_SIZE; } - _flockfile (fp); + CHECK_INIT (_REENT); - CHECK_INIT (fp); + _flockfile (fp); numbytes = *n; ptr = buf; diff --git a/newlib/libc/stdio/iprintf.c b/newlib/libc/stdio/iprintf.c index 5dcf9a759..c9a026424 100644 --- a/newlib/libc/stdio/iprintf.c +++ b/newlib/libc/stdio/iprintf.c @@ -40,7 +40,7 @@ iprintf(fmt, va_alist) int ret; va_list ap; - _REENT_SMALL_CHECK_INIT (_stdout_r (_REENT)); + _REENT_SMALL_CHECK_INIT (_REENT); #ifdef _HAVE_STDC va_start (ap, fmt); #else @@ -67,7 +67,7 @@ _iprintf_r(ptr, fmt, va_alist) int ret; va_list ap; - _REENT_SMALL_CHECK_INIT (_stdout_r (ptr)); + _REENT_SMALL_CHECK_INIT (ptr); #ifdef _HAVE_STDC va_start (ap, fmt); #else diff --git a/newlib/libc/stdio/iscanf.c b/newlib/libc/stdio/iscanf.c index 2c50efaba..f35acd2ed 100644 --- a/newlib/libc/stdio/iscanf.c +++ b/newlib/libc/stdio/iscanf.c @@ -39,7 +39,7 @@ iscanf(fmt, va_alist) int ret; va_list ap; - _REENT_SMALL_CHECK_INIT (_stdin_r (_REENT)); + _REENT_SMALL_CHECK_INIT (_REENT); #ifdef _HAVE_STDC va_start (ap, fmt); #else @@ -65,7 +65,7 @@ _iscanf_r(ptr, fmt, va_alist) int ret; va_list ap; - _REENT_SMALL_CHECK_INIT (_stdin_r (ptr)); + _REENT_SMALL_CHECK_INIT (ptr); #ifdef _HAVE_STDC va_start (ap, fmt); #else diff --git a/newlib/libc/stdio/local.h b/newlib/libc/stdio/local.h index 1e132a5d5..f7093b697 100644 --- a/newlib/libc/stdio/local.h +++ b/newlib/libc/stdio/local.h @@ -49,11 +49,11 @@ extern int _EXFUN(__srefill,(FILE *fp)); /* Called by the main entry point fns to ensure stdio has been initialized. */ -#define CHECK_INIT(fp) \ +#define CHECK_INIT(ptr) \ do \ { \ - if (_REENT && !_REENT->__sdidinit) \ - __sinit (_REENT); \ + if ((ptr) && !(ptr)->__sdidinit) \ + __sinit (ptr); \ } \ while (0) diff --git a/newlib/libc/stdio/perror.c b/newlib/libc/stdio/perror.c index 6ee698705..5dbf3326c 100644 --- a/newlib/libc/stdio/perror.c +++ b/newlib/libc/stdio/perror.c @@ -74,7 +74,7 @@ _DEFUN(_perror_r, (ptr, s), { char *error; - _REENT_SMALL_CHECK_INIT (_stderr_r (ptr)); + _REENT_SMALL_CHECK_INIT (ptr); if (s != NULL && *s != '\0') { fputs (s, _stderr_r (ptr)); diff --git a/newlib/libc/stdio/printf.c b/newlib/libc/stdio/printf.c index 2512afe04..19f465e34 100644 --- a/newlib/libc/stdio/printf.c +++ b/newlib/libc/stdio/printf.c @@ -39,7 +39,7 @@ _printf_r(ptr, fmt, va_alist) int ret; va_list ap; - _REENT_SMALL_CHECK_INIT (_stdout_r (ptr)); + _REENT_SMALL_CHECK_INIT (ptr); #ifdef _HAVE_STDC va_start (ap, fmt); #else @@ -65,7 +65,7 @@ printf(fmt, va_alist) int ret; va_list ap; - _REENT_SMALL_CHECK_INIT (_stdout_r (_REENT)); + _REENT_SMALL_CHECK_INIT (_REENT); #ifdef _HAVE_STDC va_start (ap, fmt); #else diff --git a/newlib/libc/stdio/putc.c b/newlib/libc/stdio/putc.c index 509aaf48d..097323417 100644 --- a/newlib/libc/stdio/putc.c +++ b/newlib/libc/stdio/putc.c @@ -67,6 +67,7 @@ static char sccsid[] = "%W% (Berkeley) %G%"; #include <_ansi.h> #include <stdio.h> +#include "local.h" /* * A subroutine version of the macro putc. @@ -80,8 +81,8 @@ _DEFUN(putc, (c, fp), register FILE *fp) { int result; + CHECK_INIT (_REENT); _flockfile (fp); - /* CHECK_INIT is (eventually) called by __swbuf. */ result = __sputc (c, fp); _funlockfile (fp); return result; diff --git a/newlib/libc/stdio/putchar.c b/newlib/libc/stdio/putchar.c index 903de072d..e1d748ae2 100644 --- a/newlib/libc/stdio/putchar.c +++ b/newlib/libc/stdio/putchar.c @@ -80,7 +80,7 @@ _DEFUN(_putchar_r, (ptr, c), struct _reent *ptr _AND int c) { - _REENT_SMALL_CHECK_INIT (_stdout_r (ptr)); + _REENT_SMALL_CHECK_INIT (ptr); return putc (c, _stdout_r (ptr)); } diff --git a/newlib/libc/stdio/puts.c b/newlib/libc/stdio/puts.c index 68251ce67..bf32d0401 100644 --- a/newlib/libc/stdio/puts.c +++ b/newlib/libc/stdio/puts.c @@ -90,7 +90,7 @@ _DEFUN(_puts_r, (ptr, s), uio.uio_iov = &iov[0]; uio.uio_iovcnt = 2; - _REENT_SMALL_CHECK_INIT (_stdout_r (ptr)); + _REENT_SMALL_CHECK_INIT (ptr); return (__sfvwrite (_stdout_r (ptr), &uio) ? EOF : '\n'); } diff --git a/newlib/libc/stdio/refill.c b/newlib/libc/stdio/refill.c index 3f0b1a566..639ce6e24 100644 --- a/newlib/libc/stdio/refill.c +++ b/newlib/libc/stdio/refill.c @@ -41,7 +41,7 @@ _DEFUN(__srefill, (fp), { /* make sure stdio is set up */ - CHECK_INIT (fp); + CHECK_INIT (_REENT); fp->_r = 0; /* largely a convenience for callers */ diff --git a/newlib/libc/stdio/scanf.c b/newlib/libc/stdio/scanf.c index 733a638e6..cf1472ba7 100644 --- a/newlib/libc/stdio/scanf.c +++ b/newlib/libc/stdio/scanf.c @@ -39,7 +39,7 @@ scanf(fmt, va_alist) int ret; va_list ap; - _REENT_SMALL_CHECK_INIT (_stdin_r (_REENT)); + _REENT_SMALL_CHECK_INIT (_REENT); #ifdef _HAVE_STDC va_start (ap, fmt); #else @@ -65,7 +65,7 @@ _scanf_r(ptr, fmt, va_alist) int ret; va_list ap; - _REENT_SMALL_CHECK_INIT (_stdin_r (ptr)); + _REENT_SMALL_CHECK_INIT (ptr); #ifdef _HAVE_STDC va_start (ap, fmt); #else diff --git a/newlib/libc/stdio/setvbuf.c b/newlib/libc/stdio/setvbuf.c index eddfde8e3..f6871c59d 100644 --- a/newlib/libc/stdio/setvbuf.c +++ b/newlib/libc/stdio/setvbuf.c @@ -104,9 +104,9 @@ _DEFUN(setvbuf, (fp, buf, mode, size), { int ret = 0; - _flockfile (fp); + CHECK_INIT (_REENT); - CHECK_INIT (fp); + _flockfile (fp); /* * Verify arguments. The `int' limit on `size' is due to this diff --git a/newlib/libc/stdio/ungetc.c b/newlib/libc/stdio/ungetc.c index 9ccd02766..fc6fa3160 100644 --- a/newlib/libc/stdio/ungetc.c +++ b/newlib/libc/stdio/ungetc.c @@ -77,14 +77,14 @@ _DEFUN(_ungetc_r, (rptr, c, fp), if (c == EOF) return (EOF); - _flockfile (fp); - /* Ensure stdio has been initialized. ??? Might be able to remove this as some other stdio routine should have already been called to get the char we are un-getting. */ - CHECK_INIT (fp); + CHECK_INIT (rptr); + _flockfile (fp); + /* After ungetc, we won't be at eof anymore */ fp->_flags &= ~__SEOF; diff --git a/newlib/libc/stdio/vfprintf.c b/newlib/libc/stdio/vfprintf.c index 9e970cef3..70a765e80 100644 --- a/newlib/libc/stdio/vfprintf.c +++ b/newlib/libc/stdio/vfprintf.c @@ -533,8 +533,8 @@ _DEFUN(_VFPRINTF_R, (data, fp, fmt0, ap), (u_long)GET_ARG (N, ap, u_int)) #endif + CHECK_INIT (data); _flockfile (fp); - CHECK_INIT (fp); /* sorry, fprintf(read_only_file, "") returns EOF, not 0 */ if (cantwrite (fp)) { diff --git a/newlib/libc/stdio/vfscanf.c b/newlib/libc/stdio/vfscanf.c index 00dfb9523..621ea23aa 100644 --- a/newlib/libc/stdio/vfscanf.c +++ b/newlib/libc/stdio/vfscanf.c @@ -231,7 +231,7 @@ _DEFUN(VFSCANF, (fp, fmt, ap), _CONST char *fmt _AND va_list ap) { - CHECK_INIT(fp); + CHECK_INIT(_REENT); return __SVFSCANF_R (_REENT, fp, fmt, ap); } @@ -253,6 +253,7 @@ _DEFUN(_VFSCANF_R, (data, fp, fmt, ap), _CONST char *fmt _AND va_list ap) { + CHECK_INIT(data); return __SVFSCANF_R (data, fp, fmt, ap); } diff --git a/newlib/libc/stdio/viprintf.c b/newlib/libc/stdio/viprintf.c index 523292d39..e70fa13f1 100644 --- a/newlib/libc/stdio/viprintf.c +++ b/newlib/libc/stdio/viprintf.c @@ -145,7 +145,7 @@ _DEFUN(viprintf, (fmt, ap), _CONST char *fmt _AND va_list ap) { - _REENT_SMALL_CHECK_INIT (_stdout_r (_REENT)); + _REENT_SMALL_CHECK_INIT (_REENT); return _vfiprintf_r (_REENT, _stdout_r (_REENT), fmt, ap); } @@ -157,6 +157,6 @@ _DEFUN(_viprintf_r, (ptr, fmt, ap), _CONST char *fmt _AND va_list ap) { - _REENT_SMALL_CHECK_INIT (_stdout_r (ptr)); + _REENT_SMALL_CHECK_INIT (ptr); return _vfiprintf_r (ptr, _stdout_r (ptr), fmt, ap); } diff --git a/newlib/libc/stdio/viscanf.c b/newlib/libc/stdio/viscanf.c index 15388a404..e5287acac 100644 --- a/newlib/libc/stdio/viscanf.c +++ b/newlib/libc/stdio/viscanf.c @@ -121,7 +121,7 @@ _DEFUN(viscanf, (fmt, ap), _CONST char *fmt _AND va_list ap) { - _REENT_SMALL_CHECK_INIT (_stdin_r (_REENT)); + _REENT_SMALL_CHECK_INIT (_REENT); return __svfiscanf_r (_REENT, _stdin_r (_REENT), fmt, ap); } @@ -133,7 +133,7 @@ _DEFUN(_viscanf_r, (ptr, fmt, ap), _CONST char *fmt _AND va_list ap) { - _REENT_SMALL_CHECK_INIT (_stdin_r (ptr)); + _REENT_SMALL_CHECK_INIT (ptr); return __svfiscanf_r (ptr, _stdin_r (ptr), fmt, ap); } diff --git a/newlib/libc/stdio/vprintf.c b/newlib/libc/stdio/vprintf.c index 8a1faaed1..69edc87ae 100644 --- a/newlib/libc/stdio/vprintf.c +++ b/newlib/libc/stdio/vprintf.c @@ -33,7 +33,7 @@ _DEFUN(vprintf, (fmt, ap), _CONST char *fmt _AND va_list ap) { - _REENT_SMALL_CHECK_INIT (_stdout_r (_REENT)); + _REENT_SMALL_CHECK_INIT (_REENT); return _vfprintf_r (_REENT, _stdout_r (_REENT), fmt, ap); } @@ -45,6 +45,6 @@ _DEFUN(_vprintf_r, (ptr, fmt, ap), _CONST char *fmt _AND va_list ap) { - _REENT_SMALL_CHECK_INIT (_stdout_r (ptr)); + _REENT_SMALL_CHECK_INIT (ptr); return _vfprintf_r (ptr, _stdout_r (ptr), fmt, ap); } diff --git a/newlib/libc/stdio/vscanf.c b/newlib/libc/stdio/vscanf.c index a62b0a8c3..e559b77a8 100644 --- a/newlib/libc/stdio/vscanf.c +++ b/newlib/libc/stdio/vscanf.c @@ -34,7 +34,7 @@ _DEFUN(vscanf, (fmt, ap), _CONST char *fmt _AND va_list ap) { - _REENT_SMALL_CHECK_INIT (_stdin_r (_REENT)); + _REENT_SMALL_CHECK_INIT (_REENT); return __svfscanf_r (_REENT, _stdin_r (_REENT), fmt, ap); } @@ -46,7 +46,7 @@ _DEFUN(_vscanf_r, (ptr, fmt, ap), _CONST char *fmt _AND va_list ap) { - _REENT_SMALL_CHECK_INIT (_stdin_r (ptr)); + _REENT_SMALL_CHECK_INIT (ptr); return __svfscanf_r (ptr, _stdin_r (ptr), fmt, ap); } diff --git a/newlib/libc/stdio/wbuf.c b/newlib/libc/stdio/wbuf.c index 29dd03e37..e7ddb4913 100644 --- a/newlib/libc/stdio/wbuf.c +++ b/newlib/libc/stdio/wbuf.c @@ -40,7 +40,7 @@ _DEFUN(__swbuf, (c, fp), /* Ensure stdio has been initialized. */ - CHECK_INIT (fp); + CHECK_INIT (_REENT); /* * In case we cannot write, or longjmp takes us out early, diff --git a/newlib/libc/stdio/wsetup.c b/newlib/libc/stdio/wsetup.c index c1641dbe5..bc7299678 100644 --- a/newlib/libc/stdio/wsetup.c +++ b/newlib/libc/stdio/wsetup.c @@ -34,7 +34,7 @@ _DEFUN(__swsetup, (fp), { /* Make sure stdio is set up. */ - CHECK_INIT (fp); + CHECK_INIT (_REENT); /* * If we are not writing, we had better be reading and writing. |