Skip to contentSkip to conversation

bitops: Add missing parentheses to new get_order macro

PATCH In review Joerg Roedel 3 participants 4 messages Feb 24, 2012 – Mar 5, 2012 Generic include/asm header files

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 bitops: Add missing parentheses to new get_order macro

The new get_order macro introcuded in commit

	d66acc39c7cee323733c8503b9de1821a56dff7e

does not use parentheses around all uses of the parameter n. This causes new compile warnings, for example in the amd_iommu_init.c function:

drivers/iommu/amd_iommu_init.c:561:6: warning: suggest parentheses around comparison in operand of ‘&’ [-Wparentheses] drivers/iommu/amd_iommu_init.c:561:6: warning: suggest parentheses around comparison in operand of ‘&’ [-Wparentheses]

Fix those warnings by adding the missing parentheses.

Cc Ingo Molnar <[email protected]>
Cc David Howells <[email protected]>
Cc Arnd Bergmann <[email protected]>
Cc H. Peter Anvin <[email protected]>
---
 include/asm-generic/getorder.h |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)
include/asm-generic/getorder.h +2 -2
index e0fb4bf..65e4468 100644
@@ -49,8 +49,8 @@ int __get_order(unsigned long size)
 #define get_order(n)						\
 (								\
 	__builtin_constant_p(n) ? (				\
-		(n == 0UL) ? BITS_PER_LONG - PAGE_SHIFT :	\
-		((n < (1UL << PAGE_SHIFT)) ? 0 :		\
+		((n) == 0UL) ? BITS_PER_LONG - PAGE_SHIFT :	\
+		(((n) < (1UL << PAGE_SHIFT)) ? 0 :		\
 		 ilog2((n) - 1) - PAGE_SHIFT + 1)		\
 	) :							\
 	__get_order(n)						\
Signature · 1 line
1.7.5.4
maintainer Acked-by on v1 1/1
#1 lore raw
Quoted 9 lines · Joerg Roedel
        d66acc39c7cee323733c8503b9de1821a56dff7e

does not use parentheses around all uses of the parameter n. This causes new compile warnings, for example in the amd_iommu_init.c function:

drivers/iommu/amd_iommu_init.c:561:6: warning: suggest parentheses around comparison in operand of ‘&’ [-Wparentheses] drivers/iommu/amd_iommu_init.c:561:6: warning: suggest parentheses around comparison in operand of ‘&’ [-Wparentheses]

Quoted 8 lines

Fix those warnings by adding the missing parentheses.

Cc Ingo Molnar <[email protected]>
Cc David Howells <[email protected]>
Cc Arnd Bergmann <[email protected]>
Cc H. Peter Anvin <[email protected]>
#2 lore raw
In reply to Joerg Roedel
Commit-ID:  b893485db994b17402524d3d700b950294cb6c97
Gitweb:     http://git.kernel.org/tip/b893485db994b17402524d3d700b950294cb6c97
Author:     Joerg Roedel <[email protected]>
AuthorDate: Fri, 24 Feb 2012 13:58:15 +0100
Committer:  H. Peter Anvin <[email protected]>
CommitDate: Fri, 24 Feb 2012 10:39:27 -0800

bitops: Add missing parentheses to new get_order macro

The new get_order macro introcuded in commit

	d66acc39c7cee323733c8503b9de1821a56dff7e

does not use parentheses around all uses of the parameter n. This causes new compile warnings, for example in the amd_iommu_init.c function:

drivers/iommu/amd_iommu_init.c:561:6: warning: suggest parentheses around comparison in operand of ‘&’ [-Wparentheses] drivers/iommu/amd_iommu_init.c:561:6: warning: suggest parentheses around comparison in operand of ‘&’ [-Wparentheses]

Fix those warnings by adding the missing parentheses.

---
 include/asm-generic/getorder.h |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)
include/asm-generic/getorder.h +2 -2
index e0fb4bf..65e4468 100644
@@ -49,8 +49,8 @@ int __get_order(unsigned long size)
 #define get_order(n)						\
 (								\
 	__builtin_constant_p(n) ? (				\
-		(n == 0UL) ? BITS_PER_LONG - PAGE_SHIFT :	\
-		((n < (1UL << PAGE_SHIFT)) ? 0 :		\
+		((n) == 0UL) ? BITS_PER_LONG - PAGE_SHIFT :	\
+		(((n) < (1UL << PAGE_SHIFT)) ? 0 :		\
 		 ilog2((n) - 1) - PAGE_SHIFT + 1)		\
 	) :							\
 	__get_order(n)						\
Acked-by on v1 1/1
#3 lore raw
In reply to Joerg Roedel
Quoted 11 lines · Joerg Roedel

The new get_order macro introcuded in commit

	d66acc39c7cee323733c8503b9de1821a56dff7e

does not use parentheses around all uses of the parameter n. This causes new compile warnings, for example in the amd_iommu_init.c function:

drivers/iommu/amd_iommu_init.c:561:6: warning: suggest parentheses around comparison in operand of ‘&’ [-Wparentheses] drivers/iommu/amd_iommu_init.c:561:6: warning: suggest parentheses around comparison in operand of ‘&’ [-Wparentheses]

Quoted 7 lines

Fix those warnings by adding the missing parentheses.

Cc Ingo Molnar <[email protected]>
Cc Arnd Bergmann <[email protected]>
Cc H. Peter Anvin <[email protected]>