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>
// 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
break;\r
}\r
}\r
- ASSERT (Index < (sizeof(mSectionArray) / sizeof (mSectionArray[0])));\r
+ ASSERT (Index < ARRAY_SIZE (mSectionArray));\r
\r
return EFI_SUCCESS;\r
}\r
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
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
{\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
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
//\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