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] BZ #13979- A warning should be issued if FORTIFY_SOURCEis requested but not enabled


> Here's what I'm testing now:
>
> #if defined _FORTIFY_SOURCE && _FORTIFY_SOURCE > 0 \
>      && __GNUC_PREREQ (4, 1) && defined __OPTIMIZE__ && __OPTIMIZE__ > 0
> # if _FORTIFY_SOURCE > 1
> #  define __USE_FORTIFY_LEVEL 2
> # else
> #  define __USE_FORTIFY_LEVEL 1
> # endif
> #else
> # define __USE_FORTIFY_LEVEL 0
> # 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
> # endif
> #endif

Seems cleaner to reorganize it to avoid the redundant tests:

#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 is only supported with GCC 4.1 or later
# elif _FORTIFY_SOURCE > 1
#  define __USE_FORTIFY_LEVEL 2
# else
#  define __USE_FORTIFY_LEVEL 1
# endif
#endif
#ifndef __USE_FORTIFY_LEVEL
# define __USE_FORTIFY_LEVEL 0
#endif


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