[PATCH] Remove "-Wbad-function-cast"
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):
> 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.
> 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], [
> if test "x$GCC" = xyes ; then
> CWARNFLAGS="-Wall -Wpointer-arith -Wstrict-prototypes -Wmissing-prototypes \
> --Wmissing-declarations -Wnested-externs -fno-strict-aliasing \
> +-Wmissing-declarations -Wnested-externs -fno-strict-aliasing"
> case `gcc -dumpversion` in
> CWARNFLAGS+=" -Wold-style-definition -Wdeclaration-after-statement"
> xorg mailing list
> xorg at lists.freedesktop.org
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Size: 197 bytes
Desc: not available
More information about the xorg