This is the mail archive of the
libc-alpha@sourceware.org
mailing list for the glibc project.
[PATCH] Don't always provide definition of gets
- From: Marek Polacek <polacek at redhat dot com>
- To: Ulrich Drepper <drepper at gmail dot com>
- Cc: libc-alpha <libc-alpha at sourceware dot org>
- Date: Thu, 12 Jan 2012 09:54:18 +0100
- Subject: [PATCH] Don't always provide definition of gets
In libio/stdio.h we guard the declaration of gets in a way that
gets isn't available under _GNU_SOURCE and ISOC11 or under C++11,
but the definition of gets in bits/stdio2.h, used when we want
fortification, is always available. This triggers quite a lot of
-Wmissing-prototypes-ish warnings. Thusly fixed.
2012-01-12 Marek Polacek <polacek@redhat.com>
* libio/bits/stdio2.h: Do not define gets for ISO C11, ISO C++11,
and _GNU_SOURCE.
--- libc/libio/bits/stdio2.h.mp 2012-01-11 19:42:58.292970262 +0100
+++ libc/libio/bits/stdio2.h 2012-01-11 19:59:41.776011728 +0100
@@ -217,6 +217,8 @@ __NTH (obstack_vprintf (struct obstack *
#endif
+#if !defined __USE_ISOC11 \
+ || (defined __cplusplus && __cplusplus <= 201103L && !defined __USE_GNU)
extern char *__gets_chk (char *__str, size_t) __wur;
extern char *__REDIRECT (__gets_warn, (char *__str), gets)
__wur __warnattr ("please use fgets or getline instead, gets can't "
@@ -229,6 +231,7 @@ gets (char *__str)
return __gets_chk (__str, __bos (__str));
return __gets_warn (__str);
}
+#endif
extern char *__fgets_chk (char *__restrict __s, size_t __size, int __n,
FILE *__restrict __stream) __wur;
Marek