libnm: disable "-Wtautological-constant-out-of-range-compare" warning with clang

Seen on Debian 9, clang-3.8 (1:3.8.1-24):

    ../libnm-core/nm-setting-bond.c:596:49: error: comparison of constant 32 with expression of type 'NMBondMode' is always true [-Werror,-Wtautological-constant-out-of-range-compare]
            nm_assert (_NM_INT_NOT_NEGATIVE (mode) && mode < 32);
                                                      ~~~~ ^ ~~

This warning is not useful. While it may be implementation defined how enum
values outside the defined ones are handled, we commonly rely on placing
special numeric values in enums (e.g. ((NMEnumType) -1)).

An enum is (with our compilers) just a glorified integer, and there is nothing
preventing it from being outside the enum values. The warning is not helpful
and outright wrong. Disable it.

See-also: https://bugs.llvm.org//show_bug.cgi?id=16154

Fixes: 957bb2e111 ('libnm: use binary search for _nm_setting_bond_option_supported() implementation')
This commit is contained in:
Thomas Haller 2020-02-21 10:25:55 +01:00
parent 16df1c179d
commit 4f9f228fed
2 changed files with 2 additions and 0 deletions

View file

@ -89,6 +89,7 @@ if test "$GCC" = "yes" -a "$set_more_warnings" != "no"; then
-Wno-missing-field-initializers \
-Wno-pragmas \
-Wno-sign-compare \
-Wno-tautological-constant-out-of-range-compare \
-Wno-unknown-pragmas \
-Wno-unused-parameter \
; do

View file

@ -199,6 +199,7 @@ if nm_debug
'-Wno-missing-field-initializers',
'-Wno-pragmas',
'-Wno-sign-compare',
'-Wno-tautological-constant-out-of-range-compare',
'-Wno-unknown-pragmas',
'-Wno-unused-parameter',
'-Wparentheses-equality',