stdio: warn on suspicious uses
authorEric Blake <ebb9@byu.net>
Thu, 31 Dec 2009 18:53:33 +0000 (11:53 -0700)
committerEric Blake <ebb9@byu.net>
Mon, 11 Jan 2010 13:51:00 +0000 (06:51 -0700)
commit524d6a2ef5cb6f367d4f14d5ab5a35df4c7fe08f
treeb90359d8c1adb6faf7b6ce96ee39ee3c2a2a23d8
parent039dc49e7e584131dc304bfb99b6e52812092827
stdio: warn on suspicious uses

Using gets is almost ALWAYS wrong (it is extremely rare that you have
full control over stdin).  POSIX 2008 marked it as obsolete, even
though C89 requires it.  Attach a warning to remind developers.  Add
a comment to sprintf explaining why it does not get this treatment.

Improve the warnings for fseek/fseeko (and ftell/ftello), with
comments justifying our position.

Some of our unit tests never use large files, so rather than drag
in a dependency on fseeko, they should be the first compilation
units to use _GL_NO_LARGE_FILES.

* modules/stdio (Depends-on): Add warn-on-use.
(Makefile.am): Provide new substitutions.
* m4/stdio_h.m4 (gl_STDIO_H): Check for inline, ftello, and
fseeko.
* lib/stdio.in.h (gets): Always warn on use.
(fseek, ftell): Adjust when warnings are issued, and honor
_GL_NO_LARGE_FILES as a way to silence the warning.
* tests/test-fpurge.c [!GNULIB_FSEEK]: Use new means to squelch
any warning about large file offsets.
* tests/test-freadable.c [!GNULIB_FSEEK]: Likewise.
* tests/test-freading.c [!GNULIB_FSEEK]: Likewise.
* tests/test-fseeko.c [!GNULIB_FSEEK]: Likewise.
* tests/test-ftell.c [!GNULIB_FSEEK]: Likewise.
* tests/test-ftello.c [!GNULIB_FSEEK]: Likewise.
* tests/test-fwritable.c [!GNULIB_FSEEK]: Likewise.
* tests/test-fwriting.c [!GNULIB_FSEEK]: Likewise.
* tests/test-getopt.c [!GNULIB_FTELL]: Likewise.

Signed-off-by: Eric Blake <ebb9@byu.net>
13 files changed:
ChangeLog
lib/stdio.in.h
m4/stdio_h.m4
modules/stdio
tests/test-fpurge.c
tests/test-freadable.c
tests/test-freading.c
tests/test-fseeko.c
tests/test-ftell.c
tests/test-ftello.c
tests/test-fwritable.c
tests/test-fwriting.c
tests/test-getopt.c