From 80e5a33da1fcbe54cbcc178f1880e80e297d5fd4 Mon Sep 17 00:00:00 2001 From: Ard Biesheuvel Date: Tue, 19 Apr 2016 16:16:37 +0200 Subject: [PATCH] ArmPkg/ArmDmaLib: consistently use 'gCacheAlignment - 1' as alignment mask We manage to use both an AND operation with 'gCacheAlignment - 1' and a modulo operation with 'gCacheAlignment' in the same compound if statement. Since gCacheAlignment is a global of which the compiler cannot guarantee that it is a power of two, simply use the AND version in both cases. Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Ard Biesheuvel Reviewed-by: Leif Lindholm --- ArmPkg/Library/ArmDmaLib/ArmDmaLib.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ArmPkg/Library/ArmDmaLib/ArmDmaLib.c b/ArmPkg/Library/ArmDmaLib/ArmDmaLib.c index 1e6b288b10..66f3469eb1 100644 --- a/ArmPkg/Library/ArmDmaLib/ArmDmaLib.c +++ b/ArmPkg/Library/ArmDmaLib/ArmDmaLib.c @@ -93,7 +93,7 @@ DmaMap ( *Mapping = Map; if ((((UINTN)HostAddress & (gCacheAlignment - 1)) != 0) || - ((*NumberOfBytes % gCacheAlignment) != 0)) { + ((*NumberOfBytes & (gCacheAlignment - 1)) != 0)) { // Get the cacheability of the region Status = gDS->GetMemorySpaceDescriptor (*DeviceAddress, &GcdDescriptor);