summary refs log tree commit diff
path: root/shared/nm-utils/nm-macros-internal.h
diff options
context:
space:
mode:
authorMichael Biebl <biebl@debian.org>2017-07-12 17:57:30 +0200
committerMichael Biebl <biebl@debian.org>2017-07-12 17:57:30 +0200
commitb9f0451fa35393ceedf6d9d20b78c43578ebea5d (patch)
tree417afcdd717020ad44e25fadee4b89de23316e83 /shared/nm-utils/nm-macros-internal.h
parentc333f062ddcba9b35330647bf6cbd0a07f2d786e (diff)
New upstream version 1.8.2 upstream/1.8.2
Diffstat (limited to 'shared/nm-utils/nm-macros-internal.h')
-rw-r--r--shared/nm-utils/nm-macros-internal.h13
1 files changed, 4 insertions, 9 deletions
diff --git a/shared/nm-utils/nm-macros-internal.h b/shared/nm-utils/nm-macros-internal.h
index 6ca66d29..5fe4bc50 100644
--- a/shared/nm-utils/nm-macros-internal.h
+++ b/shared/nm-utils/nm-macros-internal.h
@@ -609,18 +609,13 @@ nm_clear_g_cancellable (GCancellable **cancellable)
 /*****************************************************************************/
 
 /* Determine whether @x is a power of two (@x being an integer type).
- * For the special cases @x equals zero or one, it also returns true.
- * In case @x being a signed type, for negative @x always return FALSE. */
+ * Basically, this returns TRUE, if @x has exactly one bit set.
+ * For negative values and zero, this always returns FALSE. */
 #define nm_utils_is_power_of_two(x) ({ \
 		typeof(x) __x = (x); \
 		\
-		/* Check if the value is negative. In that case, return FALSE.
-		 * The first expression is a compile time constant, depending on whether
-		 * 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 & (__x - 1)) == 0); \
+		(    (__x > ((typeof(__x)) 0)) \
+		 && ((__x & (__x - (((typeof(__x)) 1)))) == ((typeof(__x)) 0))); \
 	})
 
 /*****************************************************************************/