]> git.proxmox.com Git - mirror_edk2.git/commitdiff
OvmfPkg: Make more use of ARRAY_SIZE()
authorGary Lin <glin@suse.com>
Thu, 27 Oct 2016 10:16:15 +0000 (18:16 +0800)
committerLaszlo Ersek <lersek@redhat.com>
Thu, 27 Oct 2016 16:21:06 +0000 (18:21 +0200)
Convert the remaining pieces to make the code shorter and more readable.

Cc: Justen Jordan <jordan.l.justen@intel.com>
Cc: Laszlo Ersek <lersek@redhat.com>
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Gary Lin <glin@suse.com>
Reviewed-by: Laszlo Ersek <lersek@redhat.com>
[lersek@redhat.com: tweak subject line]
Signed-off-by: Laszlo Ersek <lersek@redhat.com>
OvmfPkg/Csm/CsmSupportLib/LegacyRegion.c
OvmfPkg/Library/LoadLinuxLib/Linux.c
OvmfPkg/Library/PciHostBridgeLib/PciHostBridgeLib.c
OvmfPkg/VirtioGpuDxe/Gop.c

index b929db04d9c5b82e5a50f4c99558848bd2acebf0..8d5d2e58a99438e1b9b81739f28cf3900ec81667 100644 (file)
@@ -130,18 +130,18 @@ LegacyRegionManipulationInternal (
   // Loop to find the start PAM.\r
   //\r
   StartIndex = 0;\r
-  for (Index = 0; Index < (sizeof(mSectionArray) / sizeof (mSectionArray[0])); Index++) {\r
+  for (Index = 0; Index < ARRAY_SIZE (mSectionArray); Index++) {\r
     if ((Start >= mSectionArray[Index].Start) && (Start < (mSectionArray[Index].Start + mSectionArray[Index].Length))) {\r
       StartIndex = Index;\r
       break;\r
     }\r
   }\r
-  ASSERT (Index < (sizeof(mSectionArray) / sizeof (mSectionArray[0])));\r
+  ASSERT (Index < ARRAY_SIZE (mSectionArray));\r
 \r
   //\r
   // Program PAM until end PAM is encountered\r
   //\r
-  for (Index = StartIndex; Index < (sizeof(mSectionArray) / sizeof (mSectionArray[0])); Index++) {\r
+  for (Index = StartIndex; Index < ARRAY_SIZE (mSectionArray); Index++) {\r
     if (ReadEnable != NULL) {\r
       if (*ReadEnable) {\r
         PciOr8 (\r
@@ -177,7 +177,7 @@ LegacyRegionManipulationInternal (
       break;\r
     }\r
   }\r
-  ASSERT (Index < (sizeof(mSectionArray) / sizeof (mSectionArray[0])));\r
+  ASSERT (Index < ARRAY_SIZE (mSectionArray));\r
 \r
   return EFI_SUCCESS;\r
 }\r
index 9c996adfbb0030c0b776083890b56480a61e6756..68d15377bf91d06b6df6165b3a3fbdecb59a451a 100644 (file)
@@ -357,7 +357,7 @@ SetupLinuxMemmap (
       LastE820->size += EFI_PAGES_TO_SIZE ((UINTN) MemoryMap->NumberOfPages);\r
       LastEndAddr += EFI_PAGES_TO_SIZE ((UINTN) MemoryMap->NumberOfPages);\r
     } else {\r
-      if (E820EntryCount >= (sizeof (Bp->e820_map) / sizeof (Bp->e820_map[0]))) {\r
+      if (E820EntryCount >= ARRAY_SIZE (Bp->e820_map)) {\r
         break;\r
       }\r
       E820->type = (UINT32) E820Type;\r
index 6ba0ca68314d807d35835099fa92d21ae045e0e4..ff837035cafff74a015986dd4343f4d8d74a9e99 100644 (file)
@@ -419,9 +419,7 @@ PciHostBridgeResourceConflict (
     DEBUG ((EFI_D_ERROR, "RootBridge[%d]:\n", RootBridgeIndex++));\r
     for (; Descriptor->Desc == ACPI_ADDRESS_SPACE_DESCRIPTOR; Descriptor++) {\r
       ASSERT (Descriptor->ResType <\r
-              (sizeof (mPciHostBridgeLibAcpiAddressSpaceTypeStr) /\r
-               sizeof (mPciHostBridgeLibAcpiAddressSpaceTypeStr[0])\r
-               )\r
+              ARRAY_SIZE (mPciHostBridgeLibAcpiAddressSpaceTypeStr)\r
               );\r
       DEBUG ((EFI_D_ERROR, " %s: Length/Alignment = 0x%lx / 0x%lx\n",\r
               mPciHostBridgeLibAcpiAddressSpaceTypeStr[Descriptor->ResType],\r
index c6ff9ed57461a0567f1a750e100dafef38bb1a95..3438bd03224e97dd8c8c0dad838c0b4500efe023 100644 (file)
@@ -204,7 +204,7 @@ GopQueryMode (
 {\r
   EFI_GRAPHICS_OUTPUT_MODE_INFORMATION *GopModeInfo;\r
 \r
-  if (ModeNumber >= sizeof mGopResolutions / sizeof mGopResolutions[0]) {\r
+  if (ModeNumber >= ARRAY_SIZE (mGopResolutions)) {\r
     return EFI_INVALID_PARAMETER;\r
   }\r
 \r
@@ -239,7 +239,7 @@ GopSetMode (
   EFI_STATUS Status;\r
   EFI_STATUS Status2;\r
 \r
-  if (ModeNumber >= sizeof mGopResolutions / sizeof mGopResolutions[0]) {\r
+  if (ModeNumber >= ARRAY_SIZE (mGopResolutions)) {\r
     return EFI_UNSUPPORTED;\r
   }\r
 \r
@@ -258,8 +258,7 @@ GopSetMode (
     //\r
     VgpuGop->Gop.Mode = &VgpuGop->GopMode;\r
 \r
-    VgpuGop->GopMode.MaxMode         = (UINT32)(sizeof mGopResolutions /\r
-                                                sizeof mGopResolutions[0]);\r
+    VgpuGop->GopMode.MaxMode         = (UINT32)(ARRAY_SIZE (mGopResolutions));\r
     VgpuGop->GopMode.Info            = &VgpuGop->GopModeInfo;\r
     VgpuGop->GopMode.SizeOfInfo      = sizeof VgpuGop->GopModeInfo;\r
 \r