This is the mail archive of the
libc-alpha@sourceware.org
mailing list for the glibc project.
Re: [PATCH] BZ #13979- A warning should be issued if FORTIFY_SOURCE is requested but not enabled
On Tuesday, May 08, 2012 01:27:37 Paul Eggert wrote:
> On 05/07/2012 02:35 PM, Roland McGrath wrote:
> > # warning _FORTIFY_SOURCE is only supported with GCC 4.1 or later
>
> Please change "is only supported with" to "requires"
> to fix a minor grammatical problem with "only".
>
> http://www.lousywriter.com/grammar_mistakes_only_usage.php
Thanks Roland and Paul.
Here's an updated patch, tested on x86-64.
Ok now?
Andreas
2012-05-08 Roland Mc Grath <roland@hack.frob.com>
[BZ #13979]
* include/features.h: Warn if user requests __FORTIFY_SOURCE
checking but the checks are disabled for any reason.
diff --git a/include/features.h b/include/features.h
index c347555..c700871 100644
--- a/include/features.h
+++ b/include/features.h
@@ -325,14 +325,18 @@
# define __USE_REENTRANT 1
#endif
-#if defined _FORTIFY_SOURCE && _FORTIFY_SOURCE > 0 \
- && __GNUC_PREREQ (4, 1) && defined __OPTIMIZE__ && __OPTIMIZE__ > 0
-# if _FORTIFY_SOURCE > 1
+#if defined _FORTIFY_SOURCE && _FORTIFY_SOURCE > 0
+# if !defined __OPTIMIZE__ || __OPTIMIZE__ <= 0
+# warning _FORTIFY_SOURCE requires compiling with optimization (-O)
+# elif !__GNUC_PREREQ (4, 1)
+# warning _FORTIFY_SOURCE requires GCC 4.1 or later
+# elif _FORTIFY_SOURCE > 1
# define __USE_FORTIFY_LEVEL 2
# else
# define __USE_FORTIFY_LEVEL 1
# endif
-#else
+#endif
+#ifndef __USE_FORTIFY_LEVEL
# define __USE_FORTIFY_LEVEL 0
#endif
--
Andreas Jaeger aj@{suse.com,opensuse.org} Twitter/Identica: jaegerandi
SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 NÃrnberg, Germany
GF: Jeff Hawn,Jennifer Guild,Felix ImendÃrffer,HRB16746 (AG NÃrnberg)
GPG fingerprint = 93A3 365E CE47 B889 DF7F FED1 389A 563C C272 A126