From 4f9f228fed04a381f4af03212479df9399802b7e Mon Sep 17 00:00:00 2001 From: Thomas Haller Date: Fri, 21 Feb 2020 10:25:55 +0100 Subject: [PATCH] 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') --- m4/compiler_options.m4 | 1 + meson.build | 1 + 2 files changed, 2 insertions(+) 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',