Skip to contentSkip to conversation

iommu-common: Do not use 64 bit constant 0xffffffffffffffffl for computing align_mask

PATCH In review Sowmini Varadhan 2 participants 2 messages Jul 21, 2015 Library code

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 iommu-common: Do not use 64 bit constant 0xffffffffffffffffl for computing align_mask

Using a 64 bit constant generates "warning: integer constant is too large for 'long' type" on 32 bit platforms. Instead use ~0ul and BITS_PER_LONG.

Detected by Andrew Morton on ARMD.

---
v2: use BITS_PER_LONG and ulong as discussed on mailing list.

 lib/iommu-common.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
lib/iommu-common.c +1 -1
index df30632..ff19f66 100644
@@ -119,7 +119,7 @@ unsigned long iommu_tbl_range_alloc(struct device *dev,
 	unsigned long align_mask = 0;
 
 	if (align_order > 0)
-		align_mask = 0xffffffffffffffffl >> (64 - align_order);
+		align_mask = ~0ul >> (BITS_PER_LONG - align_order);
 
 	/* Sanity check */
 	if (unlikely(npages == 0)) {
Signature · 1 line
1.7.1
Reviewed-by on v2 1/1
#1 lore raw
Quoted 7 lines · Sowmini Varadhan

Using a 64 bit constant generates "warning: integer constant is too large for 'long' type" on 32 bit platforms. Instead use ~0ul and BITS_PER_LONG.

Detected by Andrew Morton on ARMD.

Looks ok afaics.

Quoted 22 lines

---
v2: use BITS_PER_LONG and ulong as discussed on mailing list.

 lib/iommu-common.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
lib/iommu-common.c +1 -1
index df30632..ff19f66 100644
@@ -119,7 +119,7 @@ unsigned long iommu_tbl_range_alloc(struct device *dev,
 	unsigned long align_mask = 0;
 
 	if (align_order > 0)
-		align_mask = 0xffffffffffffffffl >> (64 - align_order);
+		align_mask = ~0ul >> (BITS_PER_LONG - align_order);
 
 	/* Sanity check */
 	if (unlikely(npages == 0)) {
Signature · 1 line
1.7.1