[virt-tools-list] [virt-viewer PATCH v2 3/3] Switch to gnulib's compiler warning flags

Christophe Fergeau cfergeau at redhat.com
Mon Mar 4 12:58:34 UTC 2019


On Tue, Feb 19, 2019 at 03:00:11PM +0000, Daniel P. Berrangé wrote:
> diff --git a/m4/virt-viewer-warnings.m4 b/m4/virt-viewer-warnings.m4
> new file mode 100644
> index 0000000..4036b75
> --- /dev/null
> +++ b/m4/virt-viewer-warnings.m4
> [...]
> +    # List of warnings that are not relevant / wanted
> +
> +    # Don't care about C++ compiler compat
> +    dontwarn="$dontwarn -Wc++-compat"
> +    dontwarn="$dontwarn -Wabi"
> +    dontwarn="$dontwarn -Wdeprecated"
> +    # Don't care about ancient C standard compat
> +    dontwarn="$dontwarn -Wtraditional"
> +    # Don't care about ancient C standard compat
> +    dontwarn="$dontwarn -Wtraditional-conversion"
> +    # Ignore warnings in /usr/include
> +    dontwarn="$dontwarn -Wsystem-headers"
> +    # Happy for compiler to add struct padding
> +    dontwarn="$dontwarn -Wpadded"
> +    # GCC very confused with -O2
> +    dontwarn="$dontwarn -Wunreachable-code"
> +    # Too many to deal with
> +    dontwarn="$dontwarn -Wconversion"
> +    # Too many to deal with
> +    dontwarn="$dontwarn -Wsign-conversion"
> +    # We need to use long long in many places
> +    dontwarn="$dontwarn -Wlong-long"
> +    # Not a problem since we don't use -fstrict-overflow
> +    dontwarn="$dontwarn -Wstrict-overflow"
> +    # Not a problem since we don't use -funsafe-loop-optimizations
> +    dontwarn="$dontwarn -Wunsafe-loop-optimizations"
> +    # gcc 4.4.6 complains this is C++ only; gcc 4.7.0 implies this from -Wall
> +    dontwarn="$dontwarn -Wenum-compare"
> +    # /usr/include/spice-1/spice/protocol.h triggers violations
> +    dontwarn="$dontwarn -Wpacked"
> +
> +    # g_clear_object & G_ATOMIC_OP_USE_GCC_BUILTINS causes
> +    # violations with this. XXX Fix glib ?
> +    dontwarn="$dontwarn -Wbad-function-cast"
> +
> +    # Due to gutils.h bug in g_bit_storage
> +    wantwarn="$wantwarn -Wno-sign-conversion"
> +    wantwarn="$wantwarn -Wno-conversion"
> +    # We can't enable this due to horrible spice_usb_device_get_description
> +    # signature
> +#    wantwarn="$wantwarn -Wno-format-nonliteral"

I'd remove this, spice_usb_device_get_description is not marked as using
a format string, and uncommenting this line/changing it to
-Wformat-nonliteral did not trigger any additional warnings.

> +
> +    # Get all possible GCC warnings
> +    gl_MANYWARN_ALL_GCC([maybewarn])
> +
> +    # Remove the ones we don't want, blacklisted earlier
> +    gl_MANYWARN_COMPLEMENT([wantwarn], [$maybewarn], [$dontwarn])
> +
> +    # GNULIB uses '-W' (aka -Wextra) which includes a bunch of stuff.
> +    # Unfortunately, this means you can't simply use '-Wsign-compare'
> +    # with gl_MANYWARN_COMPLEMENT
> +    # So we have -W enabled, and then have to explicitly turn off...
> +    wantwarn="$wantwarn -Wno-sign-compare"
> +
> +    # GNULIB expects this to be part of -Wc++-compat, but we turn
> +    # that one off, so we need to manually enable this again
> +    wantwarn="$wantwarn -Wjump-misses-init"
> +
> +    # We do "bad" function casts all the time for event callbacks
> +    wantwarn="$wantwarn -Wno-cast-function-type"
> +
> +    # GNULIB turns on -Wformat=2 which implies -Wformat-nonliteral,
> +    # so we need to manually re-exclude it.
> +    wantwarn="$wantwarn -Wno-format-nonliteral"

This on can be removed too if we enable -Wformat-nonliteral.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 833 bytes
Desc: not available
URL: <http://listman.redhat.com/archives/virt-tools-list/attachments/20190304/6f5ef787/attachment.sig>


More information about the virt-tools-list mailing list