[PATCH] BZ #13979- A warning should be issued if FORTIFY_SOURCE is requested but not enabled

Roland McGrath roland@hack.frob.com
Mon May 7 21:15:00 GMT 2012


> 	* include/features.h: Warn if user requests FORTIFY_SOURCE checking
> 	but the checks are disabled for any reason.

Use the correct name in the log: _FORTIFY_SOURCE.

> +#if defined _FORTIFY_SOURCE && _FORTIFY_SOURCE > 0 && __USE_FORTIFY_LEVEL == 0
> +# warning _FORTIFY_SOURCE requested but disabled
> +#endif

It's probably more helpful to say something specific:

# if !defined __OPTIMIZE__ || __OPTIMIZE__ <= 0
#  warning _FORTIFY_SOURCE requires compiling with optimization (-O)
# elif !__GNUC_PREREQ (4, 1)
#  warning _FORTIFY_SOURCE is only supported with GCC 4.1 or later
# else
#  warning _FORTIFY_SOURCE is not available for mysterious reasons
# endif

It also seems cleaner to move this into the #if nest that actually sets
__USE_FORTIFY_LEVEL, perhaps reorganizing that a little as needed.


Thanks,
Roland



More information about the Libc-alpha mailing list