This is the mail archive of the libc-alpha@sourceware.org mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH] Clean up conditionals for declaration of gets().


On 21 Nov 2016 12:44, Zack Weinberg wrote:
> gets() has the dubious honor of being the only C89 library feature
> that has been completely removed from the current C and C++ standards.
> glibc follows suit by not declaring it in _GNU_SOURCE mode either, but
> it remains present in older compatibility modes.  Internally, two test
> cases need to see stdio.h make the declaration, but all our internal
> code is of course compiled under _GNU_SOURCE.  This is currently
> kludged by duplicating the gets declaration, fortify wrapper and all,
> in include/stdio.h.  Also, the conditional in the public headers for
> deciding when to declare gets is complicated and repeated in two places.
> 
> This patch adds a new macro to features.h that encapsulates the
> complicated rule for when to declare gets.  stdio.h and bits/stdio2.h
> can simply test __GLIBC_USE (DEPRECATED_GETS).  Then, instead of
> having a duplicate gets declaration in include/stdio.h,
> debug/tst-chk1.c and stdio-common/tst-gets.c force that flag on.

for the tests, what if we forced an older standard ?  that'd provide
double test coverage by also making sure things build in that mode.

your patch appears to have been mangled in transit.  might want to
check that.

> --- a/debug/tst-chk1.c
> +++ b/debug/tst-chk1.c
> @@ -16,6 +16,11 @@
>     License along with the GNU C Library; if not, see
>     <http://www.gnu.org/licenses/>.  */
>  +/* This file tests gets().  Force it to be declared.  */

needs a newline above the comment

> --- a/include/features.h
> +++ b/include/features.h
> @@ -370,6 +370,15 @@
>  # define __USE_FORTIFY_LEVEL 0
>  #endif
>  +/* The function 'gets' existed in C89, but is impossible to use safely.
> +   It has been removed from ISO C11, ISO C++14, and _GNU_SOURCE.  */

needs a newline above the comment

> --- a/stdio-common/tst-gets.c
> +++ b/stdio-common/tst-gets.c
> @@ -17,10 +17,14 @@
>     License along with the GNU C Library; if not, see
>     <http://www.gnu.org/licenses/>.  */
>  +/* This file tests gets().  Force it to be declared.  */

here too
-mike

Attachment: signature.asc
Description: Digital signature


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]