From 88be24c279e29a363c2aabcb68b5f0a1e039f477 Mon Sep 17 00:00:00 2001 From: Douglas Bagnall Date: Wed, 23 Mar 2016 11:16:48 +1300 Subject: [PATCH] util/attr.h: use HAVE___ATTRIBUTE__, not __GNUC__ comparisons The comparisons that look like #if (__GNUC__ >= 3) && (__GNUC_MINOR__ >= 1 ) fail if __GNUC_MINOR__ is 0. The intended comparison is something more like #if __GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 1) However, given that: * these checks are really trying to test the presence of __attribute__, * there are now credible compilers that are not GCC, which have __attribute__ but might not be good at emulating __GNUC__ numbers, and * we really face little risk of running into GCC 2.95 * we have a HAVE___ATTRIBUTE__ check in ./configure let's not do the version comparisons. (Untested on GCC 2.95, GCC 3.0 and GCC 3.1). Signed-off-by: Douglas Bagnall Reviewed-by: Andrew Bartlett Reviewed-by: Uri Simchoni --- lib/util/attr.h | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/lib/util/attr.h b/lib/util/attr.h index b72696a8dc3..8e542c14da3 100644 --- a/lib/util/attr.h +++ b/lib/util/attr.h @@ -35,7 +35,7 @@ #endif #ifndef _DEPRECATED_ -#if (__GNUC__ >= 3) && (__GNUC_MINOR__ >= 1 ) +#ifdef HAVE___ATTRIBUTE__ #define _DEPRECATED_ __attribute__ ((deprecated)) #else #define _DEPRECATED_ @@ -43,7 +43,7 @@ #endif #ifndef _WARN_UNUSED_RESULT_ -#if (__GNUC__ >= 3) && (__GNUC_MINOR__ >= 1 ) +#ifdef HAVE___ATTRIBUTE__ #define _WARN_UNUSED_RESULT_ __attribute__ ((warn_unused_result)) #else #define _WARN_UNUSED_RESULT_ @@ -51,7 +51,7 @@ #endif #ifndef _NORETURN_ -#if (__GNUC__ >= 3) && (__GNUC_MINOR__ >= 1 ) +#ifdef HAVE___ATTRIBUTE__ #define _NORETURN_ __attribute__ ((noreturn)) #else #define _NORETURN_ @@ -59,7 +59,7 @@ #endif #ifndef _PURE_ -#if (__GNUC__ >= 3) && (__GNUC_MINOR__ >= 1) +#ifdef HAVE___ATTRIBUTE__ #define _PURE_ __attribute__((pure)) #else #define _PURE_ @@ -67,7 +67,7 @@ #endif #ifndef NONNULL -#if (__GNUC__ >= 3) && (__GNUC_MINOR__ >= 1) +#ifdef HAVE___ATTRIBUTE__ #define NONNULL(param) param __attribute__((nonnull)) #else #define NONNULL(param) param @@ -75,7 +75,7 @@ #endif #ifndef PRINTF_ATTRIBUTE -#if __GNUC__ >= 3 +#ifdef HAVE___ATTRIBUTE__ /** Use gcc attribute to check printf fns. a1 is the 1-based index of * the parameter containing the format, and a2 the index of the first * argument. Note that some gcc 2.x versions don't handle this @@ -87,11 +87,11 @@ #endif #ifndef FORMAT_ATTRIBUTE -#if __GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 1) +#ifdef HAVE___ATTRIBUTE__ /** Use gcc attribute to check printf fns. a1 is argument to format() * in the above macro. This is needed to support Heimdal's printf * decorations. Note that some gcc 2.x versions don't handle this - * properly, and as such I've used the same minimum from heimdal: GCC 3.1 **/ + * properly. **/ #define FORMAT_ATTRIBUTE(a) __attribute__ ((format a)) #else #define FORMAT_ATTRIBUTE(a) -- 2.34.1