[PATCH] Remove "-Wbad-function-cast"
Ian Romanick
idr at freedesktop.org
Wed Feb 4 14:12:20 PST 2009
On Wed, Feb 04, 2009 at 10:39:36PM +0100, Tomas Carnecky wrote:
> It's the source of many useless warnings.
If it's only reporting false-positives, then this seems sensible.
> 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
>
>
> _______________________________________________
> xorg mailing list
> xorg at lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/xorg
>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 197 bytes
Desc: not available
URL: <http://lists.x.org/archives/xorg/attachments/20090204/5eb92483/attachment.pgp>
More information about the xorg
mailing list