]> git.proxmox.com Git - mirror_edk2.git/commitdiff
MdeModulePkg/Core: Fix build error with old Visual Studio
authorJian J Wang <jian.j.wang@intel.com>
Mon, 20 Nov 2017 02:59:41 +0000 (10:59 +0800)
committerStar Zeng <star.zeng@intel.com>
Mon, 20 Nov 2017 06:44:21 +0000 (14:44 +0800)
The build error is introduced by following check in:
  2930ef9809976ce693d1d377851344c3b06bd926
  235a4490c8ce8b6dbac49e6ae3559cb73d6bf620

The Visual Studio older than 2015 doesn't support constant integer
in binary format (0bxxx). This patch changes them to BIT macro to
fix it. This patch also cleans up coding style about unmatched
comment for return value.

Cc: Star Zeng <star.zeng@intel.com>
Cc: Eric Dong <eric.dong@intel.com>
Cc: Bi Dandan <dandan.bi@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Jian J Wang <jian.j.wang@intel.com>
Reviewed-by: Star Zeng <star.zeng@intel.com>
MdeModulePkg/Core/Dxe/Mem/HeapGuard.c
MdeModulePkg/Core/PiSmmCore/HeapGuard.c

index 98d597b180e6ad3b9ea8f0b18e7f15cdbee3e0ea..752befa44d064854c2ffa477137c627847e935ac 100644 (file)
@@ -373,7 +373,7 @@ ClearGuardedMemoryBits (
   @param[in]  Address       Memory address to retrieve from.
   @param[in]  NumberOfPages Number of pages to retrieve.
 
-  @return VOID.
+  @return An integer containing the guarded memory bitmap.
 **/
 UINTN
 GetGuardedMemoryBits (
@@ -501,8 +501,13 @@ IsGuardPage (
 {
   UINTN       BitMap;
 
+  //
+  // There must be at least one guarded page before and/or after given
+  // address if it's a Guard page. The bitmap pattern should be one of
+  // 001, 100 and 101
+  //
   BitMap = GetGuardedMemoryBits (Address - EFI_PAGE_SIZE, 3);
-  return ((BitMap == 0b001) || (BitMap == 0b100) || (BitMap == 0b101));
+  return ((BitMap == BIT0) || (BitMap == BIT2) || (BitMap == (BIT2 | BIT0)));
 }
 
 /**
@@ -519,7 +524,7 @@ IsHeadGuard (
   IN EFI_PHYSICAL_ADDRESS    Address
   )
 {
-  return (GetGuardedMemoryBits (Address, 2) == 0b10);
+  return (GetGuardedMemoryBits (Address, 2) == BIT1);
 }
 
 /**
@@ -536,7 +541,7 @@ IsTailGuard (
   IN EFI_PHYSICAL_ADDRESS    Address
   )
 {
-  return (GetGuardedMemoryBits (Address - EFI_PAGE_SIZE, 2) == 0b01);
+  return (GetGuardedMemoryBits (Address - EFI_PAGE_SIZE, 2) == BIT0);
 }
 
 /**
index 6fda9ba430fb8639b9ad917889fa388fe18e64d3..c7a1408562d7cc63f1040eb31854e52dc5671276 100644 (file)
@@ -385,7 +385,7 @@ ClearGuardedMemoryBits (
   @param[in]  Address       Memory address to retrieve from.
   @param[in]  NumberOfPages Number of pages to retrieve.
 
-  @return VOID
+  @return An integer containing the guarded memory bitmap.
 **/
 UINTN
 GetGuardedMemoryBits (
@@ -513,8 +513,13 @@ IsGuardPage (
 {
   UINTN       BitMap;
 
+  //
+  // There must be at least one guarded page before and/or after given
+  // address if it's a Guard page. The bitmap pattern should be one of
+  // 001, 100 and 101
+  //
   BitMap = GetGuardedMemoryBits (Address - EFI_PAGE_SIZE, 3);
-  return ((BitMap == 0b001) || (BitMap == 0b100) || (BitMap == 0b101));
+  return ((BitMap == BIT0) || (BitMap == BIT2) || (BitMap == (BIT2 | BIT0)));
 }
 
 /**
@@ -531,7 +536,7 @@ IsHeadGuard (
   IN EFI_PHYSICAL_ADDRESS    Address
   )
 {
-  return (GetGuardedMemoryBits (Address, 2) == 0b10);
+  return (GetGuardedMemoryBits (Address, 2) == BIT1);
 }
 
 /**
@@ -548,7 +553,7 @@ IsTailGuard (
   IN EFI_PHYSICAL_ADDRESS    Address
   )
 {
-  return (GetGuardedMemoryBits (Address - EFI_PAGE_SIZE, 2) == 0b01);
+  return (GetGuardedMemoryBits (Address - EFI_PAGE_SIZE, 2) == BIT0);
 }
 
 /**