diff options
author | Thomas Haller <thaller@redhat.com> | 2020-02-21 10:25:55 +0100 |
---|---|---|
committer | Thomas Haller <thaller@redhat.com> | 2020-02-21 10:43:55 +0100 |
commit | 4f9f228fed04a381f4af03212479df9399802b7e (patch) | |
tree | 9a8c01829d4df4beed7c6285d6520ba0e3ba1694 | |
parent | 16df1c179d6d3861042e182346b9ca6d75a64c51 (diff) |
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: 957bb2e11160 ('libnm: use binary search for _nm_setting_bond_option_supported() implementation')
-rw-r--r-- | m4/compiler_options.m4 | 1 | ||||
-rw-r--r-- | meson.build | 1 |
2 files changed, 2 insertions, 0 deletions
diff --git a/m4/compiler_options.m4 b/m4/compiler_options.m4 index 5235e037df..3ceccd983f 100644 --- a/m4/compiler_options.m4 +++ b/m4/compiler_options.m4 @@ -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 diff --git a/meson.build b/meson.build index 0d8a15bd57..a5ea1d10fd 100644 --- a/meson.build +++ b/meson.build @@ -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', |