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); \ })