summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGary Lin <glin@suse.com>2016-10-27 18:16:15 +0800
committerLaszlo Ersek <lersek@redhat.com>2016-10-27 18:21:06 +0200
commit5a5025e485b299c76ebed79fa63ba88a5b219a12 (patch)
tree98b46b4a3bce19139e37f8d84a488b6968bb1db7
parent1399565a93a7457db262ae2cb81431062fcc30c4 (diff)
downloadedk2-5a5025e485b299c76ebed79fa63ba88a5b219a12.tar.gz
edk2-5a5025e485b299c76ebed79fa63ba88a5b219a12.tar.bz2
edk2-5a5025e485b299c76ebed79fa63ba88a5b219a12.zip
OvmfPkg: Make more use of ARRAY_SIZE()
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>
-rw-r--r--OvmfPkg/Csm/CsmSupportLib/LegacyRegion.c8
-rw-r--r--OvmfPkg/Library/LoadLinuxLib/Linux.c2
-rw-r--r--OvmfPkg/Library/PciHostBridgeLib/PciHostBridgeLib.c4
-rw-r--r--OvmfPkg/VirtioGpuDxe/Gop.c7
4 files changed, 9 insertions, 12 deletions
diff --git a/OvmfPkg/Csm/CsmSupportLib/LegacyRegion.c b/OvmfPkg/Csm/CsmSupportLib/LegacyRegion.c
index b929db04d9..8d5d2e58a9 100644
--- a/OvmfPkg/Csm/CsmSupportLib/LegacyRegion.c
+++ b/OvmfPkg/Csm/CsmSupportLib/LegacyRegion.c
@@ -130,18 +130,18 @@ LegacyRegionManipulationInternal (
// Loop to find the start PAM.
//
StartIndex = 0;
- for (Index = 0; Index < (sizeof(mSectionArray) / sizeof (mSectionArray[0])); Index++) {
+ for (Index = 0; Index < ARRAY_SIZE (mSectionArray); Index++) {
if ((Start >= mSectionArray[Index].Start) && (Start < (mSectionArray[Index].Start + mSectionArray[Index].Length))) {
StartIndex = Index;
break;
}
}
- ASSERT (Index < (sizeof(mSectionArray) / sizeof (mSectionArray[0])));
+ ASSERT (Index < ARRAY_SIZE (mSectionArray));
//
// Program PAM until end PAM is encountered
//
- for (Index = StartIndex; Index < (sizeof(mSectionArray) / sizeof (mSectionArray[0])); Index++) {
+ for (Index = StartIndex; Index < ARRAY_SIZE (mSectionArray); Index++) {
if (ReadEnable != NULL) {
if (*ReadEnable) {
PciOr8 (
@@ -177,7 +177,7 @@ LegacyRegionManipulationInternal (
break;
}
}
- ASSERT (Index < (sizeof(mSectionArray) / sizeof (mSectionArray[0])));
+ ASSERT (Index < ARRAY_SIZE (mSectionArray));
return EFI_SUCCESS;
}
diff --git a/OvmfPkg/Library/LoadLinuxLib/Linux.c b/OvmfPkg/Library/LoadLinuxLib/Linux.c
index 9c996adfbb..68d15377bf 100644
--- a/OvmfPkg/Library/LoadLinuxLib/Linux.c
+++ b/OvmfPkg/Library/LoadLinuxLib/Linux.c
@@ -357,7 +357,7 @@ SetupLinuxMemmap (
LastE820->size += EFI_PAGES_TO_SIZE ((UINTN) MemoryMap->NumberOfPages);
LastEndAddr += EFI_PAGES_TO_SIZE ((UINTN) MemoryMap->NumberOfPages);
} else {
- if (E820EntryCount >= (sizeof (Bp->e820_map) / sizeof (Bp->e820_map[0]))) {
+ if (E820EntryCount >= ARRAY_SIZE (Bp->e820_map)) {
break;
}
E820->type = (UINT32) E820Type;
diff --git a/OvmfPkg/Library/PciHostBridgeLib/PciHostBridgeLib.c b/OvmfPkg/Library/PciHostBridgeLib/PciHostBridgeLib.c
index 6ba0ca6831..ff837035ca 100644
--- a/OvmfPkg/Library/PciHostBridgeLib/PciHostBridgeLib.c
+++ b/OvmfPkg/Library/PciHostBridgeLib/PciHostBridgeLib.c
@@ -419,9 +419,7 @@ PciHostBridgeResourceConflict (
DEBUG ((EFI_D_ERROR, "RootBridge[%d]:\n", RootBridgeIndex++));
for (; Descriptor->Desc == ACPI_ADDRESS_SPACE_DESCRIPTOR; Descriptor++) {
ASSERT (Descriptor->ResType <
- (sizeof (mPciHostBridgeLibAcpiAddressSpaceTypeStr) /
- sizeof (mPciHostBridgeLibAcpiAddressSpaceTypeStr[0])
- )
+ ARRAY_SIZE (mPciHostBridgeLibAcpiAddressSpaceTypeStr)
);
DEBUG ((EFI_D_ERROR, " %s: Length/Alignment = 0x%lx / 0x%lx\n",
mPciHostBridgeLibAcpiAddressSpaceTypeStr[Descriptor->ResType],
diff --git a/OvmfPkg/VirtioGpuDxe/Gop.c b/OvmfPkg/VirtioGpuDxe/Gop.c
index c6ff9ed574..3438bd0322 100644
--- a/OvmfPkg/VirtioGpuDxe/Gop.c
+++ b/OvmfPkg/VirtioGpuDxe/Gop.c
@@ -204,7 +204,7 @@ GopQueryMode (
{
EFI_GRAPHICS_OUTPUT_MODE_INFORMATION *GopModeInfo;
- if (ModeNumber >= sizeof mGopResolutions / sizeof mGopResolutions[0]) {
+ if (ModeNumber >= ARRAY_SIZE (mGopResolutions)) {
return EFI_INVALID_PARAMETER;
}
@@ -239,7 +239,7 @@ GopSetMode (
EFI_STATUS Status;
EFI_STATUS Status2;
- if (ModeNumber >= sizeof mGopResolutions / sizeof mGopResolutions[0]) {
+ if (ModeNumber >= ARRAY_SIZE (mGopResolutions)) {
return EFI_UNSUPPORTED;
}
@@ -258,8 +258,7 @@ GopSetMode (
//
VgpuGop->Gop.Mode = &VgpuGop->GopMode;
- VgpuGop->GopMode.MaxMode = (UINT32)(sizeof mGopResolutions /
- sizeof mGopResolutions[0]);
+ VgpuGop->GopMode.MaxMode = (UINT32)(ARRAY_SIZE (mGopResolutions));
VgpuGop->GopMode.Info = &VgpuGop->GopModeInfo;
VgpuGop->GopMode.SizeOfInfo = sizeof VgpuGop->GopModeInfo;