[libvirt] [PATCH v2 15/42] m4: disable gcc8 -Wcast-function-type warnings from -Wextra

Daniel P. Berrangé posted 42 patches 7 years, 11 months ago
[libvirt] [PATCH v2 15/42] m4: disable gcc8 -Wcast-function-type warnings from -Wextra
Posted by Daniel P. Berrangé 7 years, 11 months ago
The -Wextra flag bundle gained a new warning -Wcast-function-type.
This complains if you cast between two function prototypes where
the number of parameters or their data types are not compatible.
Unfortunately we need such "bad" function casts for our event
callbacks. It is possible to silence the warning by first casting
to the generic "void (*)(void)" function prototype, but that is
rather ugly to add throughout libvirt code.

Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
---
 m4/virt-compile-warnings.m4 | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/m4/virt-compile-warnings.m4 b/m4/virt-compile-warnings.m4
index 918764d362..fc185aef38 100644
--- a/m4/virt-compile-warnings.m4
+++ b/m4/virt-compile-warnings.m4
@@ -175,6 +175,8 @@ AC_DEFUN([LIBVIRT_COMPILE_WARNINGS],[
     # with gl_MANYWARN_COMPLEMENT
     # So we have -W enabled, and then have to explicitly turn off...
     wantwarn="$wantwarn -Wno-sign-compare"
+    # We do "bad" function casts all the time for event callbacks
+    wantwarn="$wantwarn -Wno-cast-function-type"
 
     # GNULIB expects this to be part of -Wc++-compat, but we turn
     # that one off, so we need to manually enable this again
-- 
2.14.3

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH v2 15/42] m4: disable gcc8 -Wcast-function-type warnings from -Wextra
Posted by Daniel P. Berrangé 7 years, 11 months ago
On Thu, Feb 15, 2018 at 04:43:20PM +0000, Daniel P. Berrangé wrote:
> The -Wextra flag bundle gained a new warning -Wcast-function-type.
> This complains if you cast between two function prototypes where
> the number of parameters or their data types are not compatible.
> Unfortunately we need such "bad" function casts for our event
> callbacks. It is possible to silence the warning by first casting
> to the generic "void (*)(void)" function prototype, but that is
> rather ugly to add throughout libvirt code.
> 
> Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
> ---
>  m4/virt-compile-warnings.m4 | 2 ++
>  1 file changed, 2 insertions(+)
> 
> diff --git a/m4/virt-compile-warnings.m4 b/m4/virt-compile-warnings.m4
> index 918764d362..fc185aef38 100644
> --- a/m4/virt-compile-warnings.m4
> +++ b/m4/virt-compile-warnings.m4
> @@ -175,6 +175,8 @@ AC_DEFUN([LIBVIRT_COMPILE_WARNINGS],[
>      # with gl_MANYWARN_COMPLEMENT
>      # So we have -W enabled, and then have to explicitly turn off...
>      wantwarn="$wantwarn -Wno-sign-compare"
> +    # We do "bad" function casts all the time for event callbacks
> +    wantwarn="$wantwarn -Wno-cast-function-type"
>  
>      # GNULIB expects this to be part of -Wc++-compat, but we turn
>      # that one off, so we need to manually enable this again

FYI, I'm going to push just this patch as a build-fixer, since in retrospect
is it not really related to the rest of the changes in this huge series.

Regards,
Daniel
-- 
|: https://berrange.com      -o-    https://www.flickr.com/photos/dberrange :|
|: https://libvirt.org         -o-            https://fstop138.berrange.com :|
|: https://entangle-photo.org    -o-    https://www.instagram.com/dberrange :|

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list