From 7c2ecaa4e082674fb84d3188ffac9d6cee653b01 Mon Sep 17 00:00:00 2001 From: Francesco Giudici Date: Mon, 22 May 2017 11:57:50 +0200 Subject: [PATCH] build: work around GCC -Wlogical-op for "nm_utils_is_power_of_two" macros We recently added -Wlogical-op in our build process (commit #41e7fca59762dc928c9d67b555b1409c3477b2b0). Seems that old versions of gcc (4.8.x) will hit that warning with our implementation of our "nm_utils_is_power_of_two" and "test_nm_utils_is_power_of_two_do" macros. Fool it just adding an always TRUE check. --- libnm-core/tests/test-general.c | 4 ++-- shared/nm-utils/nm-macros-internal.h | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/libnm-core/tests/test-general.c b/libnm-core/tests/test-general.c index 7ec63f9a80..0bb3a4cc11 100644 --- a/libnm-core/tests/test-general.c +++ b/libnm-core/tests/test-general.c @@ -4942,10 +4942,10 @@ enum TEST_IS_POWER_OF_TWP_ENUM_UNSIGNED_64 { typeof (x) x1 = (x); \ type x2 = (type) x1; \ \ - if (((typeof (x1)) x2) == x1 && (x2 > 0 || x2 == 0)) { \ + if (((typeof (x1)) x2) == x1 && (x2 > 0 || (x2 == 0 && 1))) { \ /* x2 equals @x, and is positive. Compare to @expect */ \ g_assert_cmpint (expect, ==, nm_utils_is_power_of_two (x2)); \ - } else if (!(x2 > 0) && !(x2 == 0)) { \ + } else if (!(x2 > 0) && (!(x2 == 0) && 1)) { \ /* a (signed) negative value is always FALSE. */ \ g_assert_cmpint (FALSE, ==, nm_utils_is_power_of_two (x2));\ } \ diff --git a/shared/nm-utils/nm-macros-internal.h b/shared/nm-utils/nm-macros-internal.h index cde257e404..d51a23b1bd 100644 --- a/shared/nm-utils/nm-macros-internal.h +++ b/shared/nm-utils/nm-macros-internal.h @@ -644,7 +644,7 @@ nm_clear_g_cancellable (GCancellable **cancellable) * the type is signed. The second expression is a clumsy way for (__x >= 0), * which otherwise causes a compiler warning for unsigned types. */ \ ( (((typeof(__x)) -1) > ((typeof(__x)) 0)) \ - || (__x > 0 || __x == 0) ) \ + || (__x > 0 || (__x == 0 && 1)) ) \ && ((__x & (__x - 1)) == 0); \ })