Fix warning: type qualifiers ignored on function return
PATCH 1/1 Fix warning: type qualifiers ignored on function return
Per GCC manual: Constant functions that have no side effects need to use the attribute '__attribute__((__const__))' rather than '__const__'. Putting a '__const__' in the return type of a function is simply ignored and causes GCC4 to issue the warning: type qualifiers ignored on function return.
The header files compiler-gcc2.h, compiler-gcc3.h and compiler-gcc4.h all have the definition:
#define __attribute_const__ __attribute__((__const__))
'__attribute_const__' seems to be the preferred and correct syntax to declare a constant function.
include/linux/byteorder/swabb.h renamed from include/linux/byteorder/swabb.h~ +2 -2
@@ -92,7 +92,7 @@#endif /* OPTIMIZE */ -static __inline__ __const__ __u32 __fswahw32(__u32 x) +static __inline__ __attribute_const__ __u32 __fswahw32(__u32 x) {return __arch__swahw32 (x); }
@@ -106,7 +106,7 @@ static __inline__ void __swahw32s(__u32 } -static __inline__ __const__ __u32 __fswahb32(__u32 x) +static __inline__ __attribute_const__ __u32 __fswahb32(__u32 x) {return __arch__swahb32 (x); }
_______________________________________________
Kernel-janitors mailing list
[email protected]
http://lists.osdl.org/mailman/listinfo/kernel-janitors