[PATCH] Remove "-Wbad-function-cast"

Tomas Carnecky tom at dbservice.com
Wed Feb 4 13:39:36 PST 2009


It's the source of many useless warnings.

Signed-off-by: Tomas Carnecky <tom at dbservice.com>
---

It causes warnings for code like:
   int i = (int) dixLookupPrivate(...);
of which there is a lot in the xserver source. Fixing this
is not easy, as it requires to create a temporary variable
for the return value, and that is not easily possible
when such constructs are used in macros.

I also found this while googling around (originally posted
to comp.lang.c):
 ----8<----
gcc's documentation says:

`-Wbad-function-cast (C only)'
Warn whenever a function call is cast to a non-matching type. For
example, warn if `int malloc()' is cast to `anything *'.

This seems to be intended to catch the error of calling malloc()
without a prototype in scope, an error that gcc is quite capable of
catching directly (the usual message is "warning: implicit declaration
of function `malloc'"). I wouldn't use that option myself.
 ----8<----

We already warn about missing declaration (see in the patch below).

(Cc: author of the XORG_CWARNFLAGS macro, commit 4cce4c81)

 xorg-macros.m4.in |    3 +--
 1 files changed, 1 insertions(+), 2 deletions(-)

diff --git a/xorg-macros.m4.in b/xorg-macros.m4.in
index 9a2e26a..4a8dd2b 100644
--- a/xorg-macros.m4.in
+++ b/xorg-macros.m4.in
@@ -443,8 +443,7 @@ AC_DEFUN([XORG_CWARNFLAGS], [
 AC_REQUIRE([AC_PROG_CC])
 if  test "x$GCC" = xyes ; then
     CWARNFLAGS="-Wall -Wpointer-arith -Wstrict-prototypes -Wmissing-prototypes \
--Wmissing-declarations -Wnested-externs -fno-strict-aliasing \
--Wbad-function-cast"
+-Wmissing-declarations -Wnested-externs -fno-strict-aliasing"
     case `gcc -dumpversion` in
     4.*)
 	CWARNFLAGS+=" -Wold-style-definition -Wdeclaration-after-statement"
-- 
1.6.1.2





More information about the xorg mailing list