public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
* [PATCH 00/47] edk2: centralize and adopt ARRAY_SIZE()
@ 2016-10-26 19:04 Laszlo Ersek
  2016-10-26 19:04 ` [PATCH 01/47] MdeModulePkg/RegularExpressionDxe: guard the definition of ARRAY_SIZE Laszlo Ersek
                   ` (51 more replies)
  0 siblings, 52 replies; 98+ messages in thread
From: Laszlo Ersek @ 2016-10-26 19:04 UTC (permalink / raw)
  To: edk2-devel-01
  Cc: Ard Biesheuvel, Cecil Sheng, Chao Zhang, Dandan Bi,
	Daryl McDaniel, David Wei, Eric Dong, Feng Tian, Gary Lin,
	Jaben Carsey, Jeff Fan, Jiaxin Wu, Jordan Justen, Liming Gao,
	Michael D Kinney, Ruiyu Ni, Siyuan Fu, Star Zeng, Tim He

I'm sure most of us have wished at some point that ARRAY_SIZE()
had existed in a central header file, like it does in many other
open source projects. This series implements that.

Patches 01-04 round up the modules that #define ARRAY_SIZE() just
for themselves, and wrap their definitions in #ifndef ARRAY_SIZE.

Patch 05 defines ARRAY_SIZE() in "MdePkg/Include/Base.h". This
flips the previously modified modules to MdePkg's macro definition.

Patches 06-09 modify the same set of modules as patches 01-04 do; this
time the (now unused) module-local ARRAY_SIZE() macro definitions are
eliminated.

The rest of the patches (10-47) migrate the edk2 tree to ARRAY_SIZE(),
covering the most obvious open-coded ARRAY_SIZE() expressions. These
expressions were located and converted with the following shell
pipeline:

  git ls-files \
  | xargs --no-run-if-empty -- \
      sed --regexp-extended --in-place \
        --expression='s,sizeof \(([a-zA-Z0-9_]+)\) / sizeof \((\*\1|\1\[0\])\),ARRAY_SIZE (\1),g' \
        --

This pipeline lists all tracked files with "git". The pathnames are then
composed with "xargs" into maximal length "sed" command lines, and those
"sed" commands are run.

Here the "sed" stream editor filters and modifies all the listed files
in place. The extended regular expression replaces the following two
patterns:

  sizeof (ArrayName) / sizeof (*ArrayName)
  sizeof (ArrayName) / sizeof (ArrayName[0])

with

  ARRAY_SIZE (ArrayName)

The regexp uses a backreference in the match, ensuring that the sizeof
operator in the dividend and the sizeof operator in the divisor both
refer to the same ArrayName. If there are multiple occurrences on the
same line, the sed command replaces all of them.

I collected the changes into patches manually, and I reviewed them all.

I test-built all of the modified packages, repeating the command

  build -a X64 -t GCC48 -b DEBUG -p FooPkg/FooPkg.dsc

as many times as necessary. Two packages were impossible to build like
this: Nt32Pkg and Vlv2TbltDevicePkg, so I couldn't build-test them.

I did some light-weight testing with OVMF: boot with Secure Boot
enabled, S3 suspend/resume with and without SMM. I also booted
ArmVirtQemu once.

Repository: https://github.com/lersek/edk2.git
Branch:     array_size

Cc: Ard Biesheuvel <ard.biesheuvel@linaro.org>
Cc: Cecil Sheng <cecil.sheng@hpe.com>
Cc: Chao Zhang <chao.b.zhang@intel.com>
Cc: Dandan Bi <dandan.bi@intel.com>
Cc: Daryl McDaniel <edk2-lists@mc2research.org>
Cc: David Wei <david.wei@intel.com>
Cc: Eric Dong <eric.dong@intel.com>
Cc: Feng Tian <feng.tian@intel.com>
Cc: Gary Lin <glin@suse.com>
Cc: Jaben Carsey <jaben.carsey@intel.com>
Cc: Jeff Fan <jeff.fan@intel.com>
Cc: Jiaxin Wu <jiaxin.wu@intel.com>
Cc: Jordan Justen <jordan.l.justen@intel.com>
Cc: Liming Gao <liming.gao@intel.com>
Cc: Michael D Kinney <michael.d.kinney@intel.com>
Cc: Ruiyu Ni <ruiyu.ni@intel.com>
Cc: Siyuan Fu <siyuan.fu@intel.com>
Cc: Star Zeng <star.zeng@intel.com>
Cc: Tim He <tim.he@intel.com>

Thanks
Laszlo

Laszlo Ersek (47):
  MdeModulePkg/RegularExpressionDxe: guard the definition of ARRAY_SIZE
  NetworkPkg/IpsecConfig: guard the definition of ARRAY_SIZE
  OvmfPkg/PlatformBootManagerLib: guard the definition of ARRAY_SIZE
  OvmfPkg/XenBusDxe: guard the definition of ARRAY_SIZE
  MdePkg/Include/Base.h: introduce the ARRAY_SIZE() function-like macro
  MdeModulePkg/RegularExpressionDxe: remove module-local ARRAY_SIZE
    macro
  NetworkPkg/IpsecConfig: remove module-local ARRAY_SIZE macro
  OvmfPkg/PlatformBootManagerLib: remove module-local ARRAY_SIZE macro
  OvmfPkg/XenBusDxe: remove module-local ARRAY_SIZE macro
  ArmVirtPkg/NorFlashQemuLib: rebase to ARRAY_SIZE()
  DuetPkg/DuetBdsLib: rebase to ARRAY_SIZE()
  EdkCompatibilityPkg/FrameworkHiiOnUefiHiiThunk: rebase to ARRAY_SIZE()
  EdkCompatibilityPkg/Sample/Tools: rebase to ARRAY_SIZE()
  FatPkg/EnhancedFatDxe: rebase to ARRAY_SIZE()
  IntelFrameworkModulePkg/LegacyBootManagerLib: rebase to ARRAY_SIZE()
  IntelFrameworkModulePkg/BdsDxe: rebase to ARRAY_SIZE()
  MdeModulePkg/MemoryProfileInfo: rebase to ARRAY_SIZE()
  MdeModulePkg/PciBusDxe: rebase to ARRAY_SIZE()
  MdeModulePkg/PciHostBridgeDxe: rebase to ARRAY_SIZE()
  MdeModulePkg/UsbBusDxe: rebase to ARRAY_SIZE()
  MdeModulePkg/Core/Dxe: rebase to ARRAY_SIZE()
  MdeModulePkg/Core/PiSmmCore: rebase to ARRAY_SIZE()
  MdeModulePkg/BootMaintenanceManagerUiLib: rebase to ARRAY_SIZE()
  MdeModulePkg/BootManagerUiLib: rebase to ARRAY_SIZE()
  MdeModulePkg/UefiBootManagerLib: rebase to ARRAY_SIZE()
  MdeModulePkg/VarCheckHiiLib: rebase to ARRAY_SIZE()
  MdeModulePkg/Logo: rebase to ARRAY_SIZE()
  MdeModulePkg/BdsDxe: rebase to ARRAY_SIZE()
  MdeModulePkg/DisplayEngineDxe: rebase to ARRAY_SIZE()
  MdeModulePkg/EbcDxe: rebase to ARRAY_SIZE()
  MdeModulePkg/Tcp4Dxe: rebase to ARRAY_SIZE()
  MdeModulePkg/Variable/RuntimeDxe: rebase to ARRAY_SIZE()
  NetworkPkg/IScsiDxe: rebase to ARRAY_SIZE()
  NetworkPkg/TcpDxe: rebase to ARRAY_SIZE()
  Nt32Pkg/WinNtSerialIoDxe: rebase to ARRAY_SIZE()
  OptionRomPkg/AtapiPassThruDxe: rebase to ARRAY_SIZE()
  OvmfPkg/QemuBootOrderLib: rebase to ARRAY_SIZE()
  OvmfPkg/QemuVideoDxe: rebase to ARRAY_SIZE()
  PerformancePkg/Dp_App: rebase to ARRAY_SIZE()
  SecurityPkg/AuthVariableLib: rebase to ARRAY_SIZE()
  ShellPkg/UefiDpLib: rebase to ARRAY_SIZE()
  ShellPkg/UefiShellLevel2CommandsLib: rebase to ARRAY_SIZE()
  Vlv2TbltDevicePkg/FirmwareUpdate: rebase to ARRAY_SIZE()
  Vlv2TbltDevicePkg/PlatformInitPei: rebase to ARRAY_SIZE()
  Vlv2TbltDevicePkg/PlatformPei: rebase to ARRAY_SIZE()
  Vlv2TbltDevicePkg/PlatformSetupDxe: rebase to ARRAY_SIZE()
  Vlv2TbltDevicePkg/SmBiosMiscDxe: rebase to ARRAY_SIZE()

 ArmVirtPkg/Library/NorFlashQemuLib/NorFlashQemuLib.c                          |  2 +-
 DuetPkg/Library/DuetBdsLib/BdsPlatform.c                                      |  2 +-
 EdkCompatibilityPkg/Compatibility/FrameworkHiiOnUefiHiiThunk/OpcodeCreation.c |  2 +-
 EdkCompatibilityPkg/Sample/Tools/Source/EfiRom/EfiRom.c                       |  4 ++--
 EdkCompatibilityPkg/Sample/Tools/Source/HiiPack/IfrParse.c                    |  2 +-
 FatPkg/EnhancedFatDxe/DirectoryManage.c                                       |  4 ++--
 FatPkg/EnhancedFatDxe/FileName.c                                              |  4 ++--
 FatPkg/EnhancedFatDxe/Hash.c                                                  |  4 ++--
 IntelFrameworkModulePkg/Library/LegacyBootManagerLib/LegacyBm.c               |  2 +-
 IntelFrameworkModulePkg/Universal/BdsDxe/BdsEntry.c                           |  2 +-
 IntelFrameworkModulePkg/Universal/BdsDxe/BootMaint/BBSsupport.c               |  4 ++--
 IntelFrameworkModulePkg/Universal/BdsDxe/BootMaint/BootMaint.c                |  8 ++++----
 IntelFrameworkModulePkg/Universal/BdsDxe/BootMaint/BootOption.c               |  2 +-
 IntelFrameworkModulePkg/Universal/BdsDxe/BootMaint/ConsoleOption.c            |  6 +++---
 IntelFrameworkModulePkg/Universal/BdsDxe/BootMaint/UpdatePage.c               | 10 +++++-----
 IntelFrameworkModulePkg/Universal/BdsDxe/BootMaint/Variable.c                 |  2 +-
 IntelFrameworkModulePkg/Universal/BdsDxe/BootMngr/BootManager.c               |  2 +-
 MdeModulePkg/Application/MemoryProfileInfo/MemoryProfileInfo.c                |  6 +++---
 MdeModulePkg/Bus/Pci/PciBusDxe/PciLib.c                                       |  2 +-
 MdeModulePkg/Bus/Pci/PciHostBridgeDxe/PciHostBridge.c                         |  2 +-
 MdeModulePkg/Bus/Usb/UsbBusDxe/UsbHub.c                                       |  4 ++--
 MdeModulePkg/Core/Dxe/Mem/Pool.c                                              |  2 +-
 MdeModulePkg/Core/PiSmmCore/Pool.c                                            |  2 +-
 MdeModulePkg/Core/PiSmmCore/SmramProfileRecord.c                              |  6 +++---
 MdeModulePkg/Library/BootMaintenanceManagerUiLib/BootMaintenance.c            |  8 ++++----
 MdeModulePkg/Library/BootMaintenanceManagerUiLib/ConsoleOption.c              |  8 ++++----
 MdeModulePkg/Library/BootMaintenanceManagerUiLib/UpdatePage.c                 | 12 ++++++------
 MdeModulePkg/Library/BootMaintenanceManagerUiLib/Variable.c                   |  2 +-
 MdeModulePkg/Library/BootManagerUiLib/BootManager.c                           |  6 +++---
 MdeModulePkg/Library/UefiBootManagerLib/BmBootDescription.c                   |  2 +-
 MdeModulePkg/Library/UefiBootManagerLib/BmConsole.c                           |  2 +-
 MdeModulePkg/Library/UefiBootManagerLib/BmHotkey.c                            |  2 +-
 MdeModulePkg/Library/UefiBootManagerLib/BmLoadOption.c                        |  4 ++--
 MdeModulePkg/Library/VarCheckHiiLib/VarCheckHiiGen.c                          |  4 ++--
 MdeModulePkg/Library/VarCheckHiiLib/VarCheckHiiLibNullClass.c                 |  2 +-
 MdeModulePkg/Logo/Logo.c                                                      |  2 +-
 MdeModulePkg/Universal/BdsDxe/BdsEntry.c                                      |  2 +-
 MdeModulePkg/Universal/DisplayEngineDxe/FormDisplay.c                         |  4 ++--
 MdeModulePkg/Universal/DisplayEngineDxe/InputHandler.c                        |  6 +++---
 MdeModulePkg/Universal/EbcDxe/EbcExecute.c                                    |  2 +-
 MdeModulePkg/Universal/Network/Tcp4Dxe/Tcp4Output.c                           |  2 +-
 MdeModulePkg/Universal/RegularExpressionDxe/RegularExpressionDxe.h            |  2 --
 MdeModulePkg/Universal/Variable/RuntimeDxe/Variable.c                         |  2 +-
 MdePkg/Include/Base.h                                                         | 13 +++++++++++++
 NetworkPkg/Application/IpsecConfig/IpSecConfig.h                              |  2 --
 NetworkPkg/IScsiDxe/IScsiConfig.c                                             |  4 ++--
 NetworkPkg/IScsiDxe/IScsiDriver.c                                             |  2 +-
 NetworkPkg/IScsiDxe/IScsiMisc.c                                               |  6 +++---
 NetworkPkg/TcpDxe/TcpOutput.c                                                 |  2 +-
 Nt32Pkg/WinNtSerialIoDxe/WinNtSerialIo.c                                      |  2 +-
 OptionRomPkg/AtapiPassThruDxe/AtapiPassThru.c                                 |  4 ++--
 OvmfPkg/Library/PlatformBootManagerLib/BdsPlatform.c                          |  5 -----
 OvmfPkg/Library/QemuBootOrderLib/QemuBootOrderLib.c                           | 12 ++++++------
 OvmfPkg/QemuVideoDxe/Initialize.c                                             |  4 ++--
 OvmfPkg/XenBusDxe/XenStore.c                                                  |  1 -
 PerformancePkg/Dp_App/Dp.c                                                    |  2 +-
 PerformancePkg/Dp_App/DpTrace.c                                               | 10 +++++-----
 SecurityPkg/Library/AuthVariableLib/AuthVariableLib.c                         |  4 ++--
 ShellPkg/Library/UefiDpLib/DpTrace.c                                          | 10 +++++-----
 ShellPkg/Library/UefiShellLevel2CommandsLib/TimeDate.c                        |  2 +-
 Vlv2TbltDevicePkg/Application/FirmwareUpdate/FirmwareUpdate.c                 |  2 +-
 Vlv2TbltDevicePkg/PlatformInitPei/FlashMap.c                                  |  2 +-
 Vlv2TbltDevicePkg/PlatformPei/BootMode.c                                      |  6 +++---
 Vlv2TbltDevicePkg/PlatformSetupDxe/SetupInfoRecords.c                         |  2 +-
 Vlv2TbltDevicePkg/SmBiosMiscDxe/MiscOemType0x94Function.c                     |  2 +-
 65 files changed, 131 insertions(+), 128 deletions(-)

-- 
2.9.2



^ permalink raw reply	[flat|nested] 98+ messages in thread

* [PATCH 01/47] MdeModulePkg/RegularExpressionDxe: guard the definition of ARRAY_SIZE
  2016-10-26 19:04 [PATCH 00/47] edk2: centralize and adopt ARRAY_SIZE() Laszlo Ersek
@ 2016-10-26 19:04 ` Laszlo Ersek
  2016-10-26 19:04 ` [PATCH 02/47] NetworkPkg/IpsecConfig: " Laszlo Ersek
                   ` (50 subsequent siblings)
  51 siblings, 0 replies; 98+ messages in thread
From: Laszlo Ersek @ 2016-10-26 19:04 UTC (permalink / raw)
  To: edk2-devel-01; +Cc: Cecil Sheng, Feng Tian, Star Zeng

In one of the next patches, we'll introduce ARRAY_SIZE in
"MdePkg/Include/Base.h". In order to proceed in small steps, make the
module-local definition of ARRAY_SIZE conditional. This way the
introduction of the macro under MdePkg will silently switch this module
over (after which we can remove the module-local definition completely).

Cc: Cecil Sheng <cecil.sheng@hpe.com>
Cc: Feng Tian <feng.tian@intel.com>
Cc: Star Zeng <star.zeng@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Laszlo Ersek <lersek@redhat.com>
---
 MdeModulePkg/Universal/RegularExpressionDxe/RegularExpressionDxe.h | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/MdeModulePkg/Universal/RegularExpressionDxe/RegularExpressionDxe.h b/MdeModulePkg/Universal/RegularExpressionDxe/RegularExpressionDxe.h
index b3f70136d8d3..73ea92b5a178 100644
--- a/MdeModulePkg/Universal/RegularExpressionDxe/RegularExpressionDxe.h
+++ b/MdeModulePkg/Universal/RegularExpressionDxe/RegularExpressionDxe.h
@@ -26,7 +26,9 @@
 #include <Library/DebugLib.h>
 #include <Library/BaseLib.h>
 
+#ifndef ARRAY_SIZE
 #define ARRAY_SIZE(Array) (sizeof(Array) / sizeof(*Array))
+#endif
 
 /**
   Checks if the input string matches to the regular expression pattern.
-- 
2.9.2




^ permalink raw reply related	[flat|nested] 98+ messages in thread

* [PATCH 02/47] NetworkPkg/IpsecConfig: guard the definition of ARRAY_SIZE
  2016-10-26 19:04 [PATCH 00/47] edk2: centralize and adopt ARRAY_SIZE() Laszlo Ersek
  2016-10-26 19:04 ` [PATCH 01/47] MdeModulePkg/RegularExpressionDxe: guard the definition of ARRAY_SIZE Laszlo Ersek
@ 2016-10-26 19:04 ` Laszlo Ersek
  2016-10-27  1:59   ` Fu, Siyuan
  2016-10-27  2:30   ` Wu, Jiaxin
  2016-10-26 19:04 ` [PATCH 03/47] OvmfPkg/PlatformBootManagerLib: " Laszlo Ersek
                   ` (49 subsequent siblings)
  51 siblings, 2 replies; 98+ messages in thread
From: Laszlo Ersek @ 2016-10-26 19:04 UTC (permalink / raw)
  To: edk2-devel-01; +Cc: Jiaxin Wu, Siyuan Fu

In one of the next patches, we'll introduce ARRAY_SIZE in
"MdePkg/Include/Base.h". In order to proceed in small steps, make the
module-local definition of ARRAY_SIZE conditional. This way the
introduction of the macro under MdePkg will silently switch this module
over (after which we can remove the module-local definition completely).

Cc: Jiaxin Wu <jiaxin.wu@intel.com>
Cc: Siyuan Fu <siyuan.fu@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Laszlo Ersek <lersek@redhat.com>
---
 NetworkPkg/Application/IpsecConfig/IpSecConfig.h | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/NetworkPkg/Application/IpsecConfig/IpSecConfig.h b/NetworkPkg/Application/IpsecConfig/IpSecConfig.h
index 8ebc599a12e7..79a436a7b3b2 100644
--- a/NetworkPkg/Application/IpsecConfig/IpSecConfig.h
+++ b/NetworkPkg/Application/IpsecConfig/IpSecConfig.h
@@ -27,7 +27,9 @@
 
 #include <Protocol/IpSecConfig.h>
 
+#ifndef ARRAY_SIZE
 #define ARRAY_SIZE(x) (sizeof(x) / sizeof(x[0]))
+#endif
 
 #define IPSECCONFIG_STATUS_NAME    L"IpSecStatus"
 
-- 
2.9.2




^ permalink raw reply related	[flat|nested] 98+ messages in thread

* [PATCH 03/47] OvmfPkg/PlatformBootManagerLib: guard the definition of ARRAY_SIZE
  2016-10-26 19:04 [PATCH 00/47] edk2: centralize and adopt ARRAY_SIZE() Laszlo Ersek
  2016-10-26 19:04 ` [PATCH 01/47] MdeModulePkg/RegularExpressionDxe: guard the definition of ARRAY_SIZE Laszlo Ersek
  2016-10-26 19:04 ` [PATCH 02/47] NetworkPkg/IpsecConfig: " Laszlo Ersek
@ 2016-10-26 19:04 ` Laszlo Ersek
  2016-10-26 19:04 ` [PATCH 04/47] OvmfPkg/XenBusDxe: " Laszlo Ersek
                   ` (48 subsequent siblings)
  51 siblings, 0 replies; 98+ messages in thread
From: Laszlo Ersek @ 2016-10-26 19:04 UTC (permalink / raw)
  To: edk2-devel-01; +Cc: Jordan Justen

In one of the next patches, we'll introduce ARRAY_SIZE in
"MdePkg/Include/Base.h". In order to proceed in small steps, make the
module-local definition of ARRAY_SIZE conditional. This way the
introduction of the macro under MdePkg will silently switch this module
over (after which we can remove the module-local definition completely).

Cc: Jordan Justen <jordan.l.justen@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Laszlo Ersek <lersek@redhat.com>
---
 OvmfPkg/Library/PlatformBootManagerLib/BdsPlatform.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/OvmfPkg/Library/PlatformBootManagerLib/BdsPlatform.c b/OvmfPkg/Library/PlatformBootManagerLib/BdsPlatform.c
index 29ce21282595..16618a8f57f0 100644
--- a/OvmfPkg/Library/PlatformBootManagerLib/BdsPlatform.c
+++ b/OvmfPkg/Library/PlatformBootManagerLib/BdsPlatform.c
@@ -40,7 +40,9 @@ CONST UINT8 PciHostIrqs[] = {
 //
 // Array Size macro
 //
+#ifndef ARRAY_SIZE
 #define ARRAY_SIZE(array) (sizeof (array) / sizeof (array[0]))
+#endif
 
 //
 // Type definitions
-- 
2.9.2




^ permalink raw reply related	[flat|nested] 98+ messages in thread

* [PATCH 04/47] OvmfPkg/XenBusDxe: guard the definition of ARRAY_SIZE
  2016-10-26 19:04 [PATCH 00/47] edk2: centralize and adopt ARRAY_SIZE() Laszlo Ersek
                   ` (2 preceding siblings ...)
  2016-10-26 19:04 ` [PATCH 03/47] OvmfPkg/PlatformBootManagerLib: " Laszlo Ersek
@ 2016-10-26 19:04 ` Laszlo Ersek
  2016-10-27  3:15   ` Gary Lin
  2016-10-26 19:04 ` [PATCH 05/47] MdePkg/Include/Base.h: introduce the ARRAY_SIZE() function-like macro Laszlo Ersek
                   ` (47 subsequent siblings)
  51 siblings, 1 reply; 98+ messages in thread
From: Laszlo Ersek @ 2016-10-26 19:04 UTC (permalink / raw)
  To: edk2-devel-01; +Cc: Gary Lin, Jordan Justen

In one of the next patches, we'll introduce ARRAY_SIZE in
"MdePkg/Include/Base.h". In order to proceed in small steps, make the
module-local definition of ARRAY_SIZE conditional. This way the
introduction of the macro under MdePkg will silently switch this module
over (after which we can remove the module-local definition completely).

Cc: Gary Lin <glin@suse.com>
Cc: Jordan Justen <jordan.l.justen@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Laszlo Ersek <lersek@redhat.com>
---
 OvmfPkg/XenBusDxe/XenStore.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/OvmfPkg/XenBusDxe/XenStore.c b/OvmfPkg/XenBusDxe/XenStore.c
index b7ae1d04863d..9eeb6f54fb50 100644
--- a/OvmfPkg/XenBusDxe/XenStore.c
+++ b/OvmfPkg/XenBusDxe/XenStore.c
@@ -713,7 +713,9 @@ static XenStoreErrors gXenStoreErrors[] = {
   { XENSTORE_STATUS_EISCONN, "EISCONN" },
   { XENSTORE_STATUS_E2BIG, "E2BIG" }
 };
+#ifndef ARRAY_SIZE
 #define ARRAY_SIZE(x) (sizeof(x) / sizeof(x[0]))
+#endif
 
 STATIC
 XENSTORE_STATUS
-- 
2.9.2




^ permalink raw reply related	[flat|nested] 98+ messages in thread

* [PATCH 05/47] MdePkg/Include/Base.h: introduce the ARRAY_SIZE() function-like macro
  2016-10-26 19:04 [PATCH 00/47] edk2: centralize and adopt ARRAY_SIZE() Laszlo Ersek
                   ` (3 preceding siblings ...)
  2016-10-26 19:04 ` [PATCH 04/47] OvmfPkg/XenBusDxe: " Laszlo Ersek
@ 2016-10-26 19:04 ` Laszlo Ersek
  2016-10-26 22:13   ` Kinney, Michael D
  2016-10-26 19:04 ` [PATCH 06/47] MdeModulePkg/RegularExpressionDxe: remove module-local ARRAY_SIZE macro Laszlo Ersek
                   ` (46 subsequent siblings)
  51 siblings, 1 reply; 98+ messages in thread
From: Laszlo Ersek @ 2016-10-26 19:04 UTC (permalink / raw)
  To: edk2-devel-01
  Cc: Ard Biesheuvel, Cecil Sheng, Chao Zhang, Dandan Bi,
	Daryl McDaniel, David Wei, Eric Dong, Feng Tian, Gary Lin,
	Jaben Carsey, Jeff Fan, Jiaxin Wu, Jordan Justen, Liming Gao,
	Michael D Kinney, Ruiyu Ni, Siyuan Fu, Star Zeng, Tim He

Several modules use ARRAY_SIZE() already; centralize the definition. (The
module-specific macro definitions are guarded by #ifndef directives at
this point.)

Cc: Ard Biesheuvel <ard.biesheuvel@linaro.org>
Cc: Cecil Sheng <cecil.sheng@hpe.com>
Cc: Chao Zhang <chao.b.zhang@intel.com>
Cc: Dandan Bi <dandan.bi@intel.com>
Cc: Daryl McDaniel <edk2-lists@mc2research.org>
Cc: David Wei <david.wei@intel.com>
Cc: Eric Dong <eric.dong@intel.com>
Cc: Feng Tian <feng.tian@intel.com>
Cc: Gary Lin <glin@suse.com>
Cc: Jaben Carsey <jaben.carsey@intel.com>
Cc: Jeff Fan <jeff.fan@intel.com>
Cc: Jiaxin Wu <jiaxin.wu@intel.com>
Cc: Jordan Justen <jordan.l.justen@intel.com>
Cc: Liming Gao <liming.gao@intel.com>
Cc: Michael D Kinney <michael.d.kinney@intel.com>
Cc: Ruiyu Ni <ruiyu.ni@intel.com>
Cc: Siyuan Fu <siyuan.fu@intel.com>
Cc: Star Zeng <star.zeng@intel.com>
Cc: Tim He <tim.he@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Laszlo Ersek <lersek@redhat.com>
---
 MdePkg/Include/Base.h | 13 +++++++++++++
 1 file changed, 13 insertions(+)

diff --git a/MdePkg/Include/Base.h b/MdePkg/Include/Base.h
index c66614846488..8bdb257e37bd 100644
--- a/MdePkg/Include/Base.h
+++ b/MdePkg/Include/Base.h
@@ -1211,5 +1211,18 @@ typedef UINTN RETURN_STATUS;
   #define RETURN_ADDRESS(L)     ((VOID *) 0)
 #endif
 
+/**
+  Return the number of elements in an array.
+
+  @param  Array  An object of array type. Array is only used as an argument to
+                 the sizeof operator, therefore Array is never evaluated. The
+                 caller is responsible for ensuring that Array's type is not
+                 incomplete; that is, Array must have known constant size.
+
+  @return The number of elements in Array. The result has type UINTN.
+
+**/
+#define ARRAY_SIZE(Array) (sizeof (Array) / sizeof (Array)[0])
+
 #endif
 
-- 
2.9.2




^ permalink raw reply related	[flat|nested] 98+ messages in thread

* [PATCH 06/47] MdeModulePkg/RegularExpressionDxe: remove module-local ARRAY_SIZE macro
  2016-10-26 19:04 [PATCH 00/47] edk2: centralize and adopt ARRAY_SIZE() Laszlo Ersek
                   ` (4 preceding siblings ...)
  2016-10-26 19:04 ` [PATCH 05/47] MdePkg/Include/Base.h: introduce the ARRAY_SIZE() function-like macro Laszlo Ersek
@ 2016-10-26 19:04 ` Laszlo Ersek
  2016-10-26 19:04 ` [PATCH 07/47] NetworkPkg/IpsecConfig: " Laszlo Ersek
                   ` (45 subsequent siblings)
  51 siblings, 0 replies; 98+ messages in thread
From: Laszlo Ersek @ 2016-10-26 19:04 UTC (permalink / raw)
  To: edk2-devel-01; +Cc: Cecil Sheng, Feng Tian, Star Zeng

Rely on the central macro definition from "MdePkg/Include/Base.h" instead.

Cc: Cecil Sheng <cecil.sheng@hpe.com>
Cc: Feng Tian <feng.tian@intel.com>
Cc: Star Zeng <star.zeng@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Laszlo Ersek <lersek@redhat.com>
---
 MdeModulePkg/Universal/RegularExpressionDxe/RegularExpressionDxe.h | 4 ----
 1 file changed, 4 deletions(-)

diff --git a/MdeModulePkg/Universal/RegularExpressionDxe/RegularExpressionDxe.h b/MdeModulePkg/Universal/RegularExpressionDxe/RegularExpressionDxe.h
index 73ea92b5a178..0defa56e810c 100644
--- a/MdeModulePkg/Universal/RegularExpressionDxe/RegularExpressionDxe.h
+++ b/MdeModulePkg/Universal/RegularExpressionDxe/RegularExpressionDxe.h
@@ -26,10 +26,6 @@
 #include <Library/DebugLib.h>
 #include <Library/BaseLib.h>
 
-#ifndef ARRAY_SIZE
-#define ARRAY_SIZE(Array) (sizeof(Array) / sizeof(*Array))
-#endif
-
 /**
   Checks if the input string matches to the regular expression pattern.
 
-- 
2.9.2




^ permalink raw reply related	[flat|nested] 98+ messages in thread

* [PATCH 07/47] NetworkPkg/IpsecConfig: remove module-local ARRAY_SIZE macro
  2016-10-26 19:04 [PATCH 00/47] edk2: centralize and adopt ARRAY_SIZE() Laszlo Ersek
                   ` (5 preceding siblings ...)
  2016-10-26 19:04 ` [PATCH 06/47] MdeModulePkg/RegularExpressionDxe: remove module-local ARRAY_SIZE macro Laszlo Ersek
@ 2016-10-26 19:04 ` Laszlo Ersek
  2016-10-27  1:59   ` Fu, Siyuan
  2016-10-27  2:31   ` Wu, Jiaxin
  2016-10-26 19:04 ` [PATCH 08/47] OvmfPkg/PlatformBootManagerLib: " Laszlo Ersek
                   ` (44 subsequent siblings)
  51 siblings, 2 replies; 98+ messages in thread
From: Laszlo Ersek @ 2016-10-26 19:04 UTC (permalink / raw)
  To: edk2-devel-01; +Cc: Jiaxin Wu, Siyuan Fu

Rely on the central macro definition from "MdePkg/Include/Base.h" instead.

Cc: Jiaxin Wu <jiaxin.wu@intel.com>
Cc: Siyuan Fu <siyuan.fu@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Laszlo Ersek <lersek@redhat.com>
---
 NetworkPkg/Application/IpsecConfig/IpSecConfig.h | 4 ----
 1 file changed, 4 deletions(-)

diff --git a/NetworkPkg/Application/IpsecConfig/IpSecConfig.h b/NetworkPkg/Application/IpsecConfig/IpSecConfig.h
index 79a436a7b3b2..95bb6961136d 100644
--- a/NetworkPkg/Application/IpsecConfig/IpSecConfig.h
+++ b/NetworkPkg/Application/IpsecConfig/IpSecConfig.h
@@ -27,10 +27,6 @@
 
 #include <Protocol/IpSecConfig.h>
 
-#ifndef ARRAY_SIZE
-#define ARRAY_SIZE(x) (sizeof(x) / sizeof(x[0]))
-#endif
-
 #define IPSECCONFIG_STATUS_NAME    L"IpSecStatus"
 
 #define BIT(x)   (UINT32) (1 << (x))
-- 
2.9.2




^ permalink raw reply related	[flat|nested] 98+ messages in thread

* [PATCH 08/47] OvmfPkg/PlatformBootManagerLib: remove module-local ARRAY_SIZE macro
  2016-10-26 19:04 [PATCH 00/47] edk2: centralize and adopt ARRAY_SIZE() Laszlo Ersek
                   ` (6 preceding siblings ...)
  2016-10-26 19:04 ` [PATCH 07/47] NetworkPkg/IpsecConfig: " Laszlo Ersek
@ 2016-10-26 19:04 ` Laszlo Ersek
  2016-10-26 19:04 ` [PATCH 09/47] OvmfPkg/XenBusDxe: " Laszlo Ersek
                   ` (43 subsequent siblings)
  51 siblings, 0 replies; 98+ messages in thread
From: Laszlo Ersek @ 2016-10-26 19:04 UTC (permalink / raw)
  To: edk2-devel-01; +Cc: Jordan Justen

Rely on the central macro definition from "MdePkg/Include/Base.h" instead.

Cc: Jordan Justen <jordan.l.justen@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Laszlo Ersek <lersek@redhat.com>
---
 OvmfPkg/Library/PlatformBootManagerLib/BdsPlatform.c | 7 -------
 1 file changed, 7 deletions(-)

diff --git a/OvmfPkg/Library/PlatformBootManagerLib/BdsPlatform.c b/OvmfPkg/Library/PlatformBootManagerLib/BdsPlatform.c
index 16618a8f57f0..66ee590f427e 100644
--- a/OvmfPkg/Library/PlatformBootManagerLib/BdsPlatform.c
+++ b/OvmfPkg/Library/PlatformBootManagerLib/BdsPlatform.c
@@ -38,13 +38,6 @@ CONST UINT8 PciHostIrqs[] = {
 };
 
 //
-// Array Size macro
-//
-#ifndef ARRAY_SIZE
-#define ARRAY_SIZE(array) (sizeof (array) / sizeof (array[0]))
-#endif
-
-//
 // Type definitions
 //
 
-- 
2.9.2




^ permalink raw reply related	[flat|nested] 98+ messages in thread

* [PATCH 09/47] OvmfPkg/XenBusDxe: remove module-local ARRAY_SIZE macro
  2016-10-26 19:04 [PATCH 00/47] edk2: centralize and adopt ARRAY_SIZE() Laszlo Ersek
                   ` (7 preceding siblings ...)
  2016-10-26 19:04 ` [PATCH 08/47] OvmfPkg/PlatformBootManagerLib: " Laszlo Ersek
@ 2016-10-26 19:04 ` Laszlo Ersek
  2016-10-27  3:16   ` Gary Lin
  2016-10-26 19:04 ` [PATCH 10/47] ArmVirtPkg/NorFlashQemuLib: rebase to ARRAY_SIZE() Laszlo Ersek
                   ` (42 subsequent siblings)
  51 siblings, 1 reply; 98+ messages in thread
From: Laszlo Ersek @ 2016-10-26 19:04 UTC (permalink / raw)
  To: edk2-devel-01; +Cc: Gary Lin, Jordan Justen

Rely on the central macro definition from "MdePkg/Include/Base.h" instead.

Cc: Gary Lin <glin@suse.com>
Cc: Jordan Justen <jordan.l.justen@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Laszlo Ersek <lersek@redhat.com>
---
 OvmfPkg/XenBusDxe/XenStore.c | 3 ---
 1 file changed, 3 deletions(-)

diff --git a/OvmfPkg/XenBusDxe/XenStore.c b/OvmfPkg/XenBusDxe/XenStore.c
index 9eeb6f54fb50..1666c4b8f90f 100644
--- a/OvmfPkg/XenBusDxe/XenStore.c
+++ b/OvmfPkg/XenBusDxe/XenStore.c
@@ -713,9 +713,6 @@ static XenStoreErrors gXenStoreErrors[] = {
   { XENSTORE_STATUS_EISCONN, "EISCONN" },
   { XENSTORE_STATUS_E2BIG, "E2BIG" }
 };
-#ifndef ARRAY_SIZE
-#define ARRAY_SIZE(x) (sizeof(x) / sizeof(x[0]))
-#endif
 
 STATIC
 XENSTORE_STATUS
-- 
2.9.2




^ permalink raw reply related	[flat|nested] 98+ messages in thread

* [PATCH 10/47] ArmVirtPkg/NorFlashQemuLib: rebase to ARRAY_SIZE()
  2016-10-26 19:04 [PATCH 00/47] edk2: centralize and adopt ARRAY_SIZE() Laszlo Ersek
                   ` (8 preceding siblings ...)
  2016-10-26 19:04 ` [PATCH 09/47] OvmfPkg/XenBusDxe: " Laszlo Ersek
@ 2016-10-26 19:04 ` Laszlo Ersek
  2016-10-27  7:30   ` Ard Biesheuvel
  2016-10-26 19:04 ` [PATCH 11/47] DuetPkg/DuetBdsLib: " Laszlo Ersek
                   ` (41 subsequent siblings)
  51 siblings, 1 reply; 98+ messages in thread
From: Laszlo Ersek @ 2016-10-26 19:04 UTC (permalink / raw)
  To: edk2-devel-01; +Cc: Ard Biesheuvel

Cc: Ard Biesheuvel <ard.biesheuvel@linaro.org>
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Laszlo Ersek <lersek@redhat.com>
---
 ArmVirtPkg/Library/NorFlashQemuLib/NorFlashQemuLib.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/ArmVirtPkg/Library/NorFlashQemuLib/NorFlashQemuLib.c b/ArmVirtPkg/Library/NorFlashQemuLib/NorFlashQemuLib.c
index 7f346077e6b5..d63a2d989f69 100644
--- a/ArmVirtPkg/Library/NorFlashQemuLib/NorFlashQemuLib.c
+++ b/ArmVirtPkg/Library/NorFlashQemuLib/NorFlashQemuLib.c
@@ -46,6 +46,6 @@ NorFlashPlatformGetDevices (
   )
 {
   *NorFlashDescriptions = mNorFlashDevices;
-  *Count = sizeof (mNorFlashDevices) / sizeof (mNorFlashDevices[0]);
+  *Count = ARRAY_SIZE (mNorFlashDevices);
   return EFI_SUCCESS;
 }
-- 
2.9.2




^ permalink raw reply related	[flat|nested] 98+ messages in thread

* [PATCH 11/47] DuetPkg/DuetBdsLib: rebase to ARRAY_SIZE()
  2016-10-26 19:04 [PATCH 00/47] edk2: centralize and adopt ARRAY_SIZE() Laszlo Ersek
                   ` (9 preceding siblings ...)
  2016-10-26 19:04 ` [PATCH 10/47] ArmVirtPkg/NorFlashQemuLib: rebase to ARRAY_SIZE() Laszlo Ersek
@ 2016-10-26 19:04 ` Laszlo Ersek
  2016-10-27  8:16   ` Laszlo Ersek
  2016-10-26 19:04 ` [PATCH 12/47] EdkCompatibilityPkg/FrameworkHiiOnUefiHiiThunk: " Laszlo Ersek
                   ` (40 subsequent siblings)
  51 siblings, 1 reply; 98+ messages in thread
From: Laszlo Ersek @ 2016-10-26 19:04 UTC (permalink / raw)
  To: edk2-devel-01

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Laszlo Ersek <lersek@redhat.com>
---
 DuetPkg/Library/DuetBdsLib/BdsPlatform.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/DuetPkg/Library/DuetBdsLib/BdsPlatform.c b/DuetPkg/Library/DuetBdsLib/BdsPlatform.c
index 1875dc963680..a4b2aa947322 100644
--- a/DuetPkg/Library/DuetBdsLib/BdsPlatform.c
+++ b/DuetPkg/Library/DuetBdsLib/BdsPlatform.c
@@ -64,7 +64,7 @@ Returns:
   //
   // Iteratively add ACPI Table, SMBIOS Table, MPS Table to EFI System Table
   //
-  for (Index = 0; Index < sizeof (gTableGuidArray) / sizeof (*gTableGuidArray); ++Index) {
+  for (Index = 0; Index < ARRAY_SIZE (gTableGuidArray); ++Index) {
     GuidHob.Raw = GetNextGuidHob (gTableGuidArray[Index], HobStart.Raw);
     if (GuidHob.Raw != NULL) {
       Table = GET_GUID_HOB_DATA (GuidHob.Guid);
-- 
2.9.2




^ permalink raw reply related	[flat|nested] 98+ messages in thread

* [PATCH 12/47] EdkCompatibilityPkg/FrameworkHiiOnUefiHiiThunk: rebase to ARRAY_SIZE()
  2016-10-26 19:04 [PATCH 00/47] edk2: centralize and adopt ARRAY_SIZE() Laszlo Ersek
                   ` (10 preceding siblings ...)
  2016-10-26 19:04 ` [PATCH 11/47] DuetPkg/DuetBdsLib: " Laszlo Ersek
@ 2016-10-26 19:04 ` Laszlo Ersek
  2016-10-27  1:20   ` Gao, Liming
  2016-10-26 19:04 ` [PATCH 13/47] EdkCompatibilityPkg/Sample/Tools: " Laszlo Ersek
                   ` (39 subsequent siblings)
  51 siblings, 1 reply; 98+ messages in thread
From: Laszlo Ersek @ 2016-10-26 19:04 UTC (permalink / raw)
  To: edk2-devel-01; +Cc: Liming Gao

Cc: Liming Gao <liming.gao@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Laszlo Ersek <lersek@redhat.com>
---
 EdkCompatibilityPkg/Compatibility/FrameworkHiiOnUefiHiiThunk/OpcodeCreation.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/EdkCompatibilityPkg/Compatibility/FrameworkHiiOnUefiHiiThunk/OpcodeCreation.c b/EdkCompatibilityPkg/Compatibility/FrameworkHiiOnUefiHiiThunk/OpcodeCreation.c
index dd07dfcf40cf..a3ddce9b44ec 100644
--- a/EdkCompatibilityPkg/Compatibility/FrameworkHiiOnUefiHiiThunk/OpcodeCreation.c
+++ b/EdkCompatibilityPkg/Compatibility/FrameworkHiiOnUefiHiiThunk/OpcodeCreation.c
@@ -51,7 +51,7 @@ QuestionOpFwToUefi (
 {
   UINTN       Index;
 
-  for (Index = 0; Index < sizeof (QuestionOpcodeMap) / sizeof (QuestionOpcodeMap[0]); Index++) {
+  for (Index = 0; Index < ARRAY_SIZE (QuestionOpcodeMap); Index++) {
     if (FwOp == QuestionOpcodeMap[Index].FrameworkIfrOp) {
       *UefiOp = QuestionOpcodeMap[Index].UefiIfrOp;
       return EFI_SUCCESS;
-- 
2.9.2




^ permalink raw reply related	[flat|nested] 98+ messages in thread

* [PATCH 13/47] EdkCompatibilityPkg/Sample/Tools: rebase to ARRAY_SIZE()
  2016-10-26 19:04 [PATCH 00/47] edk2: centralize and adopt ARRAY_SIZE() Laszlo Ersek
                   ` (11 preceding siblings ...)
  2016-10-26 19:04 ` [PATCH 12/47] EdkCompatibilityPkg/FrameworkHiiOnUefiHiiThunk: " Laszlo Ersek
@ 2016-10-26 19:04 ` Laszlo Ersek
  2016-10-27  1:20   ` Gao, Liming
  2016-10-26 19:04 ` [PATCH 14/47] FatPkg/EnhancedFatDxe: " Laszlo Ersek
                   ` (38 subsequent siblings)
  51 siblings, 1 reply; 98+ messages in thread
From: Laszlo Ersek @ 2016-10-26 19:04 UTC (permalink / raw)
  To: edk2-devel-01; +Cc: Liming Gao

Cc: Liming Gao <liming.gao@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Laszlo Ersek <lersek@redhat.com>
---
 EdkCompatibilityPkg/Sample/Tools/Source/EfiRom/EfiRom.c    | 4 ++--
 EdkCompatibilityPkg/Sample/Tools/Source/HiiPack/IfrParse.c | 2 +-
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/EdkCompatibilityPkg/Sample/Tools/Source/EfiRom/EfiRom.c b/EdkCompatibilityPkg/Sample/Tools/Source/EfiRom/EfiRom.c
index cf8efc86e1b4..f787ae81c2b3 100644
--- a/EdkCompatibilityPkg/Sample/Tools/Source/EfiRom/EfiRom.c
+++ b/EdkCompatibilityPkg/Sample/Tools/Source/EfiRom/EfiRom.c
@@ -397,8 +397,8 @@ GetCodeTypeStr (
   UINT8     CodeType
   )
 {
-  if (CodeType >= sizeof (mCodeTypeStr) / sizeof (*mCodeTypeStr)) {
-    CodeType = sizeof (mCodeTypeStr) / sizeof (*mCodeTypeStr) - 1;
+  if (CodeType >= ARRAY_SIZE (mCodeTypeStr)) {
+    CodeType = ARRAY_SIZE (mCodeTypeStr) - 1;
   }
   return mCodeTypeStr[CodeType];
 }
diff --git a/EdkCompatibilityPkg/Sample/Tools/Source/HiiPack/IfrParse.c b/EdkCompatibilityPkg/Sample/Tools/Source/HiiPack/IfrParse.c
index e69af5c25932..e60a2d9eeb30 100644
--- a/EdkCompatibilityPkg/Sample/Tools/Source/HiiPack/IfrParse.c
+++ b/EdkCompatibilityPkg/Sample/Tools/Source/HiiPack/IfrParse.c
@@ -470,7 +470,7 @@ static const IFR_PARSE_TABLE_ENTRY  mIfrParseTable[] = {
     IfrParse2A
   },
 };
-#define PARSE_TABLE_ENTRIES (sizeof (mIfrParseTable) / sizeof (mIfrParseTable[0]))
+#define PARSE_TABLE_ENTRIES (ARRAY_SIZE (mIfrParseTable))
 
 static
 STATUS
-- 
2.9.2




^ permalink raw reply related	[flat|nested] 98+ messages in thread

* [PATCH 14/47] FatPkg/EnhancedFatDxe: rebase to ARRAY_SIZE()
  2016-10-26 19:04 [PATCH 00/47] edk2: centralize and adopt ARRAY_SIZE() Laszlo Ersek
                   ` (12 preceding siblings ...)
  2016-10-26 19:04 ` [PATCH 13/47] EdkCompatibilityPkg/Sample/Tools: " Laszlo Ersek
@ 2016-10-26 19:04 ` Laszlo Ersek
  2016-10-27  1:53   ` Ni, Ruiyu
  2016-10-26 19:04 ` [PATCH 15/47] IntelFrameworkModulePkg/LegacyBootManagerLib: " Laszlo Ersek
                   ` (37 subsequent siblings)
  51 siblings, 1 reply; 98+ messages in thread
From: Laszlo Ersek @ 2016-10-26 19:04 UTC (permalink / raw)
  To: edk2-devel-01; +Cc: Ruiyu Ni

Cc: Ruiyu Ni <ruiyu.ni@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Laszlo Ersek <lersek@redhat.com>
---
 FatPkg/EnhancedFatDxe/DirectoryManage.c | 4 ++--
 FatPkg/EnhancedFatDxe/FileName.c        | 4 ++--
 FatPkg/EnhancedFatDxe/Hash.c            | 4 ++--
 3 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/FatPkg/EnhancedFatDxe/DirectoryManage.c b/FatPkg/EnhancedFatDxe/DirectoryManage.c
index 91e7599e2722..3328ae31fed9 100644
--- a/FatPkg/EnhancedFatDxe/DirectoryManage.c
+++ b/FatPkg/EnhancedFatDxe/DirectoryManage.c
@@ -118,7 +118,7 @@ Returns:
     SetMem (LfnBuffer, sizeof (CHAR16) * LFN_CHAR_TOTAL * EntryCount, 0xff);
     Status = StrCpyS (
                LfnBuffer,
-               sizeof (LfnBuffer) / sizeof (LfnBuffer[0]),
+               ARRAY_SIZE (LfnBuffer),
                DirEnt->FileString
                );
     if (EFI_ERROR (Status)) {
@@ -360,7 +360,7 @@ Returns:
     FatGetFileNameViaCaseFlag (
       DirEnt,
       LfnBuffer,
-      sizeof (LfnBuffer) / sizeof (LfnBuffer[0])
+      ARRAY_SIZE (LfnBuffer)
       );
   }
 
diff --git a/FatPkg/EnhancedFatDxe/FileName.c b/FatPkg/EnhancedFatDxe/FileName.c
index 551cda53b9a4..5df403625d64 100644
--- a/FatPkg/EnhancedFatDxe/FileName.c
+++ b/FatPkg/EnhancedFatDxe/FileName.c
@@ -310,7 +310,7 @@ Returns:
   // Lower case a copy of the string, if it matches the
   // original then the string is lower case
   //
-  StrCpyS (Buffer, sizeof (Buffer) / sizeof (Buffer[0]), Str);
+  StrCpyS (Buffer, ARRAY_SIZE (Buffer), Str);
   FatStrLwr (Buffer);
   if (StrCmp (Str, Buffer) == 0) {
     OutCaseFlag = InCaseFlag;
@@ -319,7 +319,7 @@ Returns:
   // Upper case a copy of the string, if it matches the
   // original then the string is upper case
   //
-  StrCpyS (Buffer, sizeof (Buffer) / sizeof (Buffer[0]), Str);
+  StrCpyS (Buffer, ARRAY_SIZE (Buffer), Str);
   FatStrUpr (Buffer);
   if (StrCmp (Str, Buffer) == 0) {
     OutCaseFlag = 0;
diff --git a/FatPkg/EnhancedFatDxe/Hash.c b/FatPkg/EnhancedFatDxe/Hash.c
index 3d0ffe6fb879..f827368ef5eb 100644
--- a/FatPkg/EnhancedFatDxe/Hash.c
+++ b/FatPkg/EnhancedFatDxe/Hash.c
@@ -49,9 +49,9 @@ Returns:
   CHAR16  UpCasedLongFileName[EFI_PATH_STRING_LENGTH];
   StrnCpyS (
     UpCasedLongFileName,
-    sizeof (UpCasedLongFileName) / sizeof (UpCasedLongFileName[0]),
+    ARRAY_SIZE (UpCasedLongFileName),
     LongNameString,
-    sizeof (UpCasedLongFileName) / sizeof (UpCasedLongFileName[0]) - 1
+    ARRAY_SIZE (UpCasedLongFileName) - 1
     );
   FatStrUpr (UpCasedLongFileName);
   gBS->CalculateCrc32 (UpCasedLongFileName, StrSize (UpCasedLongFileName), &HashValue);
-- 
2.9.2




^ permalink raw reply related	[flat|nested] 98+ messages in thread

* [PATCH 15/47] IntelFrameworkModulePkg/LegacyBootManagerLib: rebase to ARRAY_SIZE()
  2016-10-26 19:04 [PATCH 00/47] edk2: centralize and adopt ARRAY_SIZE() Laszlo Ersek
                   ` (13 preceding siblings ...)
  2016-10-26 19:04 ` [PATCH 14/47] FatPkg/EnhancedFatDxe: " Laszlo Ersek
@ 2016-10-26 19:04 ` Laszlo Ersek
  2016-10-27  3:09   ` Fan, Jeff
  2016-10-26 19:04 ` [PATCH 16/47] IntelFrameworkModulePkg/BdsDxe: " Laszlo Ersek
                   ` (36 subsequent siblings)
  51 siblings, 1 reply; 98+ messages in thread
From: Laszlo Ersek @ 2016-10-26 19:04 UTC (permalink / raw)
  To: edk2-devel-01; +Cc: Jeff Fan

Cc: Jeff Fan <jeff.fan@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Laszlo Ersek <lersek@redhat.com>
---
 IntelFrameworkModulePkg/Library/LegacyBootManagerLib/LegacyBm.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/IntelFrameworkModulePkg/Library/LegacyBootManagerLib/LegacyBm.c b/IntelFrameworkModulePkg/Library/LegacyBootManagerLib/LegacyBm.c
index d3b48e8d0b9e..c56a8786391a 100644
--- a/IntelFrameworkModulePkg/Library/LegacyBootManagerLib/LegacyBm.c
+++ b/IntelFrameworkModulePkg/Library/LegacyBootManagerLib/LegacyBm.c
@@ -183,7 +183,7 @@ LegacyBmBuildLegacyDevNameString (
     //
     CopyMem (StringBufferA, StringDesc, LEGACY_BM_BOOT_DESCRIPTION_LENGTH);
     StringBufferA[LEGACY_BM_BOOT_DESCRIPTION_LENGTH] = 0;
-    AsciiStrToUnicodeStrS (StringBufferA, StringBufferU, sizeof (StringBufferU) / sizeof (StringBufferU[0]));
+    AsciiStrToUnicodeStrS (StringBufferA, StringBufferU, ARRAY_SIZE (StringBufferU));
     Fmt   = L"%s";
     Type  = StringBufferU;
   }
-- 
2.9.2




^ permalink raw reply related	[flat|nested] 98+ messages in thread

* [PATCH 16/47] IntelFrameworkModulePkg/BdsDxe: rebase to ARRAY_SIZE()
  2016-10-26 19:04 [PATCH 00/47] edk2: centralize and adopt ARRAY_SIZE() Laszlo Ersek
                   ` (14 preceding siblings ...)
  2016-10-26 19:04 ` [PATCH 15/47] IntelFrameworkModulePkg/LegacyBootManagerLib: " Laszlo Ersek
@ 2016-10-26 19:04 ` Laszlo Ersek
  2016-10-27  3:12   ` Fan, Jeff
  2016-10-26 19:04 ` [PATCH 17/47] MdeModulePkg/MemoryProfileInfo: " Laszlo Ersek
                   ` (35 subsequent siblings)
  51 siblings, 1 reply; 98+ messages in thread
From: Laszlo Ersek @ 2016-10-26 19:04 UTC (permalink / raw)
  To: edk2-devel-01; +Cc: Jeff Fan

Cc: Jeff Fan <jeff.fan@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Laszlo Ersek <lersek@redhat.com>
---
 IntelFrameworkModulePkg/Universal/BdsDxe/BdsEntry.c                |  2 +-
 IntelFrameworkModulePkg/Universal/BdsDxe/BootMaint/BBSsupport.c    |  4 ++--
 IntelFrameworkModulePkg/Universal/BdsDxe/BootMaint/BootMaint.c     |  8 ++++----
 IntelFrameworkModulePkg/Universal/BdsDxe/BootMaint/BootOption.c    |  2 +-
 IntelFrameworkModulePkg/Universal/BdsDxe/BootMaint/ConsoleOption.c |  6 +++---
 IntelFrameworkModulePkg/Universal/BdsDxe/BootMaint/UpdatePage.c    | 10 +++++-----
 IntelFrameworkModulePkg/Universal/BdsDxe/BootMaint/Variable.c      |  2 +-
 IntelFrameworkModulePkg/Universal/BdsDxe/BootMngr/BootManager.c    |  2 +-
 8 files changed, 18 insertions(+), 18 deletions(-)

diff --git a/IntelFrameworkModulePkg/Universal/BdsDxe/BdsEntry.c b/IntelFrameworkModulePkg/Universal/BdsDxe/BdsEntry.c
index ae7ad2153c51..bf81de40a31d 100644
--- a/IntelFrameworkModulePkg/Universal/BdsDxe/BdsEntry.c
+++ b/IntelFrameworkModulePkg/Universal/BdsDxe/BdsEntry.c
@@ -581,7 +581,7 @@ BdsEntry (
   Status = gBS->LocateProtocol (&gEdkiiVariableLockProtocolGuid, NULL, (VOID **) &VariableLock);
   DEBUG ((EFI_D_INFO, "[BdsDxe] Locate Variable Lock protocol - %r\n", Status));
   if (!EFI_ERROR (Status)) {
-    for (Index = 0; Index < sizeof (mReadOnlyVariables) / sizeof (mReadOnlyVariables[0]); Index++) {
+    for (Index = 0; Index < ARRAY_SIZE (mReadOnlyVariables); Index++) {
       Status = VariableLock->RequestToLock (VariableLock, mReadOnlyVariables[Index], &gEfiGlobalVariableGuid);
       ASSERT_EFI_ERROR (Status);
     }
diff --git a/IntelFrameworkModulePkg/Universal/BdsDxe/BootMaint/BBSsupport.c b/IntelFrameworkModulePkg/Universal/BdsDxe/BootMaint/BBSsupport.c
index 6a0b525f1581..2ef9cf13ebb8 100644
--- a/IntelFrameworkModulePkg/Universal/BdsDxe/BootMaint/BBSsupport.c
+++ b/IntelFrameworkModulePkg/Universal/BdsDxe/BootMaint/BBSsupport.c
@@ -206,7 +206,7 @@ GroupMultipleLegacyBootOption4SameType (
       //
       // Legacy Boot Option
       //
-      ASSERT ((((BBS_BBS_DEVICE_PATH *) BootOption->DevicePath)->DeviceType & 0xF) < sizeof (DeviceTypeIndex) / sizeof (DeviceTypeIndex[0]));
+      ASSERT ((((BBS_BBS_DEVICE_PATH *) BootOption->DevicePath)->DeviceType & 0xF) < ARRAY_SIZE (DeviceTypeIndex));
       NextIndex = &DeviceTypeIndex[((BBS_BBS_DEVICE_PATH *) BootOption->DevicePath)->DeviceType & 0xF];
 
       if (*NextIndex == (UINTN) -1) {
@@ -225,7 +225,7 @@ GroupMultipleLegacyBootOption4SameType (
         //
         // Update the DeviceTypeIndex array to reflect the right shift operation
         //
-        for (DeviceIndex = 0; DeviceIndex < sizeof (DeviceTypeIndex) / sizeof (DeviceTypeIndex[0]); DeviceIndex++) {
+        for (DeviceIndex = 0; DeviceIndex < ARRAY_SIZE (DeviceTypeIndex); DeviceIndex++) {
           if (DeviceTypeIndex[DeviceIndex] != (UINTN) -1 && DeviceTypeIndex[DeviceIndex] >= *NextIndex) {
             DeviceTypeIndex[DeviceIndex]++;
           }
diff --git a/IntelFrameworkModulePkg/Universal/BdsDxe/BootMaint/BootMaint.c b/IntelFrameworkModulePkg/Universal/BdsDxe/BootMaint/BootMaint.c
index 96f84ece2a9a..d5ea0f457705 100644
--- a/IntelFrameworkModulePkg/Universal/BdsDxe/BootMaint/BootMaint.c
+++ b/IntelFrameworkModulePkg/Universal/BdsDxe/BootMaint/BootMaint.c
@@ -520,16 +520,16 @@ BootMaintRouteConfig (
     ASSERT (NewMenuEntry != NULL);
     NewTerminalContext = (BM_TERMINAL_CONTEXT *) NewMenuEntry->VariableContext;
     NewTerminalContext->BaudRateIndex = NewBmmData->COMBaudRate[Index];
-    ASSERT (NewBmmData->COMBaudRate[Index] < (sizeof (BaudRateList) / sizeof (BaudRateList[0])));
+    ASSERT (NewBmmData->COMBaudRate[Index] < (ARRAY_SIZE (BaudRateList)));
     NewTerminalContext->BaudRate      = BaudRateList[NewBmmData->COMBaudRate[Index]].Value;
     NewTerminalContext->DataBitsIndex = NewBmmData->COMDataRate[Index];
-    ASSERT (NewBmmData->COMDataRate[Index] < (sizeof (DataBitsList) / sizeof (DataBitsList[0])));
+    ASSERT (NewBmmData->COMDataRate[Index] < (ARRAY_SIZE (DataBitsList)));
     NewTerminalContext->DataBits      = (UINT8) DataBitsList[NewBmmData->COMDataRate[Index]].Value;
     NewTerminalContext->StopBitsIndex = NewBmmData->COMStopBits[Index];
-    ASSERT (NewBmmData->COMStopBits[Index] < (sizeof (StopBitsList) / sizeof (StopBitsList[0])));
+    ASSERT (NewBmmData->COMStopBits[Index] < (ARRAY_SIZE (StopBitsList)));
     NewTerminalContext->StopBits      = (UINT8) StopBitsList[NewBmmData->COMStopBits[Index]].Value;
     NewTerminalContext->ParityIndex   = NewBmmData->COMParity[Index];
-    ASSERT (NewBmmData->COMParity[Index] < (sizeof (ParityList) / sizeof (ParityList[0])));
+    ASSERT (NewBmmData->COMParity[Index] < (ARRAY_SIZE (ParityList)));
     NewTerminalContext->Parity        = (UINT8) ParityList[NewBmmData->COMParity[Index]].Value;
     NewTerminalContext->TerminalType  = NewBmmData->COMTerminalType[Index];
     NewTerminalContext->FlowControl   = NewBmmData->COMFlowControl[Index];
diff --git a/IntelFrameworkModulePkg/Universal/BdsDxe/BootMaint/BootOption.c b/IntelFrameworkModulePkg/Universal/BdsDxe/BootMaint/BootOption.c
index 56bcfab23f43..5898fb31bb2b 100644
--- a/IntelFrameworkModulePkg/Universal/BdsDxe/BootMaint/BootOption.c
+++ b/IntelFrameworkModulePkg/Universal/BdsDxe/BootMaint/BootOption.c
@@ -1702,7 +1702,7 @@ GetLegacyDeviceOrder (
   LegacyOrder = NULL;
   OldData     = NULL;
   DisMap      = ZeroMem (CallbackData->BmmFakeNvData.DisableMap, sizeof (CallbackData->BmmFakeNvData.DisableMap));
-  PageNum     = sizeof (PageIdList) / sizeof (PageIdList[0]);
+  PageNum     = ARRAY_SIZE (PageIdList);
   VarData     = BdsLibGetVariableAndSize (
                   VAR_LEGACY_DEV_ORDER,
                   &gEfiLegacyDevOrderVariableGuid,
diff --git a/IntelFrameworkModulePkg/Universal/BdsDxe/BootMaint/ConsoleOption.c b/IntelFrameworkModulePkg/Universal/BdsDxe/BootMaint/ConsoleOption.c
index 1854b98c360f..126feeb9ae51 100644
--- a/IntelFrameworkModulePkg/Universal/BdsDxe/BootMaint/ConsoleOption.c
+++ b/IntelFrameworkModulePkg/Universal/BdsDxe/BootMaint/ConsoleOption.c
@@ -1167,21 +1167,21 @@ GetTerminalAttribute (
         break;
       }
     }
-    for (AttributeIndex = 0; AttributeIndex < sizeof (DataBitsList) / sizeof (DataBitsList[0]); AttributeIndex++) {
+    for (AttributeIndex = 0; AttributeIndex < ARRAY_SIZE (DataBitsList); AttributeIndex++) {
       if (NewTerminalContext->DataBits == (UINT64) (DataBitsList[AttributeIndex].Value)) {
         NewTerminalContext->DataBitsIndex = AttributeIndex;
         break;
       }
     }    
     
-    for (AttributeIndex = 0; AttributeIndex < sizeof (ParityList) / sizeof (ParityList[0]); AttributeIndex++) {
+    for (AttributeIndex = 0; AttributeIndex < ARRAY_SIZE (ParityList); AttributeIndex++) {
       if (NewTerminalContext->Parity == (UINT64) (ParityList[AttributeIndex].Value)) {
         NewTerminalContext->ParityIndex = AttributeIndex;
         break;
       }
     }            
     
-    for (AttributeIndex = 0; AttributeIndex < sizeof (StopBitsList) / sizeof (StopBitsList[0]); AttributeIndex++) {
+    for (AttributeIndex = 0; AttributeIndex < ARRAY_SIZE (StopBitsList); AttributeIndex++) {
       if (NewTerminalContext->StopBits == (UINT64) (StopBitsList[AttributeIndex].Value)) {
         NewTerminalContext->StopBitsIndex = AttributeIndex;
         break;
diff --git a/IntelFrameworkModulePkg/Universal/BdsDxe/BootMaint/UpdatePage.c b/IntelFrameworkModulePkg/Universal/BdsDxe/BootMaint/UpdatePage.c
index b13ed116303b..02efefd2a614 100644
--- a/IntelFrameworkModulePkg/Universal/BdsDxe/BootMaint/UpdatePage.c
+++ b/IntelFrameworkModulePkg/Universal/BdsDxe/BootMaint/UpdatePage.c
@@ -830,7 +830,7 @@ UpdateConModePage (
     //
     UnicodeValueToString (ModeString, 0, Col, 0);
     PStr = &ModeString[0];
-    StrCatS (PStr, sizeof (ModeString) / sizeof (ModeString[0]), L" x ");
+    StrCatS (PStr, ARRAY_SIZE (ModeString), L" x ");
     PStr = PStr + StrLen (PStr);
     UnicodeValueToString (PStr , 0, Row, 0);
 
@@ -939,7 +939,7 @@ UpdateTerminalPage (
   OptionsOpCodeHandle = HiiAllocateOpCodeHandle ();
   ASSERT (OptionsOpCodeHandle != NULL);
 
-  for (Index = 0; Index < sizeof (DataBitsList) / sizeof (DataBitsList[0]); Index++) {
+  for (Index = 0; Index < ARRAY_SIZE (DataBitsList); Index++) {
     CheckFlags = 0;
 
     if (DataBitsList[Index].Value == 8) {
@@ -972,7 +972,7 @@ UpdateTerminalPage (
   OptionsOpCodeHandle = HiiAllocateOpCodeHandle ();
   ASSERT (OptionsOpCodeHandle != NULL);
 
-  for (Index = 0; Index < sizeof (ParityList) / sizeof (ParityList[0]); Index++) {
+  for (Index = 0; Index < ARRAY_SIZE (ParityList); Index++) {
     CheckFlags = 0;
     if (ParityList[Index].Value ==  NoParity) {
       CheckFlags |= EFI_IFR_OPTION_DEFAULT;
@@ -1004,7 +1004,7 @@ UpdateTerminalPage (
   OptionsOpCodeHandle = HiiAllocateOpCodeHandle ();
   ASSERT (OptionsOpCodeHandle != NULL);
 
-  for (Index = 0; Index < sizeof (StopBitsList) / sizeof (StopBitsList[0]); Index++) {
+  for (Index = 0; Index < ARRAY_SIZE (StopBitsList); Index++) {
     CheckFlags = 0;
     if (StopBitsList[Index].Value == OneStopBit) {
       CheckFlags |= EFI_IFR_OPTION_DEFAULT;
@@ -1068,7 +1068,7 @@ UpdateTerminalPage (
   OptionsOpCodeHandle = HiiAllocateOpCodeHandle ();
   ASSERT (OptionsOpCodeHandle != NULL);
 
-  for (Index = 0; Index < sizeof (mFlowControlType) / sizeof (mFlowControlType[0]); Index++) {
+  for (Index = 0; Index < ARRAY_SIZE (mFlowControlType); Index++) {
   CheckFlags = 0;
     if (Index == 0) {
       CheckFlags |= EFI_IFR_OPTION_DEFAULT;
diff --git a/IntelFrameworkModulePkg/Universal/BdsDxe/BootMaint/Variable.c b/IntelFrameworkModulePkg/Universal/BdsDxe/BootMaint/Variable.c
index b933dd9699cb..414367cf2387 100644
--- a/IntelFrameworkModulePkg/Universal/BdsDxe/BootMaint/Variable.c
+++ b/IntelFrameworkModulePkg/Universal/BdsDxe/BootMaint/Variable.c
@@ -448,7 +448,7 @@ Var_UpdateConsoleOption (
       Vendor.Header.Type    = MESSAGING_DEVICE_PATH;
       Vendor.Header.SubType = MSG_VENDOR_DP;
       
-      ASSERT (NewTerminalContext->TerminalType < (sizeof (TerminalTypeGuid) / sizeof (TerminalTypeGuid[0])));
+      ASSERT (NewTerminalContext->TerminalType < (ARRAY_SIZE (TerminalTypeGuid)));
       CopyMem (
         &Vendor.Guid,
         &TerminalTypeGuid[NewTerminalContext->TerminalType],
diff --git a/IntelFrameworkModulePkg/Universal/BdsDxe/BootMngr/BootManager.c b/IntelFrameworkModulePkg/Universal/BdsDxe/BootMngr/BootManager.c
index 6efd783ab219..9ee063859ce1 100644
--- a/IntelFrameworkModulePkg/Universal/BdsDxe/BootMngr/BootManager.c
+++ b/IntelFrameworkModulePkg/Universal/BdsDxe/BootMngr/BootManager.c
@@ -305,7 +305,7 @@ CallBootManager (
                      HiiHandle,
                      0,
                      mDeviceTypeStr[
-                       MIN (DeviceType & 0xF, sizeof (mDeviceTypeStr) / sizeof (mDeviceTypeStr[0]) - 1)
+                       MIN (DeviceType & 0xF, ARRAY_SIZE (mDeviceTypeStr) - 1)
                        ],
                      NULL
                      );
-- 
2.9.2




^ permalink raw reply related	[flat|nested] 98+ messages in thread

* [PATCH 17/47] MdeModulePkg/MemoryProfileInfo: rebase to ARRAY_SIZE()
  2016-10-26 19:04 [PATCH 00/47] edk2: centralize and adopt ARRAY_SIZE() Laszlo Ersek
                   ` (15 preceding siblings ...)
  2016-10-26 19:04 ` [PATCH 16/47] IntelFrameworkModulePkg/BdsDxe: " Laszlo Ersek
@ 2016-10-26 19:04 ` Laszlo Ersek
  2016-10-26 19:04 ` [PATCH 18/47] MdeModulePkg/PciBusDxe: " Laszlo Ersek
                   ` (34 subsequent siblings)
  51 siblings, 0 replies; 98+ messages in thread
From: Laszlo Ersek @ 2016-10-26 19:04 UTC (permalink / raw)
  To: edk2-devel-01; +Cc: Feng Tian, Star Zeng

Cc: Feng Tian <feng.tian@intel.com>
Cc: Star Zeng <star.zeng@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Laszlo Ersek <lersek@redhat.com>
---
 MdeModulePkg/Application/MemoryProfileInfo/MemoryProfileInfo.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/MdeModulePkg/Application/MemoryProfileInfo/MemoryProfileInfo.c b/MdeModulePkg/Application/MemoryProfileInfo/MemoryProfileInfo.c
index 14e89347c6db..338eb8191fa2 100644
--- a/MdeModulePkg/Application/MemoryProfileInfo/MemoryProfileInfo.c
+++ b/MdeModulePkg/Application/MemoryProfileInfo/MemoryProfileInfo.c
@@ -343,16 +343,16 @@ ProfileActionToStr (
 
   if (IsForSmm) {
     ActionString = mSmmActionString;
-    ActionStringCount = sizeof (mSmmActionString) / sizeof (mSmmActionString[0]);
+    ActionStringCount = ARRAY_SIZE (mSmmActionString);
   } else {
     ActionString = mActionString;
-    ActionStringCount = sizeof (mActionString) / sizeof (mActionString[0]);
+    ActionStringCount = ARRAY_SIZE (mActionString);
   }
 
   if ((UINTN) (UINT32) Action < ActionStringCount) {
     return ActionString[Action];
   }
-  for (Index = 0; Index < sizeof (mExtActionString) / sizeof (mExtActionString[0]); Index++) {
+  for (Index = 0; Index < ARRAY_SIZE (mExtActionString); Index++) {
     if (mExtActionString[Index].Action == Action) {
       return mExtActionString[Index].String;
     }
-- 
2.9.2




^ permalink raw reply related	[flat|nested] 98+ messages in thread

* [PATCH 18/47] MdeModulePkg/PciBusDxe: rebase to ARRAY_SIZE()
  2016-10-26 19:04 [PATCH 00/47] edk2: centralize and adopt ARRAY_SIZE() Laszlo Ersek
                   ` (16 preceding siblings ...)
  2016-10-26 19:04 ` [PATCH 17/47] MdeModulePkg/MemoryProfileInfo: " Laszlo Ersek
@ 2016-10-26 19:04 ` Laszlo Ersek
  2016-10-27  1:53   ` Ni, Ruiyu
  2016-10-26 19:04 ` [PATCH 19/47] MdeModulePkg/PciHostBridgeDxe: " Laszlo Ersek
                   ` (33 subsequent siblings)
  51 siblings, 1 reply; 98+ messages in thread
From: Laszlo Ersek @ 2016-10-26 19:04 UTC (permalink / raw)
  To: edk2-devel-01; +Cc: Feng Tian, Ruiyu Ni, Star Zeng

Cc: Feng Tian <feng.tian@intel.com>
Cc: Ruiyu Ni <ruiyu.ni@intel.com>
Cc: Star Zeng <star.zeng@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Laszlo Ersek <lersek@redhat.com>
---
 MdeModulePkg/Bus/Pci/PciBusDxe/PciLib.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/MdeModulePkg/Bus/Pci/PciBusDxe/PciLib.c b/MdeModulePkg/Bus/Pci/PciBusDxe/PciLib.c
index 337a6db7defa..4d297fdb23c7 100644
--- a/MdeModulePkg/Bus/Pci/PciBusDxe/PciLib.c
+++ b/MdeModulePkg/Bus/Pci/PciBusDxe/PciLib.c
@@ -868,7 +868,7 @@ PciHostBridgeResourceAllocator (
       Resources[2] = PMem32Bridge;
       Resources[3] = Mem64Bridge;
       Resources[4] = PMem64Bridge;
-      DumpResourceMap (RootBridgeDev, Resources, sizeof (Resources) / sizeof (Resources[0]));
+      DumpResourceMap (RootBridgeDev, Resources, ARRAY_SIZE (Resources));
     );
 
     FreePool (AcpiConfig);
-- 
2.9.2




^ permalink raw reply related	[flat|nested] 98+ messages in thread

* [PATCH 19/47] MdeModulePkg/PciHostBridgeDxe: rebase to ARRAY_SIZE()
  2016-10-26 19:04 [PATCH 00/47] edk2: centralize and adopt ARRAY_SIZE() Laszlo Ersek
                   ` (17 preceding siblings ...)
  2016-10-26 19:04 ` [PATCH 18/47] MdeModulePkg/PciBusDxe: " Laszlo Ersek
@ 2016-10-26 19:04 ` Laszlo Ersek
  2016-10-27  1:49   ` Ni, Ruiyu
  2016-10-26 19:04 ` [PATCH 20/47] MdeModulePkg/UsbBusDxe: " Laszlo Ersek
                   ` (32 subsequent siblings)
  51 siblings, 1 reply; 98+ messages in thread
From: Laszlo Ersek @ 2016-10-26 19:04 UTC (permalink / raw)
  To: edk2-devel-01; +Cc: Feng Tian, Ruiyu Ni, Star Zeng

Cc: Feng Tian <feng.tian@intel.com>
Cc: Ruiyu Ni <ruiyu.ni@intel.com>
Cc: Star Zeng <star.zeng@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Laszlo Ersek <lersek@redhat.com>
---
 MdeModulePkg/Bus/Pci/PciHostBridgeDxe/PciHostBridge.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/MdeModulePkg/Bus/Pci/PciHostBridgeDxe/PciHostBridge.c b/MdeModulePkg/Bus/Pci/PciHostBridgeDxe/PciHostBridge.c
index c866e8801607..9005deeac225 100644
--- a/MdeModulePkg/Bus/Pci/PciHostBridgeDxe/PciHostBridge.c
+++ b/MdeModulePkg/Bus/Pci/PciHostBridgeDxe/PciHostBridge.c
@@ -415,7 +415,7 @@ InitializePciHostBridge (
     MemApertures[2] = &RootBridges[Index].PMem;
     MemApertures[3] = &RootBridges[Index].PMemAbove4G;
 
-    for (MemApertureIndex = 0; MemApertureIndex < sizeof (MemApertures) / sizeof (MemApertures[0]); MemApertureIndex++) {
+    for (MemApertureIndex = 0; MemApertureIndex < ARRAY_SIZE (MemApertures); MemApertureIndex++) {
       if (MemApertures[MemApertureIndex]->Base <= MemApertures[MemApertureIndex]->Limit) {
         Status = AddMemoryMappedIoSpace (
                    MemApertures[MemApertureIndex]->Base,
-- 
2.9.2




^ permalink raw reply related	[flat|nested] 98+ messages in thread

* [PATCH 20/47] MdeModulePkg/UsbBusDxe: rebase to ARRAY_SIZE()
  2016-10-26 19:04 [PATCH 00/47] edk2: centralize and adopt ARRAY_SIZE() Laszlo Ersek
                   ` (18 preceding siblings ...)
  2016-10-26 19:04 ` [PATCH 19/47] MdeModulePkg/PciHostBridgeDxe: " Laszlo Ersek
@ 2016-10-26 19:04 ` Laszlo Ersek
  2016-10-26 19:04 ` [PATCH 21/47] MdeModulePkg/Core/Dxe: " Laszlo Ersek
                   ` (31 subsequent siblings)
  51 siblings, 0 replies; 98+ messages in thread
From: Laszlo Ersek @ 2016-10-26 19:04 UTC (permalink / raw)
  To: edk2-devel-01; +Cc: Feng Tian, Star Zeng

Cc: Feng Tian <feng.tian@intel.com>
Cc: Star Zeng <star.zeng@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Laszlo Ersek <lersek@redhat.com>
---
 MdeModulePkg/Bus/Usb/UsbBusDxe/UsbHub.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/MdeModulePkg/Bus/Usb/UsbBusDxe/UsbHub.c b/MdeModulePkg/Bus/Usb/UsbBusDxe/UsbHub.c
index f51a51f191ad..fabb44157037 100644
--- a/MdeModulePkg/Bus/Usb/UsbBusDxe/UsbHub.c
+++ b/MdeModulePkg/Bus/Usb/UsbBusDxe/UsbHub.c
@@ -884,7 +884,7 @@ UsbHubClearPortChange (
   // It may lead to extra port state report. USB bus should
   // be able to handle this.
   //
-  for (Index = 0; Index < sizeof (mHubFeatureMap) / sizeof (mHubFeatureMap[0]); Index++) {
+  for (Index = 0; Index < ARRAY_SIZE (mHubFeatureMap); Index++) {
     Map = &mHubFeatureMap[Index];
 
     if (USB_BIT_IS_SET (PortState.PortChangeStatus, Map->ChangedBit)) {
@@ -1180,7 +1180,7 @@ UsbRootHubClearPortChange (
   // It may lead to extra port state report. USB bus should
   // be able to handle this.
   //
-  for (Index = 0; Index < sizeof (mRootHubFeatureMap) / sizeof (mRootHubFeatureMap[0]); Index++) {
+  for (Index = 0; Index < ARRAY_SIZE (mRootHubFeatureMap); Index++) {
     Map = &mRootHubFeatureMap[Index];
 
     if (USB_BIT_IS_SET (PortState.PortChangeStatus, Map->ChangedBit)) {
-- 
2.9.2




^ permalink raw reply related	[flat|nested] 98+ messages in thread

* [PATCH 21/47] MdeModulePkg/Core/Dxe: rebase to ARRAY_SIZE()
  2016-10-26 19:04 [PATCH 00/47] edk2: centralize and adopt ARRAY_SIZE() Laszlo Ersek
                   ` (19 preceding siblings ...)
  2016-10-26 19:04 ` [PATCH 20/47] MdeModulePkg/UsbBusDxe: " Laszlo Ersek
@ 2016-10-26 19:04 ` Laszlo Ersek
  2016-10-26 19:04 ` [PATCH 22/47] MdeModulePkg/Core/PiSmmCore: " Laszlo Ersek
                   ` (30 subsequent siblings)
  51 siblings, 0 replies; 98+ messages in thread
From: Laszlo Ersek @ 2016-10-26 19:04 UTC (permalink / raw)
  To: edk2-devel-01; +Cc: Feng Tian, Star Zeng

Cc: Feng Tian <feng.tian@intel.com>
Cc: Star Zeng <star.zeng@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Laszlo Ersek <lersek@redhat.com>
---
 MdeModulePkg/Core/Dxe/Mem/Pool.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/MdeModulePkg/Core/Dxe/Mem/Pool.c b/MdeModulePkg/Core/Dxe/Mem/Pool.c
index 6ef5fba395f5..7afd2d312c1d 100644
--- a/MdeModulePkg/Core/Dxe/Mem/Pool.c
+++ b/MdeModulePkg/Core/Dxe/Mem/Pool.c
@@ -58,7 +58,7 @@ STATIC CONST UINT16 mPoolSizeTable[] = {
 #define SIZE_TO_LIST(a)   (GetPoolIndexFromSize (a))
 #define LIST_TO_SIZE(a)   (mPoolSizeTable [a])
 
-#define MAX_POOL_LIST     (sizeof (mPoolSizeTable) / sizeof (mPoolSizeTable[0]))
+#define MAX_POOL_LIST     (ARRAY_SIZE (mPoolSizeTable))
 
 #define MAX_POOL_SIZE     (MAX_ADDRESS - POOL_OVERHEAD)
 
-- 
2.9.2




^ permalink raw reply related	[flat|nested] 98+ messages in thread

* [PATCH 22/47] MdeModulePkg/Core/PiSmmCore: rebase to ARRAY_SIZE()
  2016-10-26 19:04 [PATCH 00/47] edk2: centralize and adopt ARRAY_SIZE() Laszlo Ersek
                   ` (20 preceding siblings ...)
  2016-10-26 19:04 ` [PATCH 21/47] MdeModulePkg/Core/Dxe: " Laszlo Ersek
@ 2016-10-26 19:04 ` Laszlo Ersek
  2016-10-27  2:20   ` Kinney, Michael D
  2016-10-26 19:04 ` [PATCH 23/47] MdeModulePkg/BootMaintenanceManagerUiLib: " Laszlo Ersek
                   ` (29 subsequent siblings)
  51 siblings, 1 reply; 98+ messages in thread
From: Laszlo Ersek @ 2016-10-26 19:04 UTC (permalink / raw)
  To: edk2-devel-01; +Cc: Feng Tian, Michael D Kinney, Star Zeng

Cc: Feng Tian <feng.tian@intel.com>
Cc: Michael D Kinney <michael.d.kinney@intel.com>
Cc: Star Zeng <star.zeng@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Laszlo Ersek <lersek@redhat.com>
---
 MdeModulePkg/Core/PiSmmCore/Pool.c               | 2 +-
 MdeModulePkg/Core/PiSmmCore/SmramProfileRecord.c | 6 +++---
 2 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/MdeModulePkg/Core/PiSmmCore/Pool.c b/MdeModulePkg/Core/PiSmmCore/Pool.c
index 9d447025883d..02dab0142560 100644
--- a/MdeModulePkg/Core/PiSmmCore/Pool.c
+++ b/MdeModulePkg/Core/PiSmmCore/Pool.c
@@ -42,7 +42,7 @@ SmmInitializeMemoryServices (
   //
   // Initialize Pool list
   //
-  for (Index = sizeof (mSmmPoolLists) / sizeof (*mSmmPoolLists); Index > 0;) {
+  for (Index = ARRAY_SIZE (mSmmPoolLists); Index > 0;) {
     InitializeListHead (&mSmmPoolLists[--Index]);
   }
   CurrentSmramRangesIndex = 0;
diff --git a/MdeModulePkg/Core/PiSmmCore/SmramProfileRecord.c b/MdeModulePkg/Core/PiSmmCore/SmramProfileRecord.c
index 93585f199df9..d983cefbb3dc 100644
--- a/MdeModulePkg/Core/PiSmmCore/SmramProfileRecord.c
+++ b/MdeModulePkg/Core/PiSmmCore/SmramProfileRecord.c
@@ -2670,7 +2670,7 @@ ProfileMemoryTypeToStr (
   )
 {
   UINTN     Index;
-  for (Index = 0; Index < sizeof (mMemoryTypeString) / sizeof (mMemoryTypeString[0]); Index++) {
+  for (Index = 0; Index < ARRAY_SIZE (mMemoryTypeString); Index++) {
     if (mMemoryTypeString[Index].MemoryType == MemoryType) {
       return mMemoryTypeString[Index].MemoryTypeStr;
     }
@@ -2697,12 +2697,12 @@ ProfileActionToStr (
   CHAR8     **ActionString;
 
   ActionString = mSmmActionString;
-  ActionStringCount = sizeof (mSmmActionString) / sizeof (mSmmActionString[0]);
+  ActionStringCount = ARRAY_SIZE (mSmmActionString);
 
   if ((UINTN) (UINT32) Action < ActionStringCount) {
     return ActionString[Action];
   }
-  for (Index = 0; Index < sizeof (mExtActionString) / sizeof (mExtActionString[0]); Index++) {
+  for (Index = 0; Index < ARRAY_SIZE (mExtActionString); Index++) {
     if (mExtActionString[Index].Action == Action) {
       return mExtActionString[Index].String;
     }
-- 
2.9.2




^ permalink raw reply related	[flat|nested] 98+ messages in thread

* [PATCH 23/47] MdeModulePkg/BootMaintenanceManagerUiLib: rebase to ARRAY_SIZE()
  2016-10-26 19:04 [PATCH 00/47] edk2: centralize and adopt ARRAY_SIZE() Laszlo Ersek
                   ` (21 preceding siblings ...)
  2016-10-26 19:04 ` [PATCH 22/47] MdeModulePkg/Core/PiSmmCore: " Laszlo Ersek
@ 2016-10-26 19:04 ` Laszlo Ersek
  2016-10-26 19:04 ` [PATCH 24/47] MdeModulePkg/BootManagerUiLib: " Laszlo Ersek
                   ` (28 subsequent siblings)
  51 siblings, 0 replies; 98+ messages in thread
From: Laszlo Ersek @ 2016-10-26 19:04 UTC (permalink / raw)
  To: edk2-devel-01; +Cc: Dandan Bi, Eric Dong, Feng Tian, Star Zeng

Cc: Dandan Bi <dandan.bi@intel.com>
Cc: Eric Dong <eric.dong@intel.com>
Cc: Feng Tian <feng.tian@intel.com>
Cc: Star Zeng <star.zeng@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Laszlo Ersek <lersek@redhat.com>
---
 MdeModulePkg/Library/BootMaintenanceManagerUiLib/BootMaintenance.c |  8 ++++----
 MdeModulePkg/Library/BootMaintenanceManagerUiLib/ConsoleOption.c   |  8 ++++----
 MdeModulePkg/Library/BootMaintenanceManagerUiLib/UpdatePage.c      | 12 ++++++------
 MdeModulePkg/Library/BootMaintenanceManagerUiLib/Variable.c        |  2 +-
 4 files changed, 15 insertions(+), 15 deletions(-)

diff --git a/MdeModulePkg/Library/BootMaintenanceManagerUiLib/BootMaintenance.c b/MdeModulePkg/Library/BootMaintenanceManagerUiLib/BootMaintenance.c
index 33c85b7d8599..5cccbf6de15d 100644
--- a/MdeModulePkg/Library/BootMaintenanceManagerUiLib/BootMaintenance.c
+++ b/MdeModulePkg/Library/BootMaintenanceManagerUiLib/BootMaintenance.c
@@ -548,16 +548,16 @@ UpdateTerminalContent (
     ASSERT (NewMenuEntry != NULL);
     NewTerminalContext = (BM_TERMINAL_CONTEXT *) NewMenuEntry->VariableContext;
     NewTerminalContext->BaudRateIndex = BmmData->COMBaudRate[Index];
-    ASSERT (BmmData->COMBaudRate[Index] < (sizeof (BaudRateList) / sizeof (BaudRateList[0])));
+    ASSERT (BmmData->COMBaudRate[Index] < (ARRAY_SIZE (BaudRateList)));
     NewTerminalContext->BaudRate      = BaudRateList[BmmData->COMBaudRate[Index]].Value;
     NewTerminalContext->DataBitsIndex = BmmData->COMDataRate[Index];
-    ASSERT (BmmData->COMDataRate[Index] < (sizeof (DataBitsList) / sizeof (DataBitsList[0])));
+    ASSERT (BmmData->COMDataRate[Index] < (ARRAY_SIZE (DataBitsList)));
     NewTerminalContext->DataBits      = (UINT8) DataBitsList[BmmData->COMDataRate[Index]].Value;
     NewTerminalContext->StopBitsIndex = BmmData->COMStopBits[Index];
-    ASSERT (BmmData->COMStopBits[Index] < (sizeof (StopBitsList) / sizeof (StopBitsList[0])));
+    ASSERT (BmmData->COMStopBits[Index] < (ARRAY_SIZE (StopBitsList)));
     NewTerminalContext->StopBits      = (UINT8) StopBitsList[BmmData->COMStopBits[Index]].Value;
     NewTerminalContext->ParityIndex   = BmmData->COMParity[Index];
-    ASSERT (BmmData->COMParity[Index] < (sizeof (ParityList) / sizeof (ParityList[0])));
+    ASSERT (BmmData->COMParity[Index] < (ARRAY_SIZE (ParityList)));
     NewTerminalContext->Parity        = (UINT8) ParityList[BmmData->COMParity[Index]].Value;
     NewTerminalContext->TerminalType  = BmmData->COMTerminalType[Index];
     NewTerminalContext->FlowControl   = BmmData->COMFlowControl[Index];
diff --git a/MdeModulePkg/Library/BootMaintenanceManagerUiLib/ConsoleOption.c b/MdeModulePkg/Library/BootMaintenanceManagerUiLib/ConsoleOption.c
index fd48d5d4cdb0..a145a77c70a1 100644
--- a/MdeModulePkg/Library/BootMaintenanceManagerUiLib/ConsoleOption.c
+++ b/MdeModulePkg/Library/BootMaintenanceManagerUiLib/ConsoleOption.c
@@ -567,7 +567,7 @@ LocateSerialIo (
     Vendor.Header.Type                = MESSAGING_DEVICE_PATH;
     Vendor.Header.SubType             = MSG_VENDOR_DP;
 
-    for (Index2 = 0; Index2 < (sizeof (TerminalTypeGuid) / sizeof (TerminalTypeGuid[0])); Index2++) {
+    for (Index2 = 0; Index2 < (ARRAY_SIZE (TerminalTypeGuid)); Index2++) {
       CopyMem (&Vendor.Guid, &TerminalTypeGuid[Index2], sizeof (EFI_GUID));
       SetDevicePathNodeLength (&Vendor.Header, sizeof (VENDOR_DEVICE_PATH));
       NewDevicePath = AppendDevicePathNode (
@@ -1131,21 +1131,21 @@ GetTerminalAttribute (
         break;
       }
     }
-    for (AttributeIndex = 0; AttributeIndex < sizeof (DataBitsList) / sizeof (DataBitsList[0]); AttributeIndex++) {
+    for (AttributeIndex = 0; AttributeIndex < ARRAY_SIZE (DataBitsList); AttributeIndex++) {
       if (NewTerminalContext->DataBits == (UINT64) (DataBitsList[AttributeIndex].Value)) {
         NewTerminalContext->DataBitsIndex = AttributeIndex;
         break;
       }
     }    
 
-    for (AttributeIndex = 0; AttributeIndex < sizeof (ParityList) / sizeof (ParityList[0]); AttributeIndex++) {
+    for (AttributeIndex = 0; AttributeIndex < ARRAY_SIZE (ParityList); AttributeIndex++) {
       if (NewTerminalContext->Parity == (UINT64) (ParityList[AttributeIndex].Value)) {
         NewTerminalContext->ParityIndex = AttributeIndex;
         break;
       }
     }
 
-    for (AttributeIndex = 0; AttributeIndex < sizeof (StopBitsList) / sizeof (StopBitsList[0]); AttributeIndex++) {
+    for (AttributeIndex = 0; AttributeIndex < ARRAY_SIZE (StopBitsList); AttributeIndex++) {
       if (NewTerminalContext->StopBits == (UINT64) (StopBitsList[AttributeIndex].Value)) {
         NewTerminalContext->StopBitsIndex = AttributeIndex;
         break;
diff --git a/MdeModulePkg/Library/BootMaintenanceManagerUiLib/UpdatePage.c b/MdeModulePkg/Library/BootMaintenanceManagerUiLib/UpdatePage.c
index 8194979477ba..dede4b392f15 100644
--- a/MdeModulePkg/Library/BootMaintenanceManagerUiLib/UpdatePage.c
+++ b/MdeModulePkg/Library/BootMaintenanceManagerUiLib/UpdatePage.c
@@ -736,7 +736,7 @@ UpdateConModePage (
     //
     UnicodeValueToString (ModeString, 0, Col, 0);
     PStr = &ModeString[0];
-    StrnCatS (PStr, sizeof (ModeString) / sizeof (ModeString[0]), L" x ", StrLen(L" x ") + 1);
+    StrnCatS (PStr, ARRAY_SIZE (ModeString), L" x ", StrLen(L" x ") + 1);
     PStr = PStr + StrLen (PStr);
     UnicodeValueToString (PStr , 0, Row, 0);
 
@@ -847,7 +847,7 @@ UpdateTerminalPage (
   OptionsOpCodeHandle = HiiAllocateOpCodeHandle ();
   ASSERT (OptionsOpCodeHandle != NULL);
 
-  for (Index = 0; Index < sizeof (DataBitsList) / sizeof (DataBitsList[0]); Index++) {
+  for (Index = 0; Index < ARRAY_SIZE (DataBitsList); Index++) {
     CheckFlags = 0;
 
     if (DataBitsList[Index].Value == 8) {
@@ -880,7 +880,7 @@ UpdateTerminalPage (
   OptionsOpCodeHandle = HiiAllocateOpCodeHandle ();
   ASSERT (OptionsOpCodeHandle != NULL);
 
-  for (Index = 0; Index < sizeof (ParityList) / sizeof (ParityList[0]); Index++) {
+  for (Index = 0; Index < ARRAY_SIZE (ParityList); Index++) {
     CheckFlags = 0;
     if (ParityList[Index].Value ==  NoParity) {
       CheckFlags |= EFI_IFR_OPTION_DEFAULT;
@@ -912,7 +912,7 @@ UpdateTerminalPage (
   OptionsOpCodeHandle = HiiAllocateOpCodeHandle ();
   ASSERT (OptionsOpCodeHandle != NULL);
 
-  for (Index = 0; Index < sizeof (StopBitsList) / sizeof (StopBitsList[0]); Index++) {
+  for (Index = 0; Index < ARRAY_SIZE (StopBitsList); Index++) {
     CheckFlags = 0;
     if (StopBitsList[Index].Value == OneStopBit) {
       CheckFlags |= EFI_IFR_OPTION_DEFAULT;
@@ -944,7 +944,7 @@ UpdateTerminalPage (
   OptionsOpCodeHandle = HiiAllocateOpCodeHandle ();
   ASSERT (OptionsOpCodeHandle != NULL);
 
-  for (Index = 0; Index < sizeof (TerminalType) / sizeof (TerminalType[0]); Index++) {
+  for (Index = 0; Index < ARRAY_SIZE (TerminalType); Index++) {
     CheckFlags = 0;
     if (Index == 0) {
       CheckFlags |= EFI_IFR_OPTION_DEFAULT;
@@ -976,7 +976,7 @@ UpdateTerminalPage (
   OptionsOpCodeHandle = HiiAllocateOpCodeHandle ();
   ASSERT (OptionsOpCodeHandle != NULL);
 
-  for (Index = 0; Index < sizeof (mFlowControlType) / sizeof (mFlowControlType[0]); Index++) {
+  for (Index = 0; Index < ARRAY_SIZE (mFlowControlType); Index++) {
   CheckFlags = 0;
     if (Index == 0) {
       CheckFlags |= EFI_IFR_OPTION_DEFAULT;
diff --git a/MdeModulePkg/Library/BootMaintenanceManagerUiLib/Variable.c b/MdeModulePkg/Library/BootMaintenanceManagerUiLib/Variable.c
index a2ae2a773666..746b2335edc5 100644
--- a/MdeModulePkg/Library/BootMaintenanceManagerUiLib/Variable.c
+++ b/MdeModulePkg/Library/BootMaintenanceManagerUiLib/Variable.c
@@ -371,7 +371,7 @@ Var_UpdateConsoleOption (
       Vendor.Header.Type    = MESSAGING_DEVICE_PATH;
       Vendor.Header.SubType = MSG_VENDOR_DP;
       
-      ASSERT (NewTerminalContext->TerminalType < (sizeof (TerminalTypeGuid) / sizeof (TerminalTypeGuid[0])));
+      ASSERT (NewTerminalContext->TerminalType < (ARRAY_SIZE (TerminalTypeGuid)));
       CopyMem (
         &Vendor.Guid,
         &TerminalTypeGuid[NewTerminalContext->TerminalType],
-- 
2.9.2




^ permalink raw reply related	[flat|nested] 98+ messages in thread

* [PATCH 24/47] MdeModulePkg/BootManagerUiLib: rebase to ARRAY_SIZE()
  2016-10-26 19:04 [PATCH 00/47] edk2: centralize and adopt ARRAY_SIZE() Laszlo Ersek
                   ` (22 preceding siblings ...)
  2016-10-26 19:04 ` [PATCH 23/47] MdeModulePkg/BootMaintenanceManagerUiLib: " Laszlo Ersek
@ 2016-10-26 19:04 ` Laszlo Ersek
  2016-10-26 19:04 ` [PATCH 25/47] MdeModulePkg/UefiBootManagerLib: " Laszlo Ersek
                   ` (27 subsequent siblings)
  51 siblings, 0 replies; 98+ messages in thread
From: Laszlo Ersek @ 2016-10-26 19:04 UTC (permalink / raw)
  To: edk2-devel-01; +Cc: Dandan Bi, Eric Dong, Feng Tian, Star Zeng

Cc: Dandan Bi <dandan.bi@intel.com>
Cc: Eric Dong <eric.dong@intel.com>
Cc: Feng Tian <feng.tian@intel.com>
Cc: Star Zeng <star.zeng@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Laszlo Ersek <lersek@redhat.com>
---
 MdeModulePkg/Library/BootManagerUiLib/BootManager.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/MdeModulePkg/Library/BootManagerUiLib/BootManager.c b/MdeModulePkg/Library/BootManagerUiLib/BootManager.c
index cab38ca28087..bf872f867e08 100644
--- a/MdeModulePkg/Library/BootManagerUiLib/BootManager.c
+++ b/MdeModulePkg/Library/BootManagerUiLib/BootManager.c
@@ -343,7 +343,7 @@ GroupMultipleLegacyBootOption4SameType (
       // Legacy Boot Option
       //
       DEBUG ((EFI_D_ERROR, "[BootManagerDxe] ==== Find Legacy Boot Option  0x%x! ==== \n", Index));
-      ASSERT ((((BBS_BBS_DEVICE_PATH *) BootOption.FilePath)->DeviceType & 0xF) < sizeof (DeviceTypeIndex) / sizeof (DeviceTypeIndex[0]));
+      ASSERT ((((BBS_BBS_DEVICE_PATH *) BootOption.FilePath)->DeviceType & 0xF) < ARRAY_SIZE (DeviceTypeIndex));
       NextIndex = &DeviceTypeIndex[((BBS_BBS_DEVICE_PATH *) BootOption.FilePath)->DeviceType & 0xF];
 
       if (*NextIndex == (UINTN) -1) {
@@ -362,7 +362,7 @@ GroupMultipleLegacyBootOption4SameType (
         //
         // Update the DeviceTypeIndex array to reflect the right shift operation
         //
-        for (DeviceIndex = 0; DeviceIndex < sizeof (DeviceTypeIndex) / sizeof (DeviceTypeIndex[0]); DeviceIndex++) {
+        for (DeviceIndex = 0; DeviceIndex < ARRAY_SIZE (DeviceTypeIndex); DeviceIndex++) {
           if (DeviceTypeIndex[DeviceIndex] != (UINTN) -1 && DeviceTypeIndex[DeviceIndex] >= *NextIndex) {
             DeviceTypeIndex[DeviceIndex]++;
           }
@@ -526,7 +526,7 @@ UpdateBootManager (
                      HiiHandle,
                      0,
                      mDeviceTypeStr[
-                       MIN (DeviceType & 0xF, sizeof (mDeviceTypeStr) / sizeof (mDeviceTypeStr[0]) - 1)
+                       MIN (DeviceType & 0xF, ARRAY_SIZE (mDeviceTypeStr) - 1)
                        ],
                      NULL
                      );
-- 
2.9.2




^ permalink raw reply related	[flat|nested] 98+ messages in thread

* [PATCH 25/47] MdeModulePkg/UefiBootManagerLib: rebase to ARRAY_SIZE()
  2016-10-26 19:04 [PATCH 00/47] edk2: centralize and adopt ARRAY_SIZE() Laszlo Ersek
                   ` (23 preceding siblings ...)
  2016-10-26 19:04 ` [PATCH 24/47] MdeModulePkg/BootManagerUiLib: " Laszlo Ersek
@ 2016-10-26 19:04 ` Laszlo Ersek
  2016-10-27  1:50   ` Ni, Ruiyu
  2016-10-26 19:04 ` [PATCH 26/47] MdeModulePkg/VarCheckHiiLib: " Laszlo Ersek
                   ` (26 subsequent siblings)
  51 siblings, 1 reply; 98+ messages in thread
From: Laszlo Ersek @ 2016-10-26 19:04 UTC (permalink / raw)
  To: edk2-devel-01; +Cc: Feng Tian, Ruiyu Ni, Star Zeng

Cc: Feng Tian <feng.tian@intel.com>
Cc: Ruiyu Ni <ruiyu.ni@intel.com>
Cc: Star Zeng <star.zeng@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Laszlo Ersek <lersek@redhat.com>
---
 MdeModulePkg/Library/UefiBootManagerLib/BmBootDescription.c | 2 +-
 MdeModulePkg/Library/UefiBootManagerLib/BmConsole.c         | 2 +-
 MdeModulePkg/Library/UefiBootManagerLib/BmHotkey.c          | 2 +-
 MdeModulePkg/Library/UefiBootManagerLib/BmLoadOption.c      | 4 ++--
 4 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/MdeModulePkg/Library/UefiBootManagerLib/BmBootDescription.c b/MdeModulePkg/Library/UefiBootManagerLib/BmBootDescription.c
index f086764f24da..050647d8f186 100644
--- a/MdeModulePkg/Library/UefiBootManagerLib/BmBootDescription.c
+++ b/MdeModulePkg/Library/UefiBootManagerLib/BmBootDescription.c
@@ -632,7 +632,7 @@ BmGetBootDescription (
   // Firstly get the default boot description
   //
   DefaultDescription = NULL;
-  for (Index = 0; Index < sizeof (mBmBootDescriptionHandlers) / sizeof (mBmBootDescriptionHandlers[0]); Index++) {
+  for (Index = 0; Index < ARRAY_SIZE (mBmBootDescriptionHandlers); Index++) {
     DefaultDescription = mBmBootDescriptionHandlers[Index] (Handle);
     if (DefaultDescription != NULL) {
       //
diff --git a/MdeModulePkg/Library/UefiBootManagerLib/BmConsole.c b/MdeModulePkg/Library/UefiBootManagerLib/BmConsole.c
index a13917bd0844..43895e10f85b 100644
--- a/MdeModulePkg/Library/UefiBootManagerLib/BmConsole.c
+++ b/MdeModulePkg/Library/UefiBootManagerLib/BmConsole.c
@@ -430,7 +430,7 @@ EfiBootManagerUpdateConsoleVariable (
   EFI_DEVICE_PATH_PROTOCOL  *NewDevicePath;
   EFI_DEVICE_PATH_PROTOCOL  *TempNewDevicePath;
 
-  if (ConsoleType >= sizeof (mConVarName) / sizeof (mConVarName[0])) {
+  if (ConsoleType >= ARRAY_SIZE (mConVarName)) {
     return EFI_INVALID_PARAMETER;
   }
 
diff --git a/MdeModulePkg/Library/UefiBootManagerLib/BmHotkey.c b/MdeModulePkg/Library/UefiBootManagerLib/BmHotkey.c
index 55df7e9a5f31..35131a94f61d 100644
--- a/MdeModulePkg/Library/UefiBootManagerLib/BmHotkey.c
+++ b/MdeModulePkg/Library/UefiBootManagerLib/BmHotkey.c
@@ -680,7 +680,7 @@ BmProcessKeyOption (
 
   KeyShiftStateCount = 0;
   BmGenerateKeyShiftState (0, KeyOption, EFI_SHIFT_STATE_VALID, KeyShiftStates, &KeyShiftStateCount);
-  ASSERT (KeyShiftStateCount <= sizeof (KeyShiftStates) / sizeof (KeyShiftStates[0]));
+  ASSERT (KeyShiftStateCount <= ARRAY_SIZE (KeyShiftStates));
 
   EfiAcquireLock (&mBmHotkeyLock);
 
diff --git a/MdeModulePkg/Library/UefiBootManagerLib/BmLoadOption.c b/MdeModulePkg/Library/UefiBootManagerLib/BmLoadOption.c
index 9af98de0afaf..e638e5fc67e6 100644
--- a/MdeModulePkg/Library/UefiBootManagerLib/BmLoadOption.c
+++ b/MdeModulePkg/Library/UefiBootManagerLib/BmLoadOption.c
@@ -796,7 +796,7 @@ EfiBootManagerIsValidLoadOptionVariableName (
     return FALSE;
   }
 
-  for (Index = 0; Index < sizeof (mBmLoadOptionName) / sizeof (mBmLoadOptionName[0]); Index++) {
+  for (Index = 0; Index < ARRAY_SIZE (mBmLoadOptionName); Index++) {
     if ((VariableNameLen - 4 == StrLen (mBmLoadOptionName[Index])) &&
         (StrnCmp (VariableName, mBmLoadOptionName[Index], VariableNameLen - 4) == 0)
         ) {
@@ -804,7 +804,7 @@ EfiBootManagerIsValidLoadOptionVariableName (
     }
   }
 
-  if (Index == sizeof (mBmLoadOptionName) / sizeof (mBmLoadOptionName[0])) {
+  if (Index == ARRAY_SIZE (mBmLoadOptionName)) {
     return FALSE;
   }
 
-- 
2.9.2




^ permalink raw reply related	[flat|nested] 98+ messages in thread

* [PATCH 26/47] MdeModulePkg/VarCheckHiiLib: rebase to ARRAY_SIZE()
  2016-10-26 19:04 [PATCH 00/47] edk2: centralize and adopt ARRAY_SIZE() Laszlo Ersek
                   ` (24 preceding siblings ...)
  2016-10-26 19:04 ` [PATCH 25/47] MdeModulePkg/UefiBootManagerLib: " Laszlo Ersek
@ 2016-10-26 19:04 ` Laszlo Ersek
  2016-10-26 19:04 ` [PATCH 27/47] MdeModulePkg/Logo: " Laszlo Ersek
                   ` (25 subsequent siblings)
  51 siblings, 0 replies; 98+ messages in thread
From: Laszlo Ersek @ 2016-10-26 19:04 UTC (permalink / raw)
  To: edk2-devel-01; +Cc: Feng Tian, Star Zeng

Cc: Feng Tian <feng.tian@intel.com>
Cc: Star Zeng <star.zeng@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Laszlo Ersek <lersek@redhat.com>
---
 MdeModulePkg/Library/VarCheckHiiLib/VarCheckHiiGen.c          | 4 ++--
 MdeModulePkg/Library/VarCheckHiiLib/VarCheckHiiLibNullClass.c | 2 +-
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/MdeModulePkg/Library/VarCheckHiiLib/VarCheckHiiGen.c b/MdeModulePkg/Library/VarCheckHiiLib/VarCheckHiiGen.c
index cab92967aa9a..dc1f88a07cce 100644
--- a/MdeModulePkg/Library/VarCheckHiiLib/VarCheckHiiGen.c
+++ b/MdeModulePkg/Library/VarCheckHiiLib/VarCheckHiiGen.c
@@ -57,7 +57,7 @@ IfrOpCodeToStr (
   )
 {
   UINTN  Index;
-  for (Index = 0; Index < sizeof (mIfrOpCodeStringTable) / sizeof (mIfrOpCodeStringTable[0]); Index++) {
+  for (Index = 0; Index < ARRAY_SIZE (mIfrOpCodeStringTable); Index++) {
     if (mIfrOpCodeStringTable[Index].HiiOpCode == IfrOpCode) {
       return mIfrOpCodeStringTable[Index].HiiOpCodeStr;
     }
@@ -96,7 +96,7 @@ HiiPackageTypeToStr (
   )
 {
   UINTN     Index;
-  for (Index = 0; Index < sizeof (mPackageTypeStringTable) / sizeof (mPackageTypeStringTable[0]); Index++) {
+  for (Index = 0; Index < ARRAY_SIZE (mPackageTypeStringTable); Index++) {
     if (mPackageTypeStringTable[Index].PackageType == PackageType) {
       return mPackageTypeStringTable[Index].PackageTypeStr;
     }
diff --git a/MdeModulePkg/Library/VarCheckHiiLib/VarCheckHiiLibNullClass.c b/MdeModulePkg/Library/VarCheckHiiLib/VarCheckHiiLibNullClass.c
index 3afa7962aa61..b9ca9084915b 100644
--- a/MdeModulePkg/Library/VarCheckHiiLib/VarCheckHiiLibNullClass.c
+++ b/MdeModulePkg/Library/VarCheckHiiLib/VarCheckHiiLibNullClass.c
@@ -318,7 +318,7 @@ HiiOpCodeToStr (
   )
 {
   UINTN     Index;
-  for (Index = 0; Index < sizeof (mHiiOpCodeStringTable) / sizeof (mHiiOpCodeStringTable[0]); Index++) {
+  for (Index = 0; Index < ARRAY_SIZE (mHiiOpCodeStringTable); Index++) {
     if (mHiiOpCodeStringTable[Index].HiiOpCode == HiiOpCode) {
       return mHiiOpCodeStringTable[Index].HiiOpCodeStr;
     }
-- 
2.9.2




^ permalink raw reply related	[flat|nested] 98+ messages in thread

* [PATCH 27/47] MdeModulePkg/Logo: rebase to ARRAY_SIZE()
  2016-10-26 19:04 [PATCH 00/47] edk2: centralize and adopt ARRAY_SIZE() Laszlo Ersek
                   ` (25 preceding siblings ...)
  2016-10-26 19:04 ` [PATCH 26/47] MdeModulePkg/VarCheckHiiLib: " Laszlo Ersek
@ 2016-10-26 19:04 ` Laszlo Ersek
  2016-10-27  1:53   ` Ni, Ruiyu
  2016-10-26 19:04 ` [PATCH 28/47] MdeModulePkg/BdsDxe: " Laszlo Ersek
                   ` (24 subsequent siblings)
  51 siblings, 1 reply; 98+ messages in thread
From: Laszlo Ersek @ 2016-10-26 19:04 UTC (permalink / raw)
  To: edk2-devel-01; +Cc: Feng Tian, Ruiyu Ni, Star Zeng

Cc: Feng Tian <feng.tian@intel.com>
Cc: Ruiyu Ni <ruiyu.ni@intel.com>
Cc: Star Zeng <star.zeng@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Laszlo Ersek <lersek@redhat.com>
---
 MdeModulePkg/Logo/Logo.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/MdeModulePkg/Logo/Logo.c b/MdeModulePkg/Logo/Logo.c
index f0792addd3a9..313dd4a7937d 100644
--- a/MdeModulePkg/Logo/Logo.c
+++ b/MdeModulePkg/Logo/Logo.c
@@ -69,7 +69,7 @@ GetImage (
   }
 
   Current = *Instance;
-  if (Current >= sizeof (mLogos) / sizeof (mLogos[0])) {
+  if (Current >= ARRAY_SIZE (mLogos)) {
     return EFI_NOT_FOUND;
   }
 
-- 
2.9.2




^ permalink raw reply related	[flat|nested] 98+ messages in thread

* [PATCH 28/47] MdeModulePkg/BdsDxe: rebase to ARRAY_SIZE()
  2016-10-26 19:04 [PATCH 00/47] edk2: centralize and adopt ARRAY_SIZE() Laszlo Ersek
                   ` (26 preceding siblings ...)
  2016-10-26 19:04 ` [PATCH 27/47] MdeModulePkg/Logo: " Laszlo Ersek
@ 2016-10-26 19:04 ` Laszlo Ersek
  2016-10-27  1:50   ` Ni, Ruiyu
  2016-10-27  1:50   ` Ni, Ruiyu
  2016-10-26 19:04 ` [PATCH 29/47] MdeModulePkg/DisplayEngineDxe: " Laszlo Ersek
                   ` (23 subsequent siblings)
  51 siblings, 2 replies; 98+ messages in thread
From: Laszlo Ersek @ 2016-10-26 19:04 UTC (permalink / raw)
  To: edk2-devel-01; +Cc: Feng Tian, Ruiyu Ni, Star Zeng

Cc: Feng Tian <feng.tian@intel.com>
Cc: Ruiyu Ni <ruiyu.ni@intel.com>
Cc: Star Zeng <star.zeng@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Laszlo Ersek <lersek@redhat.com>
---
 MdeModulePkg/Universal/BdsDxe/BdsEntry.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/MdeModulePkg/Universal/BdsDxe/BdsEntry.c b/MdeModulePkg/Universal/BdsDxe/BdsEntry.c
index c86cd7a576ad..aacc4a64794d 100644
--- a/MdeModulePkg/Universal/BdsDxe/BdsEntry.c
+++ b/MdeModulePkg/Universal/BdsDxe/BdsEntry.c
@@ -654,7 +654,7 @@ BdsEntry (
   Status = gBS->LocateProtocol (&gEdkiiVariableLockProtocolGuid, NULL, (VOID **) &VariableLock);
   DEBUG ((EFI_D_INFO, "[BdsDxe] Locate Variable Lock protocol - %r\n", Status));
   if (!EFI_ERROR (Status)) {
-    for (Index = 0; Index < sizeof (mReadOnlyVariables) / sizeof (mReadOnlyVariables[0]); Index++) {
+    for (Index = 0; Index < ARRAY_SIZE (mReadOnlyVariables); Index++) {
       Status = VariableLock->RequestToLock (VariableLock, mReadOnlyVariables[Index], &gEfiGlobalVariableGuid);
       ASSERT_EFI_ERROR (Status);
     }
-- 
2.9.2




^ permalink raw reply related	[flat|nested] 98+ messages in thread

* [PATCH 29/47] MdeModulePkg/DisplayEngineDxe: rebase to ARRAY_SIZE()
  2016-10-26 19:04 [PATCH 00/47] edk2: centralize and adopt ARRAY_SIZE() Laszlo Ersek
                   ` (27 preceding siblings ...)
  2016-10-26 19:04 ` [PATCH 28/47] MdeModulePkg/BdsDxe: " Laszlo Ersek
@ 2016-10-26 19:04 ` Laszlo Ersek
  2016-10-26 19:04 ` [PATCH 30/47] MdeModulePkg/EbcDxe: " Laszlo Ersek
                   ` (22 subsequent siblings)
  51 siblings, 0 replies; 98+ messages in thread
From: Laszlo Ersek @ 2016-10-26 19:04 UTC (permalink / raw)
  To: edk2-devel-01; +Cc: Dandan Bi, Eric Dong, Feng Tian, Star Zeng

Cc: Dandan Bi <dandan.bi@intel.com>
Cc: Eric Dong <eric.dong@intel.com>
Cc: Feng Tian <feng.tian@intel.com>
Cc: Star Zeng <star.zeng@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Laszlo Ersek <lersek@redhat.com>
---
 MdeModulePkg/Universal/DisplayEngineDxe/FormDisplay.c  | 4 ++--
 MdeModulePkg/Universal/DisplayEngineDxe/InputHandler.c | 6 +++---
 2 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/MdeModulePkg/Universal/DisplayEngineDxe/FormDisplay.c b/MdeModulePkg/Universal/DisplayEngineDxe/FormDisplay.c
index 8531d0ee06c6..b37c1cc2e4aa 100644
--- a/MdeModulePkg/Universal/DisplayEngineDxe/FormDisplay.c
+++ b/MdeModulePkg/Universal/DisplayEngineDxe/FormDisplay.c
@@ -49,7 +49,7 @@ SCAN_CODE_TO_SCREEN_OPERATION     gScanCodeToOperation[] = {
   }
 };
 
-UINTN mScanCodeNumber = sizeof (gScanCodeToOperation) / sizeof (gScanCodeToOperation[0]);
+UINTN mScanCodeNumber = ARRAY_SIZE (gScanCodeToOperation);
 
 SCREEN_OPERATION_T0_CONTROL_FLAG  gScreenOperationToControlFlag[] = {
   {
@@ -3248,7 +3248,7 @@ UiDisplayMenu (
       }
 
       for (Index = 0;
-           Index < sizeof (gScreenOperationToControlFlag) / sizeof (gScreenOperationToControlFlag[0]);
+           Index < ARRAY_SIZE (gScreenOperationToControlFlag);
            Index++
           ) {
         if (ScreenOperation == gScreenOperationToControlFlag[Index].ScreenOperation) {
diff --git a/MdeModulePkg/Universal/DisplayEngineDxe/InputHandler.c b/MdeModulePkg/Universal/DisplayEngineDxe/InputHandler.c
index 8e7b735c7063..400b93427caa 100644
--- a/MdeModulePkg/Universal/DisplayEngineDxe/InputHandler.c
+++ b/MdeModulePkg/Universal/DisplayEngineDxe/InputHandler.c
@@ -1070,14 +1070,14 @@ EnterCarriageReturn:
 
           if (ValidateFail) {
             UpdateStatusBar (INPUT_ERROR, TRUE);
-            ASSERT (Count < sizeof (PreviousNumber) / sizeof (PreviousNumber[0]));
+            ASSERT (Count < ARRAY_SIZE (PreviousNumber));
             EditValue = PreviousNumber[Count];
             break;
           }
         } else {
           if (EditValue > Maximum) {
             UpdateStatusBar (INPUT_ERROR, TRUE);
-            ASSERT (Count < sizeof (PreviousNumber) / sizeof (PreviousNumber[0]));
+            ASSERT (Count < ARRAY_SIZE (PreviousNumber));
             EditValue = PreviousNumber[Count];
             break;
           }
@@ -1086,7 +1086,7 @@ EnterCarriageReturn:
         UpdateStatusBar (INPUT_ERROR, FALSE);
 
         Count++;
-        ASSERT (Count < (sizeof (PreviousNumber) / sizeof (PreviousNumber[0])));
+        ASSERT (Count < (ARRAY_SIZE (PreviousNumber)));
         PreviousNumber[Count] = EditValue;
 
         gST->ConOut->SetAttribute (gST->ConOut, GetHighlightTextColor ());
-- 
2.9.2




^ permalink raw reply related	[flat|nested] 98+ messages in thread

* [PATCH 30/47] MdeModulePkg/EbcDxe: rebase to ARRAY_SIZE()
  2016-10-26 19:04 [PATCH 00/47] edk2: centralize and adopt ARRAY_SIZE() Laszlo Ersek
                   ` (28 preceding siblings ...)
  2016-10-26 19:04 ` [PATCH 29/47] MdeModulePkg/DisplayEngineDxe: " Laszlo Ersek
@ 2016-10-26 19:04 ` Laszlo Ersek
  2016-10-26 19:04 ` [PATCH 31/47] MdeModulePkg/Tcp4Dxe: " Laszlo Ersek
                   ` (21 subsequent siblings)
  51 siblings, 0 replies; 98+ messages in thread
From: Laszlo Ersek @ 2016-10-26 19:04 UTC (permalink / raw)
  To: edk2-devel-01; +Cc: Feng Tian, Star Zeng

Cc: Feng Tian <feng.tian@intel.com>
Cc: Star Zeng <star.zeng@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Laszlo Ersek <lersek@redhat.com>
---
 MdeModulePkg/Universal/EbcDxe/EbcExecute.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/MdeModulePkg/Universal/EbcDxe/EbcExecute.c b/MdeModulePkg/Universal/EbcDxe/EbcExecute.c
index 433eea250f7f..d9c17f48a038 100644
--- a/MdeModulePkg/Universal/EbcDxe/EbcExecute.c
+++ b/MdeModulePkg/Universal/EbcDxe/EbcExecute.c
@@ -4216,7 +4216,7 @@ ExecuteDataManip (
   //
   DataManipDispatchTableIndex = (Opcode & OPCODE_M_OPCODE) - OPCODE_NOT;
   if ((DataManipDispatchTableIndex < 0) ||
-      (DataManipDispatchTableIndex >= sizeof (mDataManipDispatchTable) / sizeof (mDataManipDispatchTable[0]))) {
+      (DataManipDispatchTableIndex >= ARRAY_SIZE (mDataManipDispatchTable))) {
     EbcDebugSignalException (
       EXCEPT_EBC_INVALID_OPCODE,
       EXCEPTION_FLAG_ERROR,
-- 
2.9.2




^ permalink raw reply related	[flat|nested] 98+ messages in thread

* [PATCH 31/47] MdeModulePkg/Tcp4Dxe: rebase to ARRAY_SIZE()
  2016-10-26 19:04 [PATCH 00/47] edk2: centralize and adopt ARRAY_SIZE() Laszlo Ersek
                   ` (29 preceding siblings ...)
  2016-10-26 19:04 ` [PATCH 30/47] MdeModulePkg/EbcDxe: " Laszlo Ersek
@ 2016-10-26 19:04 ` Laszlo Ersek
  2016-10-26 19:04 ` [PATCH 32/47] MdeModulePkg/Variable/RuntimeDxe: " Laszlo Ersek
                   ` (20 subsequent siblings)
  51 siblings, 0 replies; 98+ messages in thread
From: Laszlo Ersek @ 2016-10-26 19:04 UTC (permalink / raw)
  To: edk2-devel-01; +Cc: Feng Tian, Jiaxin Wu, Siyuan Fu, Star Zeng

Cc: Feng Tian <feng.tian@intel.com>
Cc: Jiaxin Wu <jiaxin.wu@intel.com>
Cc: Siyuan Fu <siyuan.fu@intel.com>
Cc: Star Zeng <star.zeng@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Laszlo Ersek <lersek@redhat.com>
---
 MdeModulePkg/Universal/Network/Tcp4Dxe/Tcp4Output.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/MdeModulePkg/Universal/Network/Tcp4Dxe/Tcp4Output.c b/MdeModulePkg/Universal/Network/Tcp4Dxe/Tcp4Output.c
index b984ac069ee2..0eec8f07b922 100644
--- a/MdeModulePkg/Universal/Network/Tcp4Dxe/Tcp4Output.c
+++ b/MdeModulePkg/Universal/Network/Tcp4Dxe/Tcp4Output.c
@@ -754,7 +754,7 @@ SEND_AGAIN:
   Len   = TcpDataToSend (Tcb, Force);
   Seq   = Tcb->SndNxt;
 
-  ASSERT ((Tcb->State) < (sizeof (mTcpOutFlag) / sizeof (mTcpOutFlag[0])));
+  ASSERT ((Tcb->State) < (ARRAY_SIZE (mTcpOutFlag)));
   Flag  = mTcpOutFlag[Tcb->State];
 
   if ((Flag & TCP_FLG_SYN) != 0) {
-- 
2.9.2




^ permalink raw reply related	[flat|nested] 98+ messages in thread

* [PATCH 32/47] MdeModulePkg/Variable/RuntimeDxe: rebase to ARRAY_SIZE()
  2016-10-26 19:04 [PATCH 00/47] edk2: centralize and adopt ARRAY_SIZE() Laszlo Ersek
                   ` (30 preceding siblings ...)
  2016-10-26 19:04 ` [PATCH 31/47] MdeModulePkg/Tcp4Dxe: " Laszlo Ersek
@ 2016-10-26 19:04 ` Laszlo Ersek
  2016-10-26 19:04 ` [PATCH 33/47] NetworkPkg/IScsiDxe: " Laszlo Ersek
                   ` (19 subsequent siblings)
  51 siblings, 0 replies; 98+ messages in thread
From: Laszlo Ersek @ 2016-10-26 19:04 UTC (permalink / raw)
  To: edk2-devel-01; +Cc: Feng Tian, Star Zeng

Cc: Feng Tian <feng.tian@intel.com>
Cc: Star Zeng <star.zeng@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Laszlo Ersek <lersek@redhat.com>
---
 MdeModulePkg/Universal/Variable/RuntimeDxe/Variable.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/MdeModulePkg/Universal/Variable/RuntimeDxe/Variable.c b/MdeModulePkg/Universal/Variable/RuntimeDxe/Variable.c
index 8a9f4482b5aa..f5b6a5f93ea6 100644
--- a/MdeModulePkg/Universal/Variable/RuntimeDxe/Variable.c
+++ b/MdeModulePkg/Universal/Variable/RuntimeDxe/Variable.c
@@ -4017,7 +4017,7 @@ VariableWriteServiceInitialize (
   }
 
   if (!EFI_ERROR (Status)) {
-    for (Index = 0; Index < sizeof (mVariableEntryProperty) / sizeof (mVariableEntryProperty[0]); Index++) {
+    for (Index = 0; Index < ARRAY_SIZE (mVariableEntryProperty); Index++) {
       VariableEntry = &mVariableEntryProperty[Index];
       Status = VarCheckLibVariablePropertySet (VariableEntry->Name, VariableEntry->Guid, &VariableEntry->VariableProperty);
       ASSERT_EFI_ERROR (Status);
-- 
2.9.2




^ permalink raw reply related	[flat|nested] 98+ messages in thread

* [PATCH 33/47] NetworkPkg/IScsiDxe: rebase to ARRAY_SIZE()
  2016-10-26 19:04 [PATCH 00/47] edk2: centralize and adopt ARRAY_SIZE() Laszlo Ersek
                   ` (31 preceding siblings ...)
  2016-10-26 19:04 ` [PATCH 32/47] MdeModulePkg/Variable/RuntimeDxe: " Laszlo Ersek
@ 2016-10-26 19:04 ` Laszlo Ersek
  2016-10-27  1:59   ` Fu, Siyuan
  2016-10-26 19:04 ` [PATCH 34/47] NetworkPkg/TcpDxe: " Laszlo Ersek
                   ` (18 subsequent siblings)
  51 siblings, 1 reply; 98+ messages in thread
From: Laszlo Ersek @ 2016-10-26 19:04 UTC (permalink / raw)
  To: edk2-devel-01; +Cc: Jiaxin Wu, Siyuan Fu

Cc: Jiaxin Wu <jiaxin.wu@intel.com>
Cc: Siyuan Fu <siyuan.fu@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Laszlo Ersek <lersek@redhat.com>
---
 NetworkPkg/IScsiDxe/IScsiConfig.c | 4 ++--
 NetworkPkg/IScsiDxe/IScsiDriver.c | 2 +-
 NetworkPkg/IScsiDxe/IScsiMisc.c   | 6 +++---
 3 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/NetworkPkg/IScsiDxe/IScsiConfig.c b/NetworkPkg/IScsiDxe/IScsiConfig.c
index 3631e72e3455..16a90a6206aa 100644
--- a/NetworkPkg/IScsiDxe/IScsiConfig.c
+++ b/NetworkPkg/IScsiDxe/IScsiConfig.c
@@ -1111,7 +1111,7 @@ IScsiConfigUpdateAttempt (
   NET_LIST_FOR_EACH (Entry, &mPrivate->AttemptConfigs) {
     AttemptConfigData = NET_LIST_USER_STRUCT (Entry, ISCSI_ATTEMPT_CONFIG_NVDATA, Link);
 
-    AsciiStrToUnicodeStrS (AttemptConfigData->AttemptName, AttemptName, sizeof (AttemptName) / sizeof (AttemptName[0]));
+    AsciiStrToUnicodeStrS (AttemptConfigData->AttemptName, AttemptName, ARRAY_SIZE (AttemptName));
     UnicodeSPrint (mPrivate->PortString, (UINTN) 128, L"Attempt %s", AttemptName);
     AttemptConfigData->AttemptTitleToken = HiiSetString (
                                              mCallbackInfo->RegisteredHandle,
@@ -1240,7 +1240,7 @@ IScsiConfigDeleteAttempts (
       mPrivate->SinglePathCount--;
     }
 
-    AsciiStrToUnicodeStrS (AttemptConfigData->MacString, MacString, sizeof (MacString) / sizeof (MacString[0]));
+    AsciiStrToUnicodeStrS (AttemptConfigData->MacString, MacString, ARRAY_SIZE (MacString));
 
     UnicodeSPrint (
       mPrivate->PortString,
diff --git a/NetworkPkg/IScsiDxe/IScsiDriver.c b/NetworkPkg/IScsiDxe/IScsiDriver.c
index 279f1c049679..ac10fa26d1b9 100644
--- a/NetworkPkg/IScsiDxe/IScsiDriver.c
+++ b/NetworkPkg/IScsiDxe/IScsiDriver.c
@@ -673,7 +673,7 @@ IScsiStart (
     Session->ConfigData = AttemptConfigData;
     Session->AuthType   = AttemptConfigData->AuthenticationType;
 
-    AsciiStrToUnicodeStrS (AttemptConfigData->MacString, MacString, sizeof (MacString) / sizeof (MacString[0]));
+    AsciiStrToUnicodeStrS (AttemptConfigData->MacString, MacString, ARRAY_SIZE (MacString));
     UnicodeSPrint (
       mPrivate->PortString,
       (UINTN) ISCSI_NAME_IFR_MAX_SIZE,
diff --git a/NetworkPkg/IScsiDxe/IScsiMisc.c b/NetworkPkg/IScsiDxe/IScsiMisc.c
index 64bb2ade7b0a..11a80f2e10e4 100644
--- a/NetworkPkg/IScsiDxe/IScsiMisc.c
+++ b/NetworkPkg/IScsiDxe/IScsiMisc.c
@@ -1109,7 +1109,7 @@ IScsiGetConfigData (
           //
           // Refresh the state of this attempt to NVR.
           //
-          AsciiStrToUnicodeStrS (AttemptTmp->MacString, MacString, sizeof (MacString) / sizeof (MacString[0]));
+          AsciiStrToUnicodeStrS (AttemptTmp->MacString, MacString, ARRAY_SIZE (MacString));
           UnicodeSPrint (
             mPrivate->PortString,
             (UINTN) ISCSI_NAME_IFR_MAX_SIZE,
@@ -1148,7 +1148,7 @@ IScsiGetConfigData (
         //
         // Refresh the state of this attempt to NVR.
         //
-        AsciiStrToUnicodeStrS (AttemptTmp->MacString, MacString, sizeof (MacString) / sizeof (MacString[0]));
+        AsciiStrToUnicodeStrS (AttemptTmp->MacString, MacString, ARRAY_SIZE (MacString));
         UnicodeSPrint (
           mPrivate->PortString,
           (UINTN) ISCSI_NAME_IFR_MAX_SIZE,
@@ -1239,7 +1239,7 @@ IScsiGetConfigData (
       //
       // Refresh the state of this attempt to NVR.
       //
-      AsciiStrToUnicodeStrS (AttemptConfigData->MacString, MacString, sizeof (MacString) / sizeof (MacString[0]));
+      AsciiStrToUnicodeStrS (AttemptConfigData->MacString, MacString, ARRAY_SIZE (MacString));
       UnicodeSPrint (
         mPrivate->PortString,
         (UINTN) ISCSI_NAME_IFR_MAX_SIZE,
-- 
2.9.2




^ permalink raw reply related	[flat|nested] 98+ messages in thread

* [PATCH 34/47] NetworkPkg/TcpDxe: rebase to ARRAY_SIZE()
  2016-10-26 19:04 [PATCH 00/47] edk2: centralize and adopt ARRAY_SIZE() Laszlo Ersek
                   ` (32 preceding siblings ...)
  2016-10-26 19:04 ` [PATCH 33/47] NetworkPkg/IScsiDxe: " Laszlo Ersek
@ 2016-10-26 19:04 ` Laszlo Ersek
  2016-10-27  2:00   ` Fu, Siyuan
  2016-10-27  2:31   ` Wu, Jiaxin
  2016-10-26 19:04 ` [PATCH 35/47] Nt32Pkg/WinNtSerialIoDxe: " Laszlo Ersek
                   ` (17 subsequent siblings)
  51 siblings, 2 replies; 98+ messages in thread
From: Laszlo Ersek @ 2016-10-26 19:04 UTC (permalink / raw)
  To: edk2-devel-01; +Cc: Siyuan Fu, Jiaxin Wu

Cc: Siyuan Fu <siyuan.fu@intel.com>
Cc: Jiaxin Wu <jiaxin.wu@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Laszlo Ersek <lersek@redhat.com>
---
 NetworkPkg/TcpDxe/TcpOutput.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/NetworkPkg/TcpDxe/TcpOutput.c b/NetworkPkg/TcpDxe/TcpOutput.c
index 91e56d369a71..a46cb6099ea8 100644
--- a/NetworkPkg/TcpDxe/TcpOutput.c
+++ b/NetworkPkg/TcpDxe/TcpOutput.c
@@ -797,7 +797,7 @@ TcpToSendData (
     Len   = TcpDataToSend (Tcb, Force);
     Seq   = Tcb->SndNxt;
 
-    ASSERT ((Tcb->State) < (sizeof (mTcpOutFlag) / sizeof (mTcpOutFlag[0])));
+    ASSERT ((Tcb->State) < (ARRAY_SIZE (mTcpOutFlag)));
     Flag  = mTcpOutFlag[Tcb->State];
 
     if ((Flag & TCP_FLG_SYN) != 0) {
-- 
2.9.2




^ permalink raw reply related	[flat|nested] 98+ messages in thread

* [PATCH 35/47] Nt32Pkg/WinNtSerialIoDxe: rebase to ARRAY_SIZE()
  2016-10-26 19:04 [PATCH 00/47] edk2: centralize and adopt ARRAY_SIZE() Laszlo Ersek
                   ` (33 preceding siblings ...)
  2016-10-26 19:04 ` [PATCH 34/47] NetworkPkg/TcpDxe: " Laszlo Ersek
@ 2016-10-26 19:04 ` Laszlo Ersek
  2016-10-27  1:49   ` Ni, Ruiyu
  2016-10-26 19:04 ` [PATCH 36/47] OptionRomPkg/AtapiPassThruDxe: " Laszlo Ersek
                   ` (16 subsequent siblings)
  51 siblings, 1 reply; 98+ messages in thread
From: Laszlo Ersek @ 2016-10-26 19:04 UTC (permalink / raw)
  To: edk2-devel-01; +Cc: Ruiyu Ni

Cc: Ruiyu Ni <ruiyu.ni@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Laszlo Ersek <lersek@redhat.com>
---
 Nt32Pkg/WinNtSerialIoDxe/WinNtSerialIo.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/Nt32Pkg/WinNtSerialIoDxe/WinNtSerialIo.c b/Nt32Pkg/WinNtSerialIoDxe/WinNtSerialIo.c
index 0dc031393e71..23d3329d9db1 100644
--- a/Nt32Pkg/WinNtSerialIoDxe/WinNtSerialIo.c
+++ b/Nt32Pkg/WinNtSerialIoDxe/WinNtSerialIo.c
@@ -984,7 +984,7 @@ Returns:
   //The lower baud rate supported by the serial device will be selected without exceeding the unsupported BaudRate parameter
   // 
   
-  for (Index = 1; Index < (sizeof (mBaudRateCurrentSupport) / sizeof (mBaudRateCurrentSupport[0])); Index++) {
+  for (Index = 1; Index < (ARRAY_SIZE (mBaudRateCurrentSupport)); Index++) {
     if (BaudRate < mBaudRateCurrentSupport[Index]) {
       BaudRate = mBaudRateCurrentSupport[Index-1];
       break;
-- 
2.9.2




^ permalink raw reply related	[flat|nested] 98+ messages in thread

* [PATCH 36/47] OptionRomPkg/AtapiPassThruDxe: rebase to ARRAY_SIZE()
  2016-10-26 19:04 [PATCH 00/47] edk2: centralize and adopt ARRAY_SIZE() Laszlo Ersek
                   ` (34 preceding siblings ...)
  2016-10-26 19:04 ` [PATCH 35/47] Nt32Pkg/WinNtSerialIoDxe: " Laszlo Ersek
@ 2016-10-26 19:04 ` Laszlo Ersek
  2016-10-27  1:47   ` Ni, Ruiyu
  2016-10-26 19:04 ` [PATCH 37/47] OvmfPkg/QemuBootOrderLib: " Laszlo Ersek
                   ` (15 subsequent siblings)
  51 siblings, 1 reply; 98+ messages in thread
From: Laszlo Ersek @ 2016-10-26 19:04 UTC (permalink / raw)
  To: edk2-devel-01; +Cc: Ruiyu Ni

Cc: Ruiyu Ni <ruiyu.ni@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Laszlo Ersek <lersek@redhat.com>
---
 OptionRomPkg/AtapiPassThruDxe/AtapiPassThru.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/OptionRomPkg/AtapiPassThruDxe/AtapiPassThru.c b/OptionRomPkg/AtapiPassThruDxe/AtapiPassThru.c
index 3578a1e4459c..e2654e5c2566 100644
--- a/OptionRomPkg/AtapiPassThruDxe/AtapiPassThru.c
+++ b/OptionRomPkg/AtapiPassThruDxe/AtapiPassThru.c
@@ -1752,7 +1752,7 @@ Returns:
   UINT8 ArrayLen;
 
   OpCode = (UINT8 *) (Packet->Cdb);
-  ArrayLen = (UINT8) (sizeof (gSupportedATAPICommands) / sizeof (gSupportedATAPICommands[0]));
+  ArrayLen = (UINT8) (ARRAY_SIZE (gSupportedATAPICommands));
 
   for (Index = 0; (Index < ArrayLen) && (CompareMem (&gSupportedATAPICommands[Index], &gEndTable, sizeof (SCSI_COMMAND_SET)) != 0); Index++) {
 
@@ -1995,7 +1995,7 @@ Returns:
   UINT8 ArrayLen;
 
   OpCode = (UINT8 *) (Packet->Cdb);
-  ArrayLen = (UINT8) (sizeof (gSupportedATAPICommands) / sizeof (gSupportedATAPICommands[0]));
+  ArrayLen = (UINT8) (ARRAY_SIZE (gSupportedATAPICommands));
 
   for (Index = 0; (Index < ArrayLen) && (CompareMem (&gSupportedATAPICommands[Index], &gEndTable, sizeof (SCSI_COMMAND_SET)) != 0); Index++) {
 
-- 
2.9.2




^ permalink raw reply related	[flat|nested] 98+ messages in thread

* [PATCH 37/47] OvmfPkg/QemuBootOrderLib: rebase to ARRAY_SIZE()
  2016-10-26 19:04 [PATCH 00/47] edk2: centralize and adopt ARRAY_SIZE() Laszlo Ersek
                   ` (35 preceding siblings ...)
  2016-10-26 19:04 ` [PATCH 36/47] OptionRomPkg/AtapiPassThruDxe: " Laszlo Ersek
@ 2016-10-26 19:04 ` Laszlo Ersek
  2016-10-26 19:04 ` [PATCH 38/47] OvmfPkg/QemuVideoDxe: " Laszlo Ersek
                   ` (14 subsequent siblings)
  51 siblings, 0 replies; 98+ messages in thread
From: Laszlo Ersek @ 2016-10-26 19:04 UTC (permalink / raw)
  To: edk2-devel-01; +Cc: Jordan Justen

Cc: Jordan Justen <jordan.l.justen@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Laszlo Ersek <lersek@redhat.com>
---
 OvmfPkg/Library/QemuBootOrderLib/QemuBootOrderLib.c | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/OvmfPkg/Library/QemuBootOrderLib/QemuBootOrderLib.c b/OvmfPkg/Library/QemuBootOrderLib/QemuBootOrderLib.c
index 8cbbdb0568fa..567f6f92f452 100644
--- a/OvmfPkg/Library/QemuBootOrderLib/QemuBootOrderLib.c
+++ b/OvmfPkg/Library/QemuBootOrderLib/QemuBootOrderLib.c
@@ -707,7 +707,7 @@ TranslatePciOfwNodes (
   // Parse the OFW nodes starting with the first non-bridge node.
   //
   PciDevFun[1] = 0;
-  NumEntries = sizeof (PciDevFun) / sizeof (PciDevFun[0]);
+  NumEntries = ARRAY_SIZE (PciDevFun);
   if (ParseUnitAddressHexList (
         OfwNode[FirstNonBridge].UnitAddress,
         PciDevFun,
@@ -910,7 +910,7 @@ TranslatePciOfwNodes (
     UINT64 TargetLun[2];
 
     TargetLun[1] = 0;
-    NumEntries = sizeof (TargetLun) / sizeof (TargetLun[0]);
+    NumEntries = ARRAY_SIZE (TargetLun);
     if (ParseUnitAddressHexList (
           OfwNode[FirstNonBridge + 2].UnitAddress,
           TargetLun,
@@ -958,7 +958,7 @@ TranslatePciOfwNodes (
     UINTN  RequiredEntries;
     UINT8  *Eui64;
 
-    RequiredEntries = sizeof (Namespace) / sizeof (Namespace[0]);
+    RequiredEntries = ARRAY_SIZE (Namespace);
     NumEntries = RequiredEntries;
     if (ParseUnitAddressHexList (
           OfwNode[FirstNonBridge + 1].UnitAddress,
@@ -1145,7 +1145,7 @@ TranslateMmioOfwNodes (
     UINT64 TargetLun[2];
 
     TargetLun[1] = 0;
-    NumEntries = sizeof (TargetLun) / sizeof (TargetLun[0]);
+    NumEntries = ARRAY_SIZE (TargetLun);
     if (ParseUnitAddressHexList (
           OfwNode[2].UnitAddress,
           TargetLun,
@@ -1803,7 +1803,7 @@ SetBootOrderFromQemu (
   //
   // translate each OpenFirmware path
   //
-  TranslatedSize = sizeof (Translated) / sizeof (Translated[0]);
+  TranslatedSize = ARRAY_SIZE (Translated);
   Status = TranslateOfwPath (&FwCfgPtr, ExtraPciRoots, Translated,
              &TranslatedSize);
   while (Status == RETURN_SUCCESS ||
@@ -1835,7 +1835,7 @@ SetBootOrderFromQemu (
       } // scanned all active boot options
     }   // translation successful
 
-    TranslatedSize = sizeof (Translated) / sizeof (Translated[0]);
+    TranslatedSize = ARRAY_SIZE (Translated);
     Status = TranslateOfwPath (&FwCfgPtr, ExtraPciRoots, Translated,
                &TranslatedSize);
   } // scanning of OpenFirmware paths done
-- 
2.9.2




^ permalink raw reply related	[flat|nested] 98+ messages in thread

* [PATCH 38/47] OvmfPkg/QemuVideoDxe: rebase to ARRAY_SIZE()
  2016-10-26 19:04 [PATCH 00/47] edk2: centralize and adopt ARRAY_SIZE() Laszlo Ersek
                   ` (36 preceding siblings ...)
  2016-10-26 19:04 ` [PATCH 37/47] OvmfPkg/QemuBootOrderLib: " Laszlo Ersek
@ 2016-10-26 19:04 ` Laszlo Ersek
  2016-10-26 19:04 ` [PATCH 39/47] PerformancePkg/Dp_App: " Laszlo Ersek
                   ` (13 subsequent siblings)
  51 siblings, 0 replies; 98+ messages in thread
From: Laszlo Ersek @ 2016-10-26 19:04 UTC (permalink / raw)
  To: edk2-devel-01; +Cc: Jordan Justen

Cc: Jordan Justen <jordan.l.justen@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Laszlo Ersek <lersek@redhat.com>
---
 OvmfPkg/QemuVideoDxe/Initialize.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/OvmfPkg/QemuVideoDxe/Initialize.c b/OvmfPkg/QemuVideoDxe/Initialize.c
index 98ca4f8488fe..d5d8cfef9661 100644
--- a/OvmfPkg/QemuVideoDxe/Initialize.c
+++ b/OvmfPkg/QemuVideoDxe/Initialize.c
@@ -155,7 +155,7 @@ QEMU_VIDEO_CIRRUS_MODES  QemuVideoCirrusModes[] = {
 };
 
 #define QEMU_VIDEO_CIRRUS_MODE_COUNT \
-  (sizeof (QemuVideoCirrusModes) / sizeof (QemuVideoCirrusModes[0]))
+  (ARRAY_SIZE (QemuVideoCirrusModes))
 
 /**
   Construct the valid video modes for QemuVideo.
@@ -247,7 +247,7 @@ QEMU_VIDEO_BOCHS_MODES  QemuVideoBochsModes[] = {
 };
 
 #define QEMU_VIDEO_BOCHS_MODE_COUNT \
-  (sizeof (QemuVideoBochsModes) / sizeof (QemuVideoBochsModes[0]))
+  (ARRAY_SIZE (QemuVideoBochsModes))
 
 EFI_STATUS
 QemuVideoBochsModeSetup (
-- 
2.9.2




^ permalink raw reply related	[flat|nested] 98+ messages in thread

* [PATCH 39/47] PerformancePkg/Dp_App: rebase to ARRAY_SIZE()
  2016-10-26 19:04 [PATCH 00/47] edk2: centralize and adopt ARRAY_SIZE() Laszlo Ersek
                   ` (37 preceding siblings ...)
  2016-10-26 19:04 ` [PATCH 38/47] OvmfPkg/QemuVideoDxe: " Laszlo Ersek
@ 2016-10-26 19:04 ` Laszlo Ersek
  2016-10-26 19:04 ` [PATCH 40/47] SecurityPkg/AuthVariableLib: " Laszlo Ersek
                   ` (12 subsequent siblings)
  51 siblings, 0 replies; 98+ messages in thread
From: Laszlo Ersek @ 2016-10-26 19:04 UTC (permalink / raw)
  To: edk2-devel-01; +Cc: Daryl McDaniel, Jaben Carsey

Cc: Daryl McDaniel <edk2-lists@mc2research.org>
Cc: Jaben Carsey <jaben.carsey@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Laszlo Ersek <lersek@redhat.com>
---
 PerformancePkg/Dp_App/Dp.c      |  2 +-
 PerformancePkg/Dp_App/DpTrace.c | 10 +++++-----
 2 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/PerformancePkg/Dp_App/Dp.c b/PerformancePkg/Dp_App/Dp.c
index 6890a99c2937..26a3ebcd1d07 100644
--- a/PerformancePkg/Dp_App/Dp.c
+++ b/PerformancePkg/Dp_App/Dp.c
@@ -114,7 +114,7 @@ InitialShellParamList( void )
   //
   // Allocate one more for the end tag.
   //
-  ListLength = sizeof (ParamList) / sizeof (ParamList[0]) + 1;  
+  ListLength = ARRAY_SIZE (ParamList) + 1;  
   DpParamList = AllocatePool (sizeof (SHELL_PARAM_ITEM) * ListLength);
   ASSERT (DpParamList != NULL);
   
diff --git a/PerformancePkg/Dp_App/DpTrace.c b/PerformancePkg/Dp_App/DpTrace.c
index 256f7462838c..6a62bba7efe0 100644
--- a/PerformancePkg/Dp_App/DpTrace.c
+++ b/PerformancePkg/Dp_App/DpTrace.c
@@ -220,8 +220,8 @@ DumpAllTrace(
       ++Count;    // Count the number of records printed
 
       // If Handle is non-zero, see if we can determine a name for the driver
-      AsciiStrToUnicodeStrS (Measurement.Module, mGaugeString, sizeof (mGaugeString) / sizeof (mGaugeString[0])); // Use Module by default
-      AsciiStrToUnicodeStrS (Measurement.Token, mUnicodeToken, sizeof (mUnicodeToken) / sizeof (mUnicodeToken[0]));
+      AsciiStrToUnicodeStrS (Measurement.Module, mGaugeString, ARRAY_SIZE (mGaugeString)); // Use Module by default
+      AsciiStrToUnicodeStrS (Measurement.Token, mUnicodeToken, ARRAY_SIZE (mUnicodeToken));
       if (Measurement.Handle != NULL) {
         // See if the Handle is in the HandleBuffer
         for (TIndex = 0; TIndex < HandleCount; TIndex++) {
@@ -594,7 +594,7 @@ ProcessHandles(
         continue;
       }
       mGaugeString[0] = 0;    // Empty driver name by default
-      AsciiStrToUnicodeStrS (Measurement.Token, mUnicodeToken, sizeof (mUnicodeToken) / sizeof (mUnicodeToken[0]));
+      AsciiStrToUnicodeStrS (Measurement.Token, mUnicodeToken, ARRAY_SIZE (mUnicodeToken));
       // See if the Handle is in the HandleBuffer
       for (Index = 0; Index < HandleCount; Index++) {
         if (Measurement.Handle == HandleBuffer[Index]) {
@@ -777,8 +777,8 @@ ProcessGlobal(
                           &Measurement.EndTimeStamp,
                           &Measurement.Identifier)) != 0)
   {
-    AsciiStrToUnicodeStrS (Measurement.Module, mGaugeString, sizeof (mGaugeString) / sizeof (mGaugeString[0]));
-    AsciiStrToUnicodeStrS (Measurement.Token, mUnicodeToken, sizeof (mUnicodeToken) / sizeof (mUnicodeToken[0]));
+    AsciiStrToUnicodeStrS (Measurement.Module, mGaugeString, ARRAY_SIZE (mGaugeString));
+    AsciiStrToUnicodeStrS (Measurement.Token, mUnicodeToken, ARRAY_SIZE (mUnicodeToken));
     mGaugeString[25] = 0;
     mUnicodeToken[31] = 0;
     if ( ! ( IsPhase( &Measurement)  ||
-- 
2.9.2




^ permalink raw reply related	[flat|nested] 98+ messages in thread

* [PATCH 40/47] SecurityPkg/AuthVariableLib: rebase to ARRAY_SIZE()
  2016-10-26 19:04 [PATCH 00/47] edk2: centralize and adopt ARRAY_SIZE() Laszlo Ersek
                   ` (38 preceding siblings ...)
  2016-10-26 19:04 ` [PATCH 39/47] PerformancePkg/Dp_App: " Laszlo Ersek
@ 2016-10-26 19:04 ` Laszlo Ersek
  2016-10-27  9:07   ` Laszlo Ersek
  2016-10-26 19:04 ` [PATCH 41/47] ShellPkg/UefiDpLib: " Laszlo Ersek
                   ` (11 subsequent siblings)
  51 siblings, 1 reply; 98+ messages in thread
From: Laszlo Ersek @ 2016-10-26 19:04 UTC (permalink / raw)
  To: edk2-devel-01; +Cc: Chao Zhang, Star Zeng

Cc: Chao Zhang <chao.b.zhang@intel.com>
Cc: Star Zeng <star.zeng@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Laszlo Ersek <lersek@redhat.com>
---
 SecurityPkg/Library/AuthVariableLib/AuthVariableLib.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/SecurityPkg/Library/AuthVariableLib/AuthVariableLib.c b/SecurityPkg/Library/AuthVariableLib/AuthVariableLib.c
index c4fbb649f1fd..792a1232aed9 100644
--- a/SecurityPkg/Library/AuthVariableLib/AuthVariableLib.c
+++ b/SecurityPkg/Library/AuthVariableLib/AuthVariableLib.c
@@ -421,7 +421,7 @@ AuthVariableLibInitialize (
   AuthVarLibContextOut->StructVersion = AUTH_VAR_LIB_CONTEXT_OUT_STRUCT_VERSION;
   AuthVarLibContextOut->StructSize = sizeof (AUTH_VAR_LIB_CONTEXT_OUT);
   AuthVarLibContextOut->AuthVarEntry = mAuthVarEntry;
-  AuthVarLibContextOut->AuthVarEntryCount = sizeof (mAuthVarEntry) / sizeof (mAuthVarEntry[0]);
+  AuthVarLibContextOut->AuthVarEntryCount = ARRAY_SIZE (mAuthVarEntry);
   mAuthVarAddressPointer[0] = (VOID **) &mPubKeyStore;
   mAuthVarAddressPointer[1] = (VOID **) &mCertDbStore;
   mAuthVarAddressPointer[2] = (VOID **) &mHashCtx;
@@ -433,7 +433,7 @@ AuthVariableLibInitialize (
   mAuthVarAddressPointer[8] = (VOID **) &(mAuthVarLibContextIn->CheckRemainingSpaceForConsistency),
   mAuthVarAddressPointer[9] = (VOID **) &(mAuthVarLibContextIn->AtRuntime),
   AuthVarLibContextOut->AddressPointer = mAuthVarAddressPointer;
-  AuthVarLibContextOut->AddressPointerCount = sizeof (mAuthVarAddressPointer) / sizeof (mAuthVarAddressPointer[0]);
+  AuthVarLibContextOut->AddressPointerCount = ARRAY_SIZE (mAuthVarAddressPointer);
 
   return Status;
 }
-- 
2.9.2




^ permalink raw reply related	[flat|nested] 98+ messages in thread

* [PATCH 41/47] ShellPkg/UefiDpLib: rebase to ARRAY_SIZE()
  2016-10-26 19:04 [PATCH 00/47] edk2: centralize and adopt ARRAY_SIZE() Laszlo Ersek
                   ` (39 preceding siblings ...)
  2016-10-26 19:04 ` [PATCH 40/47] SecurityPkg/AuthVariableLib: " Laszlo Ersek
@ 2016-10-26 19:04 ` Laszlo Ersek
  2016-10-27  1:47   ` Ni, Ruiyu
  2016-10-26 19:04 ` [PATCH 42/47] ShellPkg/UefiShellLevel2CommandsLib: " Laszlo Ersek
                   ` (10 subsequent siblings)
  51 siblings, 1 reply; 98+ messages in thread
From: Laszlo Ersek @ 2016-10-26 19:04 UTC (permalink / raw)
  To: edk2-devel-01; +Cc: Jaben Carsey, Ruiyu Ni

Cc: Jaben Carsey <jaben.carsey@intel.com>
Cc: Ruiyu Ni <ruiyu.ni@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Laszlo Ersek <lersek@redhat.com>
---
 ShellPkg/Library/UefiDpLib/DpTrace.c | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/ShellPkg/Library/UefiDpLib/DpTrace.c b/ShellPkg/Library/UefiDpLib/DpTrace.c
index f3f781fdb989..eca2ef309bbc 100644
--- a/ShellPkg/Library/UefiDpLib/DpTrace.c
+++ b/ShellPkg/Library/UefiDpLib/DpTrace.c
@@ -220,8 +220,8 @@ DumpAllTrace(
       ++Count;    // Count the number of records printed
 
       // If Handle is non-zero, see if we can determine a name for the driver
-      AsciiStrToUnicodeStrS (Measurement.Module, mGaugeString, sizeof (mGaugeString) / sizeof (mGaugeString[0])); // Use Module by default
-      AsciiStrToUnicodeStrS (Measurement.Token, mUnicodeToken, sizeof (mUnicodeToken) / sizeof (mUnicodeToken[0]));
+      AsciiStrToUnicodeStrS (Measurement.Module, mGaugeString, ARRAY_SIZE (mGaugeString)); // Use Module by default
+      AsciiStrToUnicodeStrS (Measurement.Token, mUnicodeToken, ARRAY_SIZE (mUnicodeToken));
       if (Measurement.Handle != NULL) {
         // See if the Handle is in the HandleBuffer
         for (TIndex = 0; TIndex < HandleCount; TIndex++) {
@@ -595,7 +595,7 @@ ProcessHandles(
         continue;
       }
       mGaugeString[0] = 0;    // Empty driver name by default
-      AsciiStrToUnicodeStrS (Measurement.Token, mUnicodeToken, sizeof (mUnicodeToken) / sizeof (mUnicodeToken[0]));
+      AsciiStrToUnicodeStrS (Measurement.Token, mUnicodeToken, ARRAY_SIZE (mUnicodeToken));
       // See if the Handle is in the HandleBuffer
       for (Index = 0; Index < HandleCount; Index++) {
         if (Measurement.Handle == HandleBuffer[Index]) {
@@ -776,8 +776,8 @@ ProcessGlobal(
                           &Measurement.EndTimeStamp,
                           &Measurement.Identifier)) != 0)
   {
-    AsciiStrToUnicodeStrS (Measurement.Module, mGaugeString, sizeof (mGaugeString) / sizeof (mGaugeString[0]));
-    AsciiStrToUnicodeStrS (Measurement.Token, mUnicodeToken, sizeof (mUnicodeToken) / sizeof (mUnicodeToken[0]));
+    AsciiStrToUnicodeStrS (Measurement.Module, mGaugeString, ARRAY_SIZE (mGaugeString));
+    AsciiStrToUnicodeStrS (Measurement.Token, mUnicodeToken, ARRAY_SIZE (mUnicodeToken));
     mGaugeString[25] = 0;
     mUnicodeToken[31] = 0;
     if ( ! ( IsPhase( &Measurement)  ||
-- 
2.9.2




^ permalink raw reply related	[flat|nested] 98+ messages in thread

* [PATCH 42/47] ShellPkg/UefiShellLevel2CommandsLib: rebase to ARRAY_SIZE()
  2016-10-26 19:04 [PATCH 00/47] edk2: centralize and adopt ARRAY_SIZE() Laszlo Ersek
                   ` (40 preceding siblings ...)
  2016-10-26 19:04 ` [PATCH 41/47] ShellPkg/UefiDpLib: " Laszlo Ersek
@ 2016-10-26 19:04 ` Laszlo Ersek
  2016-10-27  1:47   ` Ni, Ruiyu
  2016-10-26 19:05 ` [PATCH 43/47] Vlv2TbltDevicePkg/FirmwareUpdate: " Laszlo Ersek
                   ` (9 subsequent siblings)
  51 siblings, 1 reply; 98+ messages in thread
From: Laszlo Ersek @ 2016-10-26 19:04 UTC (permalink / raw)
  To: edk2-devel-01; +Cc: Jaben Carsey, Ruiyu Ni

Cc: Jaben Carsey <jaben.carsey@intel.com>
Cc: Ruiyu Ni <ruiyu.ni@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Laszlo Ersek <lersek@redhat.com>
---
 ShellPkg/Library/UefiShellLevel2CommandsLib/TimeDate.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/ShellPkg/Library/UefiShellLevel2CommandsLib/TimeDate.c b/ShellPkg/Library/UefiShellLevel2CommandsLib/TimeDate.c
index 3ebc72a0afa8..5383cffe879c 100644
--- a/ShellPkg/Library/UefiShellLevel2CommandsLib/TimeDate.c
+++ b/ShellPkg/Library/UefiShellLevel2CommandsLib/TimeDate.c
@@ -942,7 +942,7 @@ ShellCommandRunTimeZone (
         //
         if (ShellCommandLineGetFlag (Package, L"-f")) {
           for ( LoopVar = 0
-              ; LoopVar < sizeof (TimeZoneList) / sizeof (TimeZoneList[0])
+              ; LoopVar < ARRAY_SIZE (TimeZoneList)
               ; LoopVar++
              ){
             if (TheTime.TimeZone == TimeZoneList[LoopVar].TimeZone) {
-- 
2.9.2




^ permalink raw reply related	[flat|nested] 98+ messages in thread

* [PATCH 43/47] Vlv2TbltDevicePkg/FirmwareUpdate: rebase to ARRAY_SIZE()
  2016-10-26 19:04 [PATCH 00/47] edk2: centralize and adopt ARRAY_SIZE() Laszlo Ersek
                   ` (41 preceding siblings ...)
  2016-10-26 19:04 ` [PATCH 42/47] ShellPkg/UefiShellLevel2CommandsLib: " Laszlo Ersek
@ 2016-10-26 19:05 ` Laszlo Ersek
  2016-10-27  7:08   ` Guo, Mang
  2016-10-26 19:05 ` [PATCH 44/47] Vlv2TbltDevicePkg/PlatformInitPei: " Laszlo Ersek
                   ` (8 subsequent siblings)
  51 siblings, 1 reply; 98+ messages in thread
From: Laszlo Ersek @ 2016-10-26 19:05 UTC (permalink / raw)
  To: edk2-devel-01; +Cc: David Wei, Tim He

Cc: David Wei <david.wei@intel.com>
Cc: Tim He <tim.he@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Laszlo Ersek <lersek@redhat.com>
---
 Vlv2TbltDevicePkg/Application/FirmwareUpdate/FirmwareUpdate.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/Vlv2TbltDevicePkg/Application/FirmwareUpdate/FirmwareUpdate.c b/Vlv2TbltDevicePkg/Application/FirmwareUpdate/FirmwareUpdate.c
index 16629bf93bf3..8e44224e6779 100644
--- a/Vlv2TbltDevicePkg/Application/FirmwareUpdate/FirmwareUpdate.c
+++ b/Vlv2TbltDevicePkg/Application/FirmwareUpdate/FirmwareUpdate.c
@@ -34,7 +34,7 @@ FV_REGION_INFO mRegionInfo[] = {
   {FixedPcdGet32 (PcdBiosRomBase), FixedPcdGet32 (PcdBiosRomSize), TRUE}
 };
 
-UINTN mRegionInfoCount = sizeof (mRegionInfo) / sizeof (mRegionInfo[0]);
+UINTN mRegionInfoCount = ARRAY_SIZE (mRegionInfo);
 
 FV_INPUT_DATA mInputData = {0};
 
-- 
2.9.2




^ permalink raw reply related	[flat|nested] 98+ messages in thread

* [PATCH 44/47] Vlv2TbltDevicePkg/PlatformInitPei: rebase to ARRAY_SIZE()
  2016-10-26 19:04 [PATCH 00/47] edk2: centralize and adopt ARRAY_SIZE() Laszlo Ersek
                   ` (42 preceding siblings ...)
  2016-10-26 19:05 ` [PATCH 43/47] Vlv2TbltDevicePkg/FirmwareUpdate: " Laszlo Ersek
@ 2016-10-26 19:05 ` Laszlo Ersek
  2016-10-27  7:10   ` Guo, Mang
  2016-10-26 19:05 ` [PATCH 45/47] Vlv2TbltDevicePkg/PlatformPei: " Laszlo Ersek
                   ` (7 subsequent siblings)
  51 siblings, 1 reply; 98+ messages in thread
From: Laszlo Ersek @ 2016-10-26 19:05 UTC (permalink / raw)
  To: edk2-devel-01

M: David Wei <david.wei@intel.com>
M: Tim He <tim.he@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Laszlo Ersek <lersek@redhat.com>
---
 Vlv2TbltDevicePkg/PlatformInitPei/FlashMap.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/Vlv2TbltDevicePkg/PlatformInitPei/FlashMap.c b/Vlv2TbltDevicePkg/PlatformInitPei/FlashMap.c
index 282faa85ffb6..54ad42bb27a0 100644
--- a/Vlv2TbltDevicePkg/PlatformInitPei/FlashMap.c
+++ b/Vlv2TbltDevicePkg/PlatformInitPei/FlashMap.c
@@ -72,7 +72,7 @@ static EFI_FLASH_AREA_DATA          mFlashAreaData[]  = {
 
 };
 
-#define NUM_FLASH_AREA_DATA (sizeof (mFlashAreaData) / sizeof (mFlashAreaData[0]))
+#define NUM_FLASH_AREA_DATA (ARRAY_SIZE (mFlashAreaData))
 
 /**
   Build GUID HOBs for platform specific flash map.
-- 
2.9.2




^ permalink raw reply related	[flat|nested] 98+ messages in thread

* [PATCH 45/47] Vlv2TbltDevicePkg/PlatformPei: rebase to ARRAY_SIZE()
  2016-10-26 19:04 [PATCH 00/47] edk2: centralize and adopt ARRAY_SIZE() Laszlo Ersek
                   ` (43 preceding siblings ...)
  2016-10-26 19:05 ` [PATCH 44/47] Vlv2TbltDevicePkg/PlatformInitPei: " Laszlo Ersek
@ 2016-10-26 19:05 ` Laszlo Ersek
  2016-10-27  7:12   ` Guo, Mang
  2016-10-26 19:05 ` [PATCH 46/47] Vlv2TbltDevicePkg/PlatformSetupDxe: " Laszlo Ersek
                   ` (6 subsequent siblings)
  51 siblings, 1 reply; 98+ messages in thread
From: Laszlo Ersek @ 2016-10-26 19:05 UTC (permalink / raw)
  To: edk2-devel-01; +Cc: David Wei, Tim He

Cc: David Wei <david.wei@intel.com>
Cc: Tim He <tim.he@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Laszlo Ersek <lersek@redhat.com>
---
 Vlv2TbltDevicePkg/PlatformPei/BootMode.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/Vlv2TbltDevicePkg/PlatformPei/BootMode.c b/Vlv2TbltDevicePkg/PlatformPei/BootMode.c
index 4d933a09db0e..95be1c0f2851 100644
--- a/Vlv2TbltDevicePkg/PlatformPei/BootMode.c
+++ b/Vlv2TbltDevicePkg/PlatformPei/BootMode.c
@@ -372,13 +372,13 @@ PrioritizeBootMode (
   // Find the position of the current boot mode in our priority array
   //
   for ( CurrentIndex = 0;
-        CurrentIndex < sizeof (mBootModePriority) / sizeof (mBootModePriority[0]);
+        CurrentIndex < ARRAY_SIZE (mBootModePriority);
         CurrentIndex++) {
     if (mBootModePriority[CurrentIndex] == *CurrentBootMode) {
       break;
     }
   }
-  if (CurrentIndex >= sizeof (mBootModePriority) / sizeof (mBootModePriority[0])) {
+  if (CurrentIndex >= ARRAY_SIZE (mBootModePriority)) {
     return EFI_NOT_FOUND;
   }
 
@@ -386,7 +386,7 @@ PrioritizeBootMode (
   // Find the position of the new boot mode in our priority array
   //
   for ( NewIndex = 0;
-        NewIndex < sizeof (mBootModePriority) / sizeof (mBootModePriority[0]);
+        NewIndex < ARRAY_SIZE (mBootModePriority);
         NewIndex++) {
     if (mBootModePriority[NewIndex] == NewBootMode) {
       //
-- 
2.9.2




^ permalink raw reply related	[flat|nested] 98+ messages in thread

* [PATCH 46/47] Vlv2TbltDevicePkg/PlatformSetupDxe: rebase to ARRAY_SIZE()
  2016-10-26 19:04 [PATCH 00/47] edk2: centralize and adopt ARRAY_SIZE() Laszlo Ersek
                   ` (44 preceding siblings ...)
  2016-10-26 19:05 ` [PATCH 45/47] Vlv2TbltDevicePkg/PlatformPei: " Laszlo Ersek
@ 2016-10-26 19:05 ` Laszlo Ersek
  2016-10-27  7:14   ` Guo, Mang
  2016-10-26 19:05 ` [PATCH 47/47] Vlv2TbltDevicePkg/SmBiosMiscDxe: " Laszlo Ersek
                   ` (5 subsequent siblings)
  51 siblings, 1 reply; 98+ messages in thread
From: Laszlo Ersek @ 2016-10-26 19:05 UTC (permalink / raw)
  To: edk2-devel-01; +Cc: David Wei, Tim He

Cc: David Wei <david.wei@intel.com>
Cc: Tim He <tim.he@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Laszlo Ersek <lersek@redhat.com>
---
 Vlv2TbltDevicePkg/PlatformSetupDxe/SetupInfoRecords.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/Vlv2TbltDevicePkg/PlatformSetupDxe/SetupInfoRecords.c b/Vlv2TbltDevicePkg/PlatformSetupDxe/SetupInfoRecords.c
index 3cdb0132cd04..b0e29f02d067 100644
--- a/Vlv2TbltDevicePkg/PlatformSetupDxe/SetupInfoRecords.c
+++ b/Vlv2TbltDevicePkg/PlatformSetupDxe/SetupInfoRecords.c
@@ -1371,7 +1371,7 @@ UpdatePlatformInformation (
                             );
 
          Data8 = MmioRead8 (PciD31F0RegBase + R_PCH_LPC_RID_CC);
-         count = sizeof (SBRevisionTable) / sizeof (SBRevisionTable[0]);
+         count = ARRAY_SIZE (SBRevisionTable);
          for (Index = 0; Index < count; Index++) {
            if(Data8 == SBRevisionTable[Index].RevId) {
               UnicodeSPrint (Buffer, sizeof (Buffer), L"%02x %a", Data8, SBRevisionTable[Index].String);
-- 
2.9.2




^ permalink raw reply related	[flat|nested] 98+ messages in thread

* [PATCH 47/47] Vlv2TbltDevicePkg/SmBiosMiscDxe: rebase to ARRAY_SIZE()
  2016-10-26 19:04 [PATCH 00/47] edk2: centralize and adopt ARRAY_SIZE() Laszlo Ersek
                   ` (45 preceding siblings ...)
  2016-10-26 19:05 ` [PATCH 46/47] Vlv2TbltDevicePkg/PlatformSetupDxe: " Laszlo Ersek
@ 2016-10-26 19:05 ` Laszlo Ersek
  2016-10-27  7:14   ` Guo, Mang
  2016-10-26 21:48 ` [PATCH 00/47] edk2: centralize and adopt ARRAY_SIZE() Carsey, Jaben
                   ` (4 subsequent siblings)
  51 siblings, 1 reply; 98+ messages in thread
From: Laszlo Ersek @ 2016-10-26 19:05 UTC (permalink / raw)
  To: edk2-devel-01; +Cc: David Wei, Tim He

Cc: David Wei <david.wei@intel.com>
Cc: Tim He <tim.he@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Laszlo Ersek <lersek@redhat.com>
---
 Vlv2TbltDevicePkg/SmBiosMiscDxe/MiscOemType0x94Function.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/Vlv2TbltDevicePkg/SmBiosMiscDxe/MiscOemType0x94Function.c b/Vlv2TbltDevicePkg/SmBiosMiscDxe/MiscOemType0x94Function.c
index 898fc7cf0db3..657d19a6e757 100644
--- a/Vlv2TbltDevicePkg/SmBiosMiscDxe/MiscOemType0x94Function.c
+++ b/Vlv2TbltDevicePkg/SmBiosMiscDxe/MiscOemType0x94Function.c
@@ -691,7 +691,7 @@ UpdatePlatformInformation (
                             );
 
          Data8 = MmioRead8 (PciD31F0RegBase + R_PCH_LPC_RID_CC);
-         count = sizeof (SBRevisionTable) / sizeof (SBRevisionTable[0]);
+         count = ARRAY_SIZE (SBRevisionTable);
          for (Index = 0; Index < count; Index++) {
            if(Data8 == SBRevisionTable[Index].RevId) {
               UnicodeSPrint (Buffer, sizeof (Buffer), L"%02x %a", Data8, SBRevisionTable[Index].String);
-- 
2.9.2



^ permalink raw reply related	[flat|nested] 98+ messages in thread

* Re: [PATCH 00/47] edk2: centralize and adopt ARRAY_SIZE()
  2016-10-26 19:04 [PATCH 00/47] edk2: centralize and adopt ARRAY_SIZE() Laszlo Ersek
                   ` (46 preceding siblings ...)
  2016-10-26 19:05 ` [PATCH 47/47] Vlv2TbltDevicePkg/SmBiosMiscDxe: " Laszlo Ersek
@ 2016-10-26 21:48 ` Carsey, Jaben
  2016-10-27  1:17 ` Tian, Feng
                   ` (3 subsequent siblings)
  51 siblings, 0 replies; 98+ messages in thread
From: Carsey, Jaben @ 2016-10-26 21:48 UTC (permalink / raw)
  To: Laszlo Ersek, edk2-devel-01
  Cc: Ard Biesheuvel, Cecil Sheng, Zhang, Chao B, Bi, Dandan,
	Daryl McDaniel, Wei, David, Dong, Eric, Tian, Feng, Gary Lin,
	Fan, Jeff, Wu, Jiaxin, Justen, Jordan L, Gao, Liming,
	Kinney, Michael D, Ni, Ruiyu, Fu, Siyuan, Zeng, Star,
	Carsey, Jaben

For 05, 39, 41, 42

Reviewed-by: Jaben Carsey <jaben.carsey@intel.com>

> -----Original Message-----
> From: Laszlo Ersek [mailto:lersek@redhat.com]
> Sent: Wednesday, October 26, 2016 12:04 PM
> To: edk2-devel-01 <edk2-devel@ml01.01.org>
> Cc: Ard Biesheuvel <ard.biesheuvel@linaro.org>; Cecil Sheng
> <cecil.sheng@hpe.com>; Zhang, Chao B <chao.b.zhang@intel.com>; Bi,
> Dandan <dandan.bi@intel.com>; Daryl McDaniel <edk2-
> lists@mc2research.org>; Wei, David <david.wei@intel.com>; Dong, Eric
> <eric.dong@intel.com>; Tian, Feng <feng.tian@intel.com>; Gary Lin
> <glin@suse.com>; Carsey, Jaben <jaben.carsey@intel.com>; Fan, Jeff
> <jeff.fan@intel.com>; Wu, Jiaxin <jiaxin.wu@intel.com>; Justen, Jordan L
> <jordan.l.justen@intel.com>; Gao, Liming <liming.gao@intel.com>; Kinney,
> Michael D <michael.d.kinney@intel.com>; Ni, Ruiyu <ruiyu.ni@intel.com>;
> Fu, Siyuan <siyuan.fu@intel.com>; Zeng, Star <star.zeng@intel.com>; Tim He
> <tim.he@intel.com>
> Subject: [PATCH 00/47] edk2: centralize and adopt ARRAY_SIZE()
> Importance: High
> 
> I'm sure most of us have wished at some point that ARRAY_SIZE()
> had existed in a central header file, like it does in many other
> open source projects. This series implements that.
> 
> Patches 01-04 round up the modules that #define ARRAY_SIZE() just
> for themselves, and wrap their definitions in #ifndef ARRAY_SIZE.
> 
> Patch 05 defines ARRAY_SIZE() in "MdePkg/Include/Base.h". This
> flips the previously modified modules to MdePkg's macro definition.
> 
> Patches 06-09 modify the same set of modules as patches 01-04 do; this
> time the (now unused) module-local ARRAY_SIZE() macro definitions are
> eliminated.
> 
> The rest of the patches (10-47) migrate the edk2 tree to ARRAY_SIZE(),
> covering the most obvious open-coded ARRAY_SIZE() expressions. These
> expressions were located and converted with the following shell
> pipeline:
> 
>   git ls-files \
>   | xargs --no-run-if-empty -- \
>       sed --regexp-extended --in-place \
>         --expression='s,sizeof \(([a-zA-Z0-9_]+)\) / sizeof
> \((\*\1|\1\[0\])\),ARRAY_SIZE (\1),g' \
>         --
> 
> This pipeline lists all tracked files with "git". The pathnames are then
> composed with "xargs" into maximal length "sed" command lines, and those
> "sed" commands are run.
> 
> Here the "sed" stream editor filters and modifies all the listed files
> in place. The extended regular expression replaces the following two
> patterns:
> 
>   sizeof (ArrayName) / sizeof (*ArrayName)
>   sizeof (ArrayName) / sizeof (ArrayName[0])
> 
> with
> 
>   ARRAY_SIZE (ArrayName)
> 
> The regexp uses a backreference in the match, ensuring that the sizeof
> operator in the dividend and the sizeof operator in the divisor both
> refer to the same ArrayName. If there are multiple occurrences on the
> same line, the sed command replaces all of them.
> 
> I collected the changes into patches manually, and I reviewed them all.
> 
> I test-built all of the modified packages, repeating the command
> 
>   build -a X64 -t GCC48 -b DEBUG -p FooPkg/FooPkg.dsc
> 
> as many times as necessary. Two packages were impossible to build like
> this: Nt32Pkg and Vlv2TbltDevicePkg, so I couldn't build-test them.
> 
> I did some light-weight testing with OVMF: boot with Secure Boot
> enabled, S3 suspend/resume with and without SMM. I also booted
> ArmVirtQemu once.
> 
> Repository: https://github.com/lersek/edk2.git
> Branch:     array_size
> 
> Cc: Ard Biesheuvel <ard.biesheuvel@linaro.org>
> Cc: Cecil Sheng <cecil.sheng@hpe.com>
> Cc: Chao Zhang <chao.b.zhang@intel.com>
> Cc: Dandan Bi <dandan.bi@intel.com>
> Cc: Daryl McDaniel <edk2-lists@mc2research.org>
> Cc: David Wei <david.wei@intel.com>
> Cc: Eric Dong <eric.dong@intel.com>
> Cc: Feng Tian <feng.tian@intel.com>
> Cc: Gary Lin <glin@suse.com>
> Cc: Jaben Carsey <jaben.carsey@intel.com>
> Cc: Jeff Fan <jeff.fan@intel.com>
> Cc: Jiaxin Wu <jiaxin.wu@intel.com>
> Cc: Jordan Justen <jordan.l.justen@intel.com>
> Cc: Liming Gao <liming.gao@intel.com>
> Cc: Michael D Kinney <michael.d.kinney@intel.com>
> Cc: Ruiyu Ni <ruiyu.ni@intel.com>
> Cc: Siyuan Fu <siyuan.fu@intel.com>
> Cc: Star Zeng <star.zeng@intel.com>
> Cc: Tim He <tim.he@intel.com>
> 
> Thanks
> Laszlo
> 
> Laszlo Ersek (47):
>   MdeModulePkg/RegularExpressionDxe: guard the definition of ARRAY_SIZE
>   NetworkPkg/IpsecConfig: guard the definition of ARRAY_SIZE
>   OvmfPkg/PlatformBootManagerLib: guard the definition of ARRAY_SIZE
>   OvmfPkg/XenBusDxe: guard the definition of ARRAY_SIZE
>   MdePkg/Include/Base.h: introduce the ARRAY_SIZE() function-like macro
>   MdeModulePkg/RegularExpressionDxe: remove module-local ARRAY_SIZE
>     macro
>   NetworkPkg/IpsecConfig: remove module-local ARRAY_SIZE macro
>   OvmfPkg/PlatformBootManagerLib: remove module-local ARRAY_SIZE
> macro
>   OvmfPkg/XenBusDxe: remove module-local ARRAY_SIZE macro
>   ArmVirtPkg/NorFlashQemuLib: rebase to ARRAY_SIZE()
>   DuetPkg/DuetBdsLib: rebase to ARRAY_SIZE()
>   EdkCompatibilityPkg/FrameworkHiiOnUefiHiiThunk: rebase to ARRAY_SIZE()
>   EdkCompatibilityPkg/Sample/Tools: rebase to ARRAY_SIZE()
>   FatPkg/EnhancedFatDxe: rebase to ARRAY_SIZE()
>   IntelFrameworkModulePkg/LegacyBootManagerLib: rebase to
> ARRAY_SIZE()
>   IntelFrameworkModulePkg/BdsDxe: rebase to ARRAY_SIZE()
>   MdeModulePkg/MemoryProfileInfo: rebase to ARRAY_SIZE()
>   MdeModulePkg/PciBusDxe: rebase to ARRAY_SIZE()
>   MdeModulePkg/PciHostBridgeDxe: rebase to ARRAY_SIZE()
>   MdeModulePkg/UsbBusDxe: rebase to ARRAY_SIZE()
>   MdeModulePkg/Core/Dxe: rebase to ARRAY_SIZE()
>   MdeModulePkg/Core/PiSmmCore: rebase to ARRAY_SIZE()
>   MdeModulePkg/BootMaintenanceManagerUiLib: rebase to ARRAY_SIZE()
>   MdeModulePkg/BootManagerUiLib: rebase to ARRAY_SIZE()
>   MdeModulePkg/UefiBootManagerLib: rebase to ARRAY_SIZE()
>   MdeModulePkg/VarCheckHiiLib: rebase to ARRAY_SIZE()
>   MdeModulePkg/Logo: rebase to ARRAY_SIZE()
>   MdeModulePkg/BdsDxe: rebase to ARRAY_SIZE()
>   MdeModulePkg/DisplayEngineDxe: rebase to ARRAY_SIZE()
>   MdeModulePkg/EbcDxe: rebase to ARRAY_SIZE()
>   MdeModulePkg/Tcp4Dxe: rebase to ARRAY_SIZE()
>   MdeModulePkg/Variable/RuntimeDxe: rebase to ARRAY_SIZE()
>   NetworkPkg/IScsiDxe: rebase to ARRAY_SIZE()
>   NetworkPkg/TcpDxe: rebase to ARRAY_SIZE()
>   Nt32Pkg/WinNtSerialIoDxe: rebase to ARRAY_SIZE()
>   OptionRomPkg/AtapiPassThruDxe: rebase to ARRAY_SIZE()
>   OvmfPkg/QemuBootOrderLib: rebase to ARRAY_SIZE()
>   OvmfPkg/QemuVideoDxe: rebase to ARRAY_SIZE()
>   PerformancePkg/Dp_App: rebase to ARRAY_SIZE()
>   SecurityPkg/AuthVariableLib: rebase to ARRAY_SIZE()
>   ShellPkg/UefiDpLib: rebase to ARRAY_SIZE()
>   ShellPkg/UefiShellLevel2CommandsLib: rebase to ARRAY_SIZE()
>   Vlv2TbltDevicePkg/FirmwareUpdate: rebase to ARRAY_SIZE()
>   Vlv2TbltDevicePkg/PlatformInitPei: rebase to ARRAY_SIZE()
>   Vlv2TbltDevicePkg/PlatformPei: rebase to ARRAY_SIZE()
>   Vlv2TbltDevicePkg/PlatformSetupDxe: rebase to ARRAY_SIZE()
>   Vlv2TbltDevicePkg/SmBiosMiscDxe: rebase to ARRAY_SIZE()
> 
>  ArmVirtPkg/Library/NorFlashQemuLib/NorFlashQemuLib.c                          |  2
> +-
>  DuetPkg/Library/DuetBdsLib/BdsPlatform.c                                      |  2 +-
> 
> EdkCompatibilityPkg/Compatibility/FrameworkHiiOnUefiHiiThunk/OpcodeCr
> eation.c |  2 +-
>  EdkCompatibilityPkg/Sample/Tools/Source/EfiRom/EfiRom.c                       |  4
> ++--
>  EdkCompatibilityPkg/Sample/Tools/Source/HiiPack/IfrParse.c                    |  2
> +-
>  FatPkg/EnhancedFatDxe/DirectoryManage.c                                       |  4 ++--
>  FatPkg/EnhancedFatDxe/FileName.c                                              |  4 ++--
>  FatPkg/EnhancedFatDxe/Hash.c                                                  |  4 ++--
>  IntelFrameworkModulePkg/Library/LegacyBootManagerLib/LegacyBm.c
> |  2 +-
>  IntelFrameworkModulePkg/Universal/BdsDxe/BdsEntry.c                           |  2
> +-
>  IntelFrameworkModulePkg/Universal/BdsDxe/BootMaint/BBSsupport.c
> |  4 ++--
>  IntelFrameworkModulePkg/Universal/BdsDxe/BootMaint/BootMaint.c
> |  8 ++++----
>  IntelFrameworkModulePkg/Universal/BdsDxe/BootMaint/BootOption.c
> |  2 +-
>  IntelFrameworkModulePkg/Universal/BdsDxe/BootMaint/ConsoleOption.c
> |  6 +++---
>  IntelFrameworkModulePkg/Universal/BdsDxe/BootMaint/UpdatePage.c
> | 10 +++++-----
>  IntelFrameworkModulePkg/Universal/BdsDxe/BootMaint/Variable.c
> |  2 +-
>  IntelFrameworkModulePkg/Universal/BdsDxe/BootMngr/BootManager.c
> |  2 +-
>  MdeModulePkg/Application/MemoryProfileInfo/MemoryProfileInfo.c
> |  6 +++---
>  MdeModulePkg/Bus/Pci/PciBusDxe/PciLib.c                                       |  2 +-
>  MdeModulePkg/Bus/Pci/PciHostBridgeDxe/PciHostBridge.c                         |  2
> +-
>  MdeModulePkg/Bus/Usb/UsbBusDxe/UsbHub.c                                       |  4 ++--
>  MdeModulePkg/Core/Dxe/Mem/Pool.c                                              |  2 +-
>  MdeModulePkg/Core/PiSmmCore/Pool.c                                            |  2 +-
>  MdeModulePkg/Core/PiSmmCore/SmramProfileRecord.c                              |  6
> +++---
> 
> MdeModulePkg/Library/BootMaintenanceManagerUiLib/BootMaintenance.
> c            |  8 ++++----
>  MdeModulePkg/Library/BootMaintenanceManagerUiLib/ConsoleOption.c
> |  8 ++++----
>  MdeModulePkg/Library/BootMaintenanceManagerUiLib/UpdatePage.c
> | 12 ++++++------
>  MdeModulePkg/Library/BootMaintenanceManagerUiLib/Variable.c
> |  2 +-
>  MdeModulePkg/Library/BootManagerUiLib/BootManager.c                           |  6
> +++---
>  MdeModulePkg/Library/UefiBootManagerLib/BmBootDescription.c
> |  2 +-
>  MdeModulePkg/Library/UefiBootManagerLib/BmConsole.c                           |  2
> +-
>  MdeModulePkg/Library/UefiBootManagerLib/BmHotkey.c                            |  2
> +-
>  MdeModulePkg/Library/UefiBootManagerLib/BmLoadOption.c                        |
> 4 ++--
>  MdeModulePkg/Library/VarCheckHiiLib/VarCheckHiiGen.c                          |  4
> ++--
>  MdeModulePkg/Library/VarCheckHiiLib/VarCheckHiiLibNullClass.c                 |
> 2 +-
>  MdeModulePkg/Logo/Logo.c                                                      |  2 +-
>  MdeModulePkg/Universal/BdsDxe/BdsEntry.c                                      |  2 +-
>  MdeModulePkg/Universal/DisplayEngineDxe/FormDisplay.c                         |  4
> ++--
>  MdeModulePkg/Universal/DisplayEngineDxe/InputHandler.c                        |  6
> +++---
>  MdeModulePkg/Universal/EbcDxe/EbcExecute.c                                    |  2 +-
>  MdeModulePkg/Universal/Network/Tcp4Dxe/Tcp4Output.c                           |
> 2 +-
>  MdeModulePkg/Universal/RegularExpressionDxe/RegularExpressionDxe.h
> |  2 --
>  MdeModulePkg/Universal/Variable/RuntimeDxe/Variable.c                         |  2
> +-
>  MdePkg/Include/Base.h                                                         | 13 +++++++++++++
>  NetworkPkg/Application/IpsecConfig/IpSecConfig.h                              |  2 --
>  NetworkPkg/IScsiDxe/IScsiConfig.c                                             |  4 ++--
>  NetworkPkg/IScsiDxe/IScsiDriver.c                                             |  2 +-
>  NetworkPkg/IScsiDxe/IScsiMisc.c                                               |  6 +++---
>  NetworkPkg/TcpDxe/TcpOutput.c                                                 |  2 +-
>  Nt32Pkg/WinNtSerialIoDxe/WinNtSerialIo.c                                      |  2 +-
>  OptionRomPkg/AtapiPassThruDxe/AtapiPassThru.c                                 |  4 ++--
>  OvmfPkg/Library/PlatformBootManagerLib/BdsPlatform.c                          |  5 --
> ---
>  OvmfPkg/Library/QemuBootOrderLib/QemuBootOrderLib.c                           |
> 12 ++++++------
>  OvmfPkg/QemuVideoDxe/Initialize.c                                             |  4 ++--
>  OvmfPkg/XenBusDxe/XenStore.c                                                  |  1 -
>  PerformancePkg/Dp_App/Dp.c                                                    |  2 +-
>  PerformancePkg/Dp_App/DpTrace.c                                               | 10 +++++-----
>  SecurityPkg/Library/AuthVariableLib/AuthVariableLib.c                         |  4 ++--
>  ShellPkg/Library/UefiDpLib/DpTrace.c                                          | 10 +++++-----
>  ShellPkg/Library/UefiShellLevel2CommandsLib/TimeDate.c                        |  2 +-
>  Vlv2TbltDevicePkg/Application/FirmwareUpdate/FirmwareUpdate.c
> |  2 +-
>  Vlv2TbltDevicePkg/PlatformInitPei/FlashMap.c                                  |  2 +-
>  Vlv2TbltDevicePkg/PlatformPei/BootMode.c                                      |  6 +++---
>  Vlv2TbltDevicePkg/PlatformSetupDxe/SetupInfoRecords.c                         |  2
> +-
>  Vlv2TbltDevicePkg/SmBiosMiscDxe/MiscOemType0x94Function.c
> |  2 +-
>  65 files changed, 131 insertions(+), 128 deletions(-)
> 
> --
> 2.9.2



^ permalink raw reply	[flat|nested] 98+ messages in thread

* Re: [PATCH 05/47] MdePkg/Include/Base.h: introduce the ARRAY_SIZE() function-like macro
  2016-10-26 19:04 ` [PATCH 05/47] MdePkg/Include/Base.h: introduce the ARRAY_SIZE() function-like macro Laszlo Ersek
@ 2016-10-26 22:13   ` Kinney, Michael D
  2016-10-26 22:25     ` Laszlo Ersek
  0 siblings, 1 reply; 98+ messages in thread
From: Kinney, Michael D @ 2016-10-26 22:13 UTC (permalink / raw)
  To: Laszlo Ersek, edk2-devel-01, Kinney, Michael D
  Cc: Ni, Ruiyu, Tim He, Tian, Feng, Dong, Eric, Cecil Sheng,
	Ard Biesheuvel, Justen, Jordan L, Gao, Liming, Bi, Dandan,
	Wu, Jiaxin, Gary Lin, Zeng, Star, Daryl McDaniel, Carsey, Jaben,
	Fu, Siyuan, Fan, Jeff, Zhang, Chao B, Wei, David

Hi Laszlo,

One comment inline below.

Mike

> -----Original Message-----
> From: edk2-devel [mailto:edk2-devel-bounces@lists.01.org] On Behalf Of Laszlo Ersek
> Sent: Wednesday, October 26, 2016 12:04 PM
> To: edk2-devel-01 <edk2-devel@ml01.01.org>
> Cc: Ni, Ruiyu <ruiyu.ni@intel.com>; Tim He <tim.he@intel.com>; Tian, Feng
> <feng.tian@intel.com>; Kinney, Michael D <michael.d.kinney@intel.com>; Dong, Eric
> <eric.dong@intel.com>; Cecil Sheng <cecil.sheng@hpe.com>; Ard Biesheuvel
> <ard.biesheuvel@linaro.org>; Justen, Jordan L <jordan.l.justen@intel.com>; Gao, Liming
> <liming.gao@intel.com>; Bi, Dandan <dandan.bi@intel.com>; Wu, Jiaxin
> <jiaxin.wu@intel.com>; Gary Lin <glin@suse.com>; Zeng, Star <star.zeng@intel.com>;
> Daryl McDaniel <edk2-lists@mc2research.org>; Carsey, Jaben <jaben.carsey@intel.com>;
> Fu, Siyuan <siyuan.fu@intel.com>; Fan, Jeff <jeff.fan@intel.com>; Zhang, Chao B
> <chao.b.zhang@intel.com>; Wei, David <david.wei@intel.com>
> Subject: [edk2] [PATCH 05/47] MdePkg/Include/Base.h: introduce the ARRAY_SIZE()
> function-like macro
> 
> Several modules use ARRAY_SIZE() already; centralize the definition. (The
> module-specific macro definitions are guarded by #ifndef directives at
> this point.)
> 
> Cc: Ard Biesheuvel <ard.biesheuvel@linaro.org>
> Cc: Cecil Sheng <cecil.sheng@hpe.com>
> Cc: Chao Zhang <chao.b.zhang@intel.com>
> Cc: Dandan Bi <dandan.bi@intel.com>
> Cc: Daryl McDaniel <edk2-lists@mc2research.org>
> Cc: David Wei <david.wei@intel.com>
> Cc: Eric Dong <eric.dong@intel.com>
> Cc: Feng Tian <feng.tian@intel.com>
> Cc: Gary Lin <glin@suse.com>
> Cc: Jaben Carsey <jaben.carsey@intel.com>
> Cc: Jeff Fan <jeff.fan@intel.com>
> Cc: Jiaxin Wu <jiaxin.wu@intel.com>
> Cc: Jordan Justen <jordan.l.justen@intel.com>
> Cc: Liming Gao <liming.gao@intel.com>
> Cc: Michael D Kinney <michael.d.kinney@intel.com>
> Cc: Ruiyu Ni <ruiyu.ni@intel.com>
> Cc: Siyuan Fu <siyuan.fu@intel.com>
> Cc: Star Zeng <star.zeng@intel.com>
> Cc: Tim He <tim.he@intel.com>
> Contributed-under: TianoCore Contribution Agreement 1.0
> Signed-off-by: Laszlo Ersek <lersek@redhat.com>
> ---
>  MdePkg/Include/Base.h | 13 +++++++++++++
>  1 file changed, 13 insertions(+)
> 
> diff --git a/MdePkg/Include/Base.h b/MdePkg/Include/Base.h
> index c66614846488..8bdb257e37bd 100644
> --- a/MdePkg/Include/Base.h
> +++ b/MdePkg/Include/Base.h
> @@ -1211,5 +1211,18 @@ typedef UINTN RETURN_STATUS;
>    #define RETURN_ADDRESS(L)     ((VOID *) 0)
>  #endif
> 
> +/**
> +  Return the number of elements in an array.
> +
> +  @param  Array  An object of array type. Array is only used as an argument to
> +                 the sizeof operator, therefore Array is never evaluated. The
> +                 caller is responsible for ensuring that Array's type is not
> +                 incomplete; that is, Array must have known constant size.
> +
> +  @return The number of elements in Array. The result has type UINTN.
> +
> +**/
> +#define ARRAY_SIZE(Array) (sizeof (Array) / sizeof (Array)[0])
 
I think adding one extra set of () makes this clearer:

#define ARRAY_SIZE(Array) (sizeof (Array) / sizeof ((Array)[0]))

> +
>  #endif
> 
> --
> 2.9.2
> 
> 
> _______________________________________________
> edk2-devel mailing list
> edk2-devel@lists.01.org
> https://lists.01.org/mailman/listinfo/edk2-devel


^ permalink raw reply	[flat|nested] 98+ messages in thread

* Re: [PATCH 05/47] MdePkg/Include/Base.h: introduce the ARRAY_SIZE() function-like macro
  2016-10-26 22:13   ` Kinney, Michael D
@ 2016-10-26 22:25     ` Laszlo Ersek
  2016-10-27  2:21       ` Kinney, Michael D
  0 siblings, 1 reply; 98+ messages in thread
From: Laszlo Ersek @ 2016-10-26 22:25 UTC (permalink / raw)
  To: Kinney, Michael D, edk2-devel-01
  Cc: Ni, Ruiyu, Tim He, Tian, Feng, Dong, Eric, Cecil Sheng,
	Ard Biesheuvel, Justen, Jordan L, Gao, Liming, Bi, Dandan,
	Wu, Jiaxin, Gary Lin, Zeng, Star, Daryl McDaniel, Carsey, Jaben,
	Fu, Siyuan, Fan, Jeff, Zhang, Chao B, Wei, David

On 10/27/16 00:13, Kinney, Michael D wrote:
> Hi Laszlo,
> 
> One comment inline below.
> 
> Mike
> 
>> -----Original Message-----
>> From: edk2-devel [mailto:edk2-devel-bounces@lists.01.org] On Behalf Of Laszlo Ersek
>> Sent: Wednesday, October 26, 2016 12:04 PM
>> To: edk2-devel-01 <edk2-devel@ml01.01.org>
>> Cc: Ni, Ruiyu <ruiyu.ni@intel.com>; Tim He <tim.he@intel.com>; Tian, Feng
>> <feng.tian@intel.com>; Kinney, Michael D <michael.d.kinney@intel.com>; Dong, Eric
>> <eric.dong@intel.com>; Cecil Sheng <cecil.sheng@hpe.com>; Ard Biesheuvel
>> <ard.biesheuvel@linaro.org>; Justen, Jordan L <jordan.l.justen@intel.com>; Gao, Liming
>> <liming.gao@intel.com>; Bi, Dandan <dandan.bi@intel.com>; Wu, Jiaxin
>> <jiaxin.wu@intel.com>; Gary Lin <glin@suse.com>; Zeng, Star <star.zeng@intel.com>;
>> Daryl McDaniel <edk2-lists@mc2research.org>; Carsey, Jaben <jaben.carsey@intel.com>;
>> Fu, Siyuan <siyuan.fu@intel.com>; Fan, Jeff <jeff.fan@intel.com>; Zhang, Chao B
>> <chao.b.zhang@intel.com>; Wei, David <david.wei@intel.com>
>> Subject: [edk2] [PATCH 05/47] MdePkg/Include/Base.h: introduce the ARRAY_SIZE()
>> function-like macro
>>
>> Several modules use ARRAY_SIZE() already; centralize the definition. (The
>> module-specific macro definitions are guarded by #ifndef directives at
>> this point.)
>>
>> Cc: Ard Biesheuvel <ard.biesheuvel@linaro.org>
>> Cc: Cecil Sheng <cecil.sheng@hpe.com>
>> Cc: Chao Zhang <chao.b.zhang@intel.com>
>> Cc: Dandan Bi <dandan.bi@intel.com>
>> Cc: Daryl McDaniel <edk2-lists@mc2research.org>
>> Cc: David Wei <david.wei@intel.com>
>> Cc: Eric Dong <eric.dong@intel.com>
>> Cc: Feng Tian <feng.tian@intel.com>
>> Cc: Gary Lin <glin@suse.com>
>> Cc: Jaben Carsey <jaben.carsey@intel.com>
>> Cc: Jeff Fan <jeff.fan@intel.com>
>> Cc: Jiaxin Wu <jiaxin.wu@intel.com>
>> Cc: Jordan Justen <jordan.l.justen@intel.com>
>> Cc: Liming Gao <liming.gao@intel.com>
>> Cc: Michael D Kinney <michael.d.kinney@intel.com>
>> Cc: Ruiyu Ni <ruiyu.ni@intel.com>
>> Cc: Siyuan Fu <siyuan.fu@intel.com>
>> Cc: Star Zeng <star.zeng@intel.com>
>> Cc: Tim He <tim.he@intel.com>
>> Contributed-under: TianoCore Contribution Agreement 1.0
>> Signed-off-by: Laszlo Ersek <lersek@redhat.com>
>> ---
>>  MdePkg/Include/Base.h | 13 +++++++++++++
>>  1 file changed, 13 insertions(+)
>>
>> diff --git a/MdePkg/Include/Base.h b/MdePkg/Include/Base.h
>> index c66614846488..8bdb257e37bd 100644
>> --- a/MdePkg/Include/Base.h
>> +++ b/MdePkg/Include/Base.h
>> @@ -1211,5 +1211,18 @@ typedef UINTN RETURN_STATUS;
>>    #define RETURN_ADDRESS(L)     ((VOID *) 0)
>>  #endif
>>
>> +/**
>> +  Return the number of elements in an array.
>> +
>> +  @param  Array  An object of array type. Array is only used as an argument to
>> +                 the sizeof operator, therefore Array is never evaluated. The
>> +                 caller is responsible for ensuring that Array's type is not
>> +                 incomplete; that is, Array must have known constant size.
>> +
>> +  @return The number of elements in Array. The result has type UINTN.
>> +
>> +**/
>> +#define ARRAY_SIZE(Array) (sizeof (Array) / sizeof (Array)[0])
>  
> I think adding one extra set of () makes this clearer:
> 
> #define ARRAY_SIZE(Array) (sizeof (Array) / sizeof ((Array)[0]))

Sure, will do.

Thanks!
Laszlo

>> +
>>  #endif
>>
>> --
>> 2.9.2
>>
>>
>> _______________________________________________
>> edk2-devel mailing list
>> edk2-devel@lists.01.org
>> https://lists.01.org/mailman/listinfo/edk2-devel



^ permalink raw reply	[flat|nested] 98+ messages in thread

* Re: [PATCH 00/47] edk2: centralize and adopt ARRAY_SIZE()
  2016-10-26 19:04 [PATCH 00/47] edk2: centralize and adopt ARRAY_SIZE() Laszlo Ersek
                   ` (47 preceding siblings ...)
  2016-10-26 21:48 ` [PATCH 00/47] edk2: centralize and adopt ARRAY_SIZE() Carsey, Jaben
@ 2016-10-27  1:17 ` Tian, Feng
  2016-10-27  2:37   ` Zeng, Star
  2016-10-27  4:43 ` Gary Lin
                   ` (2 subsequent siblings)
  51 siblings, 1 reply; 98+ messages in thread
From: Tian, Feng @ 2016-10-27  1:17 UTC (permalink / raw)
  To: Laszlo Ersek, edk2-devel-01
  Cc: Ard Biesheuvel, Cecil Sheng, Zhang, Chao B, Bi, Dandan,
	Daryl McDaniel, Wei, David, Dong, Eric, Gary Lin, Carsey, Jaben,
	Fan, Jeff, Wu, Jiaxin, Justen, Jordan L, Gao, Liming,
	Kinney, Michael D, Ni, Ruiyu, Fu, Siyuan, Zeng, Star, Tim He,
	Tian, Feng

MdeModulePkg

reviewed-by: Feng Tian <feng.tian@Intel.com>

Thanks
Feng

-----Original Message-----
From: Laszlo Ersek [mailto:lersek@redhat.com] 
Sent: Thursday, October 27, 2016 3:04 AM
To: edk2-devel-01 <edk2-devel@ml01.01.org>
Cc: Ard Biesheuvel <ard.biesheuvel@linaro.org>; Cecil Sheng <cecil.sheng@hpe.com>; Zhang, Chao B <chao.b.zhang@intel.com>; Bi, Dandan <dandan.bi@intel.com>; Daryl McDaniel <edk2-lists@mc2research.org>; Wei, David <david.wei@intel.com>; Dong, Eric <eric.dong@intel.com>; Tian, Feng <feng.tian@intel.com>; Gary Lin <glin@suse.com>; Carsey, Jaben <jaben.carsey@intel.com>; Fan, Jeff <jeff.fan@intel.com>; Wu, Jiaxin <jiaxin.wu@intel.com>; Justen, Jordan L <jordan.l.justen@intel.com>; Gao, Liming <liming.gao@intel.com>; Kinney, Michael D <michael.d.kinney@intel.com>; Ni, Ruiyu <ruiyu.ni@intel.com>; Fu, Siyuan <siyuan.fu@intel.com>; Zeng, Star <star.zeng@intel.com>; Tim He <tim.he@intel.com>
Subject: [PATCH 00/47] edk2: centralize and adopt ARRAY_SIZE()

I'm sure most of us have wished at some point that ARRAY_SIZE() had existed in a central header file, like it does in many other open source projects. This series implements that.

Patches 01-04 round up the modules that #define ARRAY_SIZE() just for themselves, and wrap their definitions in #ifndef ARRAY_SIZE.

Patch 05 defines ARRAY_SIZE() in "MdePkg/Include/Base.h". This flips the previously modified modules to MdePkg's macro definition.

Patches 06-09 modify the same set of modules as patches 01-04 do; this time the (now unused) module-local ARRAY_SIZE() macro definitions are eliminated.

The rest of the patches (10-47) migrate the edk2 tree to ARRAY_SIZE(), covering the most obvious open-coded ARRAY_SIZE() expressions. These expressions were located and converted with the following shell
pipeline:

  git ls-files \
  | xargs --no-run-if-empty -- \
      sed --regexp-extended --in-place \
        --expression='s,sizeof \(([a-zA-Z0-9_]+)\) / sizeof \((\*\1|\1\[0\])\),ARRAY_SIZE (\1),g' \
        --

This pipeline lists all tracked files with "git". The pathnames are then composed with "xargs" into maximal length "sed" command lines, and those "sed" commands are run.

Here the "sed" stream editor filters and modifies all the listed files in place. The extended regular expression replaces the following two
patterns:

  sizeof (ArrayName) / sizeof (*ArrayName)
  sizeof (ArrayName) / sizeof (ArrayName[0])

with

  ARRAY_SIZE (ArrayName)

The regexp uses a backreference in the match, ensuring that the sizeof operator in the dividend and the sizeof operator in the divisor both refer to the same ArrayName. If there are multiple occurrences on the same line, the sed command replaces all of them.

I collected the changes into patches manually, and I reviewed them all.

I test-built all of the modified packages, repeating the command

  build -a X64 -t GCC48 -b DEBUG -p FooPkg/FooPkg.dsc

as many times as necessary. Two packages were impossible to build like
this: Nt32Pkg and Vlv2TbltDevicePkg, so I couldn't build-test them.

I did some light-weight testing with OVMF: boot with Secure Boot enabled, S3 suspend/resume with and without SMM. I also booted ArmVirtQemu once.

Repository: https://github.com/lersek/edk2.git
Branch:     array_size

Cc: Ard Biesheuvel <ard.biesheuvel@linaro.org>
Cc: Cecil Sheng <cecil.sheng@hpe.com>
Cc: Chao Zhang <chao.b.zhang@intel.com>
Cc: Dandan Bi <dandan.bi@intel.com>
Cc: Daryl McDaniel <edk2-lists@mc2research.org>
Cc: David Wei <david.wei@intel.com>
Cc: Eric Dong <eric.dong@intel.com>
Cc: Feng Tian <feng.tian@intel.com>
Cc: Gary Lin <glin@suse.com>
Cc: Jaben Carsey <jaben.carsey@intel.com>
Cc: Jeff Fan <jeff.fan@intel.com>
Cc: Jiaxin Wu <jiaxin.wu@intel.com>
Cc: Jordan Justen <jordan.l.justen@intel.com>
Cc: Liming Gao <liming.gao@intel.com>
Cc: Michael D Kinney <michael.d.kinney@intel.com>
Cc: Ruiyu Ni <ruiyu.ni@intel.com>
Cc: Siyuan Fu <siyuan.fu@intel.com>
Cc: Star Zeng <star.zeng@intel.com>
Cc: Tim He <tim.he@intel.com>

Thanks
Laszlo

Laszlo Ersek (47):
  MdeModulePkg/RegularExpressionDxe: guard the definition of ARRAY_SIZE
  NetworkPkg/IpsecConfig: guard the definition of ARRAY_SIZE
  OvmfPkg/PlatformBootManagerLib: guard the definition of ARRAY_SIZE
  OvmfPkg/XenBusDxe: guard the definition of ARRAY_SIZE
  MdePkg/Include/Base.h: introduce the ARRAY_SIZE() function-like macro
  MdeModulePkg/RegularExpressionDxe: remove module-local ARRAY_SIZE
    macro
  NetworkPkg/IpsecConfig: remove module-local ARRAY_SIZE macro
  OvmfPkg/PlatformBootManagerLib: remove module-local ARRAY_SIZE macro
  OvmfPkg/XenBusDxe: remove module-local ARRAY_SIZE macro
  ArmVirtPkg/NorFlashQemuLib: rebase to ARRAY_SIZE()
  DuetPkg/DuetBdsLib: rebase to ARRAY_SIZE()
  EdkCompatibilityPkg/FrameworkHiiOnUefiHiiThunk: rebase to ARRAY_SIZE()
  EdkCompatibilityPkg/Sample/Tools: rebase to ARRAY_SIZE()
  FatPkg/EnhancedFatDxe: rebase to ARRAY_SIZE()
  IntelFrameworkModulePkg/LegacyBootManagerLib: rebase to ARRAY_SIZE()
  IntelFrameworkModulePkg/BdsDxe: rebase to ARRAY_SIZE()
  MdeModulePkg/MemoryProfileInfo: rebase to ARRAY_SIZE()
  MdeModulePkg/PciBusDxe: rebase to ARRAY_SIZE()
  MdeModulePkg/PciHostBridgeDxe: rebase to ARRAY_SIZE()
  MdeModulePkg/UsbBusDxe: rebase to ARRAY_SIZE()
  MdeModulePkg/Core/Dxe: rebase to ARRAY_SIZE()
  MdeModulePkg/Core/PiSmmCore: rebase to ARRAY_SIZE()
  MdeModulePkg/BootMaintenanceManagerUiLib: rebase to ARRAY_SIZE()
  MdeModulePkg/BootManagerUiLib: rebase to ARRAY_SIZE()
  MdeModulePkg/UefiBootManagerLib: rebase to ARRAY_SIZE()
  MdeModulePkg/VarCheckHiiLib: rebase to ARRAY_SIZE()
  MdeModulePkg/Logo: rebase to ARRAY_SIZE()
  MdeModulePkg/BdsDxe: rebase to ARRAY_SIZE()
  MdeModulePkg/DisplayEngineDxe: rebase to ARRAY_SIZE()
  MdeModulePkg/EbcDxe: rebase to ARRAY_SIZE()
  MdeModulePkg/Tcp4Dxe: rebase to ARRAY_SIZE()
  MdeModulePkg/Variable/RuntimeDxe: rebase to ARRAY_SIZE()
  NetworkPkg/IScsiDxe: rebase to ARRAY_SIZE()
  NetworkPkg/TcpDxe: rebase to ARRAY_SIZE()
  Nt32Pkg/WinNtSerialIoDxe: rebase to ARRAY_SIZE()
  OptionRomPkg/AtapiPassThruDxe: rebase to ARRAY_SIZE()
  OvmfPkg/QemuBootOrderLib: rebase to ARRAY_SIZE()
  OvmfPkg/QemuVideoDxe: rebase to ARRAY_SIZE()
  PerformancePkg/Dp_App: rebase to ARRAY_SIZE()
  SecurityPkg/AuthVariableLib: rebase to ARRAY_SIZE()
  ShellPkg/UefiDpLib: rebase to ARRAY_SIZE()
  ShellPkg/UefiShellLevel2CommandsLib: rebase to ARRAY_SIZE()
  Vlv2TbltDevicePkg/FirmwareUpdate: rebase to ARRAY_SIZE()
  Vlv2TbltDevicePkg/PlatformInitPei: rebase to ARRAY_SIZE()
  Vlv2TbltDevicePkg/PlatformPei: rebase to ARRAY_SIZE()
  Vlv2TbltDevicePkg/PlatformSetupDxe: rebase to ARRAY_SIZE()
  Vlv2TbltDevicePkg/SmBiosMiscDxe: rebase to ARRAY_SIZE()

 ArmVirtPkg/Library/NorFlashQemuLib/NorFlashQemuLib.c                          |  2 +-
 DuetPkg/Library/DuetBdsLib/BdsPlatform.c                                      |  2 +-
 EdkCompatibilityPkg/Compatibility/FrameworkHiiOnUefiHiiThunk/OpcodeCreation.c |  2 +-
 EdkCompatibilityPkg/Sample/Tools/Source/EfiRom/EfiRom.c                       |  4 ++--
 EdkCompatibilityPkg/Sample/Tools/Source/HiiPack/IfrParse.c                    |  2 +-
 FatPkg/EnhancedFatDxe/DirectoryManage.c                                       |  4 ++--
 FatPkg/EnhancedFatDxe/FileName.c                                              |  4 ++--
 FatPkg/EnhancedFatDxe/Hash.c                                                  |  4 ++--
 IntelFrameworkModulePkg/Library/LegacyBootManagerLib/LegacyBm.c               |  2 +-
 IntelFrameworkModulePkg/Universal/BdsDxe/BdsEntry.c                           |  2 +-
 IntelFrameworkModulePkg/Universal/BdsDxe/BootMaint/BBSsupport.c               |  4 ++--
 IntelFrameworkModulePkg/Universal/BdsDxe/BootMaint/BootMaint.c                |  8 ++++----
 IntelFrameworkModulePkg/Universal/BdsDxe/BootMaint/BootOption.c               |  2 +-
 IntelFrameworkModulePkg/Universal/BdsDxe/BootMaint/ConsoleOption.c            |  6 +++---
 IntelFrameworkModulePkg/Universal/BdsDxe/BootMaint/UpdatePage.c               | 10 +++++-----
 IntelFrameworkModulePkg/Universal/BdsDxe/BootMaint/Variable.c                 |  2 +-
 IntelFrameworkModulePkg/Universal/BdsDxe/BootMngr/BootManager.c               |  2 +-
 MdeModulePkg/Application/MemoryProfileInfo/MemoryProfileInfo.c                |  6 +++---
 MdeModulePkg/Bus/Pci/PciBusDxe/PciLib.c                                       |  2 +-
 MdeModulePkg/Bus/Pci/PciHostBridgeDxe/PciHostBridge.c                         |  2 +-
 MdeModulePkg/Bus/Usb/UsbBusDxe/UsbHub.c                                       |  4 ++--
 MdeModulePkg/Core/Dxe/Mem/Pool.c                                              |  2 +-
 MdeModulePkg/Core/PiSmmCore/Pool.c                                            |  2 +-
 MdeModulePkg/Core/PiSmmCore/SmramProfileRecord.c                              |  6 +++---
 MdeModulePkg/Library/BootMaintenanceManagerUiLib/BootMaintenance.c            |  8 ++++----
 MdeModulePkg/Library/BootMaintenanceManagerUiLib/ConsoleOption.c              |  8 ++++----
 MdeModulePkg/Library/BootMaintenanceManagerUiLib/UpdatePage.c                 | 12 ++++++------
 MdeModulePkg/Library/BootMaintenanceManagerUiLib/Variable.c                   |  2 +-
 MdeModulePkg/Library/BootManagerUiLib/BootManager.c                           |  6 +++---
 MdeModulePkg/Library/UefiBootManagerLib/BmBootDescription.c                   |  2 +-
 MdeModulePkg/Library/UefiBootManagerLib/BmConsole.c                           |  2 +-
 MdeModulePkg/Library/UefiBootManagerLib/BmHotkey.c                            |  2 +-
 MdeModulePkg/Library/UefiBootManagerLib/BmLoadOption.c                        |  4 ++--
 MdeModulePkg/Library/VarCheckHiiLib/VarCheckHiiGen.c                          |  4 ++--
 MdeModulePkg/Library/VarCheckHiiLib/VarCheckHiiLibNullClass.c                 |  2 +-
 MdeModulePkg/Logo/Logo.c                                                      |  2 +-
 MdeModulePkg/Universal/BdsDxe/BdsEntry.c                                      |  2 +-
 MdeModulePkg/Universal/DisplayEngineDxe/FormDisplay.c                         |  4 ++--
 MdeModulePkg/Universal/DisplayEngineDxe/InputHandler.c                        |  6 +++---
 MdeModulePkg/Universal/EbcDxe/EbcExecute.c                                    |  2 +-
 MdeModulePkg/Universal/Network/Tcp4Dxe/Tcp4Output.c                           |  2 +-
 MdeModulePkg/Universal/RegularExpressionDxe/RegularExpressionDxe.h            |  2 --
 MdeModulePkg/Universal/Variable/RuntimeDxe/Variable.c                         |  2 +-
 MdePkg/Include/Base.h                                                         | 13 +++++++++++++
 NetworkPkg/Application/IpsecConfig/IpSecConfig.h                              |  2 --
 NetworkPkg/IScsiDxe/IScsiConfig.c                                             |  4 ++--
 NetworkPkg/IScsiDxe/IScsiDriver.c                                             |  2 +-
 NetworkPkg/IScsiDxe/IScsiMisc.c                                               |  6 +++---
 NetworkPkg/TcpDxe/TcpOutput.c                                                 |  2 +-
 Nt32Pkg/WinNtSerialIoDxe/WinNtSerialIo.c                                      |  2 +-
 OptionRomPkg/AtapiPassThruDxe/AtapiPassThru.c                                 |  4 ++--
 OvmfPkg/Library/PlatformBootManagerLib/BdsPlatform.c                          |  5 -----
 OvmfPkg/Library/QemuBootOrderLib/QemuBootOrderLib.c                           | 12 ++++++------
 OvmfPkg/QemuVideoDxe/Initialize.c                                             |  4 ++--
 OvmfPkg/XenBusDxe/XenStore.c                                                  |  1 -
 PerformancePkg/Dp_App/Dp.c                                                    |  2 +-
 PerformancePkg/Dp_App/DpTrace.c                                               | 10 +++++-----
 SecurityPkg/Library/AuthVariableLib/AuthVariableLib.c                         |  4 ++--
 ShellPkg/Library/UefiDpLib/DpTrace.c                                          | 10 +++++-----
 ShellPkg/Library/UefiShellLevel2CommandsLib/TimeDate.c                        |  2 +-
 Vlv2TbltDevicePkg/Application/FirmwareUpdate/FirmwareUpdate.c                 |  2 +-
 Vlv2TbltDevicePkg/PlatformInitPei/FlashMap.c                                  |  2 +-
 Vlv2TbltDevicePkg/PlatformPei/BootMode.c                                      |  6 +++---
 Vlv2TbltDevicePkg/PlatformSetupDxe/SetupInfoRecords.c                         |  2 +-
 Vlv2TbltDevicePkg/SmBiosMiscDxe/MiscOemType0x94Function.c                     |  2 +-
 65 files changed, 131 insertions(+), 128 deletions(-)

--
2.9.2



^ permalink raw reply	[flat|nested] 98+ messages in thread

* Re: [PATCH 13/47] EdkCompatibilityPkg/Sample/Tools: rebase to ARRAY_SIZE()
  2016-10-26 19:04 ` [PATCH 13/47] EdkCompatibilityPkg/Sample/Tools: " Laszlo Ersek
@ 2016-10-27  1:20   ` Gao, Liming
  0 siblings, 0 replies; 98+ messages in thread
From: Gao, Liming @ 2016-10-27  1:20 UTC (permalink / raw)
  To: Laszlo Ersek, edk2-devel-01

Reviewed-by: Liming Gao <liming.gao@intel.com>

-----Original Message-----
From: Laszlo Ersek [mailto:lersek@redhat.com] 
Sent: Thursday, October 27, 2016 3:05 AM
To: edk2-devel-01 <edk2-devel@ml01.01.org>
Cc: Gao, Liming <liming.gao@intel.com>
Subject: [PATCH 13/47] EdkCompatibilityPkg/Sample/Tools: rebase to ARRAY_SIZE()

Cc: Liming Gao <liming.gao@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Laszlo Ersek <lersek@redhat.com>
---
 EdkCompatibilityPkg/Sample/Tools/Source/EfiRom/EfiRom.c    | 4 ++--
 EdkCompatibilityPkg/Sample/Tools/Source/HiiPack/IfrParse.c | 2 +-
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/EdkCompatibilityPkg/Sample/Tools/Source/EfiRom/EfiRom.c b/EdkCompatibilityPkg/Sample/Tools/Source/EfiRom/EfiRom.c
index cf8efc86e1b4..f787ae81c2b3 100644
--- a/EdkCompatibilityPkg/Sample/Tools/Source/EfiRom/EfiRom.c
+++ b/EdkCompatibilityPkg/Sample/Tools/Source/EfiRom/EfiRom.c
@@ -397,8 +397,8 @@ GetCodeTypeStr (
   UINT8     CodeType
   )
 {
-  if (CodeType >= sizeof (mCodeTypeStr) / sizeof (*mCodeTypeStr)) {
-    CodeType = sizeof (mCodeTypeStr) / sizeof (*mCodeTypeStr) - 1;
+  if (CodeType >= ARRAY_SIZE (mCodeTypeStr)) {
+    CodeType = ARRAY_SIZE (mCodeTypeStr) - 1;
   }
   return mCodeTypeStr[CodeType];
 }
diff --git a/EdkCompatibilityPkg/Sample/Tools/Source/HiiPack/IfrParse.c b/EdkCompatibilityPkg/Sample/Tools/Source/HiiPack/IfrParse.c
index e69af5c25932..e60a2d9eeb30 100644
--- a/EdkCompatibilityPkg/Sample/Tools/Source/HiiPack/IfrParse.c
+++ b/EdkCompatibilityPkg/Sample/Tools/Source/HiiPack/IfrParse.c
@@ -470,7 +470,7 @@ static const IFR_PARSE_TABLE_ENTRY  mIfrParseTable[] = {
     IfrParse2A
   },
 };
-#define PARSE_TABLE_ENTRIES (sizeof (mIfrParseTable) / sizeof (mIfrParseTable[0]))
+#define PARSE_TABLE_ENTRIES (ARRAY_SIZE (mIfrParseTable))
 
 static
 STATUS
-- 
2.9.2




^ permalink raw reply related	[flat|nested] 98+ messages in thread

* Re: [PATCH 12/47] EdkCompatibilityPkg/FrameworkHiiOnUefiHiiThunk: rebase to ARRAY_SIZE()
  2016-10-26 19:04 ` [PATCH 12/47] EdkCompatibilityPkg/FrameworkHiiOnUefiHiiThunk: " Laszlo Ersek
@ 2016-10-27  1:20   ` Gao, Liming
  0 siblings, 0 replies; 98+ messages in thread
From: Gao, Liming @ 2016-10-27  1:20 UTC (permalink / raw)
  To: Laszlo Ersek, edk2-devel-01

Reviewed-by: Liming Gao <liming.gao@intel.com>

-----Original Message-----
From: Laszlo Ersek [mailto:lersek@redhat.com] 
Sent: Thursday, October 27, 2016 3:04 AM
To: edk2-devel-01 <edk2-devel@ml01.01.org>
Cc: Gao, Liming <liming.gao@intel.com>
Subject: [PATCH 12/47] EdkCompatibilityPkg/FrameworkHiiOnUefiHiiThunk: rebase to ARRAY_SIZE()

Cc: Liming Gao <liming.gao@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Laszlo Ersek <lersek@redhat.com>
---
 EdkCompatibilityPkg/Compatibility/FrameworkHiiOnUefiHiiThunk/OpcodeCreation.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/EdkCompatibilityPkg/Compatibility/FrameworkHiiOnUefiHiiThunk/OpcodeCreation.c b/EdkCompatibilityPkg/Compatibility/FrameworkHiiOnUefiHiiThunk/OpcodeCreation.c
index dd07dfcf40cf..a3ddce9b44ec 100644
--- a/EdkCompatibilityPkg/Compatibility/FrameworkHiiOnUefiHiiThunk/OpcodeCreation.c
+++ b/EdkCompatibilityPkg/Compatibility/FrameworkHiiOnUefiHiiThunk/OpcodeCreation.c
@@ -51,7 +51,7 @@ QuestionOpFwToUefi (
 {
   UINTN       Index;
 
-  for (Index = 0; Index < sizeof (QuestionOpcodeMap) / sizeof (QuestionOpcodeMap[0]); Index++) {
+  for (Index = 0; Index < ARRAY_SIZE (QuestionOpcodeMap); Index++) {
     if (FwOp == QuestionOpcodeMap[Index].FrameworkIfrOp) {
       *UefiOp = QuestionOpcodeMap[Index].UefiIfrOp;
       return EFI_SUCCESS;
-- 
2.9.2




^ permalink raw reply related	[flat|nested] 98+ messages in thread

* Re: [PATCH 41/47] ShellPkg/UefiDpLib: rebase to ARRAY_SIZE()
  2016-10-26 19:04 ` [PATCH 41/47] ShellPkg/UefiDpLib: " Laszlo Ersek
@ 2016-10-27  1:47   ` Ni, Ruiyu
  0 siblings, 0 replies; 98+ messages in thread
From: Ni, Ruiyu @ 2016-10-27  1:47 UTC (permalink / raw)
  To: Laszlo Ersek, edk2-devel-01; +Cc: Carsey, Jaben



Reviewed-by: Ruiyu Ni <ruiyu.ni@intel.com>
>-----Original Message-----
>From: Laszlo Ersek [mailto:lersek@redhat.com]
>Sent: Thursday, October 27, 2016 3:05 AM
>To: edk2-devel-01 <edk2-devel@ml01.01.org>
>Cc: Carsey, Jaben <jaben.carsey@intel.com>; Ni, Ruiyu <ruiyu.ni@intel.com>
>Subject: [PATCH 41/47] ShellPkg/UefiDpLib: rebase to ARRAY_SIZE()
>
>Cc: Jaben Carsey <jaben.carsey@intel.com>
>Cc: Ruiyu Ni <ruiyu.ni@intel.com>
>Contributed-under: TianoCore Contribution Agreement 1.0
>Signed-off-by: Laszlo Ersek <lersek@redhat.com>
>---
> ShellPkg/Library/UefiDpLib/DpTrace.c | 10 +++++-----
> 1 file changed, 5 insertions(+), 5 deletions(-)
>
>diff --git a/ShellPkg/Library/UefiDpLib/DpTrace.c b/ShellPkg/Library/UefiDpLib/DpTrace.c
>index f3f781fdb989..eca2ef309bbc 100644
>--- a/ShellPkg/Library/UefiDpLib/DpTrace.c
>+++ b/ShellPkg/Library/UefiDpLib/DpTrace.c
>@@ -220,8 +220,8 @@ DumpAllTrace(
>       ++Count;    // Count the number of records printed
>
>       // If Handle is non-zero, see if we can determine a name for the driver
>-      AsciiStrToUnicodeStrS (Measurement.Module, mGaugeString, sizeof (mGaugeString) / sizeof (mGaugeString[0])); //
>Use Module by default
>-      AsciiStrToUnicodeStrS (Measurement.Token, mUnicodeToken, sizeof (mUnicodeToken) / sizeof (mUnicodeToken[0]));
>+      AsciiStrToUnicodeStrS (Measurement.Module, mGaugeString, ARRAY_SIZE (mGaugeString)); // Use Module by
>default
>+      AsciiStrToUnicodeStrS (Measurement.Token, mUnicodeToken, ARRAY_SIZE (mUnicodeToken));
>       if (Measurement.Handle != NULL) {
>         // See if the Handle is in the HandleBuffer
>         for (TIndex = 0; TIndex < HandleCount; TIndex++) {
>@@ -595,7 +595,7 @@ ProcessHandles(
>         continue;
>       }
>       mGaugeString[0] = 0;    // Empty driver name by default
>-      AsciiStrToUnicodeStrS (Measurement.Token, mUnicodeToken, sizeof (mUnicodeToken) / sizeof (mUnicodeToken[0]));
>+      AsciiStrToUnicodeStrS (Measurement.Token, mUnicodeToken, ARRAY_SIZE (mUnicodeToken));
>       // See if the Handle is in the HandleBuffer
>       for (Index = 0; Index < HandleCount; Index++) {
>         if (Measurement.Handle == HandleBuffer[Index]) {
>@@ -776,8 +776,8 @@ ProcessGlobal(
>                           &Measurement.EndTimeStamp,
>                           &Measurement.Identifier)) != 0)
>   {
>-    AsciiStrToUnicodeStrS (Measurement.Module, mGaugeString, sizeof (mGaugeString) / sizeof (mGaugeString[0]));
>-    AsciiStrToUnicodeStrS (Measurement.Token, mUnicodeToken, sizeof (mUnicodeToken) / sizeof (mUnicodeToken[0]));
>+    AsciiStrToUnicodeStrS (Measurement.Module, mGaugeString, ARRAY_SIZE (mGaugeString));
>+    AsciiStrToUnicodeStrS (Measurement.Token, mUnicodeToken, ARRAY_SIZE (mUnicodeToken));
>     mGaugeString[25] = 0;
>     mUnicodeToken[31] = 0;
>     if ( ! ( IsPhase( &Measurement)  ||
>--
>2.9.2
>



^ permalink raw reply	[flat|nested] 98+ messages in thread

* Re: [PATCH 42/47] ShellPkg/UefiShellLevel2CommandsLib: rebase to ARRAY_SIZE()
  2016-10-26 19:04 ` [PATCH 42/47] ShellPkg/UefiShellLevel2CommandsLib: " Laszlo Ersek
@ 2016-10-27  1:47   ` Ni, Ruiyu
  0 siblings, 0 replies; 98+ messages in thread
From: Ni, Ruiyu @ 2016-10-27  1:47 UTC (permalink / raw)
  To: Laszlo Ersek, edk2-devel-01; +Cc: Carsey, Jaben



Reviewed-by: Ruiyu Ni <ruiyu.ni@intel.com>
>-----Original Message-----
>From: Laszlo Ersek [mailto:lersek@redhat.com]
>Sent: Thursday, October 27, 2016 3:05 AM
>To: edk2-devel-01 <edk2-devel@ml01.01.org>
>Cc: Carsey, Jaben <jaben.carsey@intel.com>; Ni, Ruiyu <ruiyu.ni@intel.com>
>Subject: [PATCH 42/47] ShellPkg/UefiShellLevel2CommandsLib: rebase to ARRAY_SIZE()
>
>Cc: Jaben Carsey <jaben.carsey@intel.com>
>Cc: Ruiyu Ni <ruiyu.ni@intel.com>
>Contributed-under: TianoCore Contribution Agreement 1.0
>Signed-off-by: Laszlo Ersek <lersek@redhat.com>
>---
> ShellPkg/Library/UefiShellLevel2CommandsLib/TimeDate.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
>diff --git a/ShellPkg/Library/UefiShellLevel2CommandsLib/TimeDate.c
>b/ShellPkg/Library/UefiShellLevel2CommandsLib/TimeDate.c
>index 3ebc72a0afa8..5383cffe879c 100644
>--- a/ShellPkg/Library/UefiShellLevel2CommandsLib/TimeDate.c
>+++ b/ShellPkg/Library/UefiShellLevel2CommandsLib/TimeDate.c
>@@ -942,7 +942,7 @@ ShellCommandRunTimeZone (
>         //
>         if (ShellCommandLineGetFlag (Package, L"-f")) {
>           for ( LoopVar = 0
>-              ; LoopVar < sizeof (TimeZoneList) / sizeof (TimeZoneList[0])
>+              ; LoopVar < ARRAY_SIZE (TimeZoneList)
>               ; LoopVar++
>              ){
>             if (TheTime.TimeZone == TimeZoneList[LoopVar].TimeZone) {
>--
>2.9.2
>



^ permalink raw reply	[flat|nested] 98+ messages in thread

* Re: [PATCH 36/47] OptionRomPkg/AtapiPassThruDxe: rebase to ARRAY_SIZE()
  2016-10-26 19:04 ` [PATCH 36/47] OptionRomPkg/AtapiPassThruDxe: " Laszlo Ersek
@ 2016-10-27  1:47   ` Ni, Ruiyu
  0 siblings, 0 replies; 98+ messages in thread
From: Ni, Ruiyu @ 2016-10-27  1:47 UTC (permalink / raw)
  To: Laszlo Ersek, edk2-devel-01



Reviewed-by: Ruiyu Ni <ruiyu.ni@intel.com>
>-----Original Message-----
>From: Laszlo Ersek [mailto:lersek@redhat.com]
>Sent: Thursday, October 27, 2016 3:05 AM
>To: edk2-devel-01 <edk2-devel@ml01.01.org>
>Cc: Ni, Ruiyu <ruiyu.ni@intel.com>
>Subject: [PATCH 36/47] OptionRomPkg/AtapiPassThruDxe: rebase to ARRAY_SIZE()
>
>Cc: Ruiyu Ni <ruiyu.ni@intel.com>
>Contributed-under: TianoCore Contribution Agreement 1.0
>Signed-off-by: Laszlo Ersek <lersek@redhat.com>
>---
> OptionRomPkg/AtapiPassThruDxe/AtapiPassThru.c | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
>
>diff --git a/OptionRomPkg/AtapiPassThruDxe/AtapiPassThru.c b/OptionRomPkg/AtapiPassThruDxe/AtapiPassThru.c
>index 3578a1e4459c..e2654e5c2566 100644
>--- a/OptionRomPkg/AtapiPassThruDxe/AtapiPassThru.c
>+++ b/OptionRomPkg/AtapiPassThruDxe/AtapiPassThru.c
>@@ -1752,7 +1752,7 @@ Returns:
>   UINT8 ArrayLen;
>
>   OpCode = (UINT8 *) (Packet->Cdb);
>-  ArrayLen = (UINT8) (sizeof (gSupportedATAPICommands) / sizeof (gSupportedATAPICommands[0]));
>+  ArrayLen = (UINT8) (ARRAY_SIZE (gSupportedATAPICommands));
>
>   for (Index = 0; (Index < ArrayLen) && (CompareMem (&gSupportedATAPICommands[Index], &gEndTable, sizeof
>(SCSI_COMMAND_SET)) != 0); Index++) {
>
>@@ -1995,7 +1995,7 @@ Returns:
>   UINT8 ArrayLen;
>
>   OpCode = (UINT8 *) (Packet->Cdb);
>-  ArrayLen = (UINT8) (sizeof (gSupportedATAPICommands) / sizeof (gSupportedATAPICommands[0]));
>+  ArrayLen = (UINT8) (ARRAY_SIZE (gSupportedATAPICommands));
>
>   for (Index = 0; (Index < ArrayLen) && (CompareMem (&gSupportedATAPICommands[Index], &gEndTable, sizeof
>(SCSI_COMMAND_SET)) != 0); Index++) {
>
>--
>2.9.2
>



^ permalink raw reply	[flat|nested] 98+ messages in thread

* Re: [PATCH 35/47] Nt32Pkg/WinNtSerialIoDxe: rebase to ARRAY_SIZE()
  2016-10-26 19:04 ` [PATCH 35/47] Nt32Pkg/WinNtSerialIoDxe: " Laszlo Ersek
@ 2016-10-27  1:49   ` Ni, Ruiyu
  0 siblings, 0 replies; 98+ messages in thread
From: Ni, Ruiyu @ 2016-10-27  1:49 UTC (permalink / raw)
  To: Laszlo Ersek, edk2-devel-01

Reviewed-by: Ruiyu Ni <ruiyu.ni@intel.com>

Regards,
Ray

>-----Original Message-----
>From: Laszlo Ersek [mailto:lersek@redhat.com]
>Sent: Thursday, October 27, 2016 3:05 AM
>To: edk2-devel-01 <edk2-devel@ml01.01.org>
>Cc: Ni, Ruiyu <ruiyu.ni@intel.com>
>Subject: [PATCH 35/47] Nt32Pkg/WinNtSerialIoDxe: rebase to ARRAY_SIZE()
>
>Cc: Ruiyu Ni <ruiyu.ni@intel.com>
>Contributed-under: TianoCore Contribution Agreement 1.0
>Signed-off-by: Laszlo Ersek <lersek@redhat.com>
>---
> Nt32Pkg/WinNtSerialIoDxe/WinNtSerialIo.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
>diff --git a/Nt32Pkg/WinNtSerialIoDxe/WinNtSerialIo.c b/Nt32Pkg/WinNtSerialIoDxe/WinNtSerialIo.c
>index 0dc031393e71..23d3329d9db1 100644
>--- a/Nt32Pkg/WinNtSerialIoDxe/WinNtSerialIo.c
>+++ b/Nt32Pkg/WinNtSerialIoDxe/WinNtSerialIo.c
>@@ -984,7 +984,7 @@ Returns:
>   //The lower baud rate supported by the serial device will be selected without exceeding the unsupported BaudRate
>parameter
>   //
>
>-  for (Index = 1; Index < (sizeof (mBaudRateCurrentSupport) / sizeof (mBaudRateCurrentSupport[0])); Index++) {
>+  for (Index = 1; Index < (ARRAY_SIZE (mBaudRateCurrentSupport)); Index++) {
>     if (BaudRate < mBaudRateCurrentSupport[Index]) {
>       BaudRate = mBaudRateCurrentSupport[Index-1];
>       break;
>--
>2.9.2
>



^ permalink raw reply	[flat|nested] 98+ messages in thread

* Re: [PATCH 19/47] MdeModulePkg/PciHostBridgeDxe: rebase to ARRAY_SIZE()
  2016-10-26 19:04 ` [PATCH 19/47] MdeModulePkg/PciHostBridgeDxe: " Laszlo Ersek
@ 2016-10-27  1:49   ` Ni, Ruiyu
  0 siblings, 0 replies; 98+ messages in thread
From: Ni, Ruiyu @ 2016-10-27  1:49 UTC (permalink / raw)
  To: Laszlo Ersek, edk2-devel-01; +Cc: Tian, Feng, Zeng, Star

Reviewed-by: Ruiyu Ni <ruiyu.ni@intel.com>

Regards,
Ray

>-----Original Message-----
>From: Laszlo Ersek [mailto:lersek@redhat.com]
>Sent: Thursday, October 27, 2016 3:05 AM
>To: edk2-devel-01 <edk2-devel@ml01.01.org>
>Cc: Tian, Feng <feng.tian@intel.com>; Ni, Ruiyu <ruiyu.ni@intel.com>; Zeng, Star <star.zeng@intel.com>
>Subject: [PATCH 19/47] MdeModulePkg/PciHostBridgeDxe: rebase to ARRAY_SIZE()
>
>Cc: Feng Tian <feng.tian@intel.com>
>Cc: Ruiyu Ni <ruiyu.ni@intel.com>
>Cc: Star Zeng <star.zeng@intel.com>
>Contributed-under: TianoCore Contribution Agreement 1.0
>Signed-off-by: Laszlo Ersek <lersek@redhat.com>
>---
> MdeModulePkg/Bus/Pci/PciHostBridgeDxe/PciHostBridge.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
>diff --git a/MdeModulePkg/Bus/Pci/PciHostBridgeDxe/PciHostBridge.c
>b/MdeModulePkg/Bus/Pci/PciHostBridgeDxe/PciHostBridge.c
>index c866e8801607..9005deeac225 100644
>--- a/MdeModulePkg/Bus/Pci/PciHostBridgeDxe/PciHostBridge.c
>+++ b/MdeModulePkg/Bus/Pci/PciHostBridgeDxe/PciHostBridge.c
>@@ -415,7 +415,7 @@ InitializePciHostBridge (
>     MemApertures[2] = &RootBridges[Index].PMem;
>     MemApertures[3] = &RootBridges[Index].PMemAbove4G;
>
>-    for (MemApertureIndex = 0; MemApertureIndex < sizeof (MemApertures) / sizeof (MemApertures[0]);
>MemApertureIndex++) {
>+    for (MemApertureIndex = 0; MemApertureIndex < ARRAY_SIZE (MemApertures); MemApertureIndex++) {
>       if (MemApertures[MemApertureIndex]->Base <= MemApertures[MemApertureIndex]->Limit) {
>         Status = AddMemoryMappedIoSpace (
>                    MemApertures[MemApertureIndex]->Base,
>--
>2.9.2
>



^ permalink raw reply	[flat|nested] 98+ messages in thread

* Re: [PATCH 28/47] MdeModulePkg/BdsDxe: rebase to ARRAY_SIZE()
  2016-10-26 19:04 ` [PATCH 28/47] MdeModulePkg/BdsDxe: " Laszlo Ersek
@ 2016-10-27  1:50   ` Ni, Ruiyu
  2016-10-27  1:50   ` Ni, Ruiyu
  1 sibling, 0 replies; 98+ messages in thread
From: Ni, Ruiyu @ 2016-10-27  1:50 UTC (permalink / raw)
  To: Laszlo Ersek, edk2-devel-01; +Cc: Tian, Feng, Zeng, Star

Reviewed-by: Ruiyu Ni <ruiyu.ni@intel.com>

Regards,
Ray

>-----Original Message-----
>From: Laszlo Ersek [mailto:lersek@redhat.com]
>Sent: Thursday, October 27, 2016 3:05 AM
>To: edk2-devel-01 <edk2-devel@ml01.01.org>
>Cc: Tian, Feng <feng.tian@intel.com>; Ni, Ruiyu <ruiyu.ni@intel.com>; Zeng, Star <star.zeng@intel.com>
>Subject: [PATCH 28/47] MdeModulePkg/BdsDxe: rebase to ARRAY_SIZE()
>
>Cc: Feng Tian <feng.tian@intel.com>
>Cc: Ruiyu Ni <ruiyu.ni@intel.com>
>Cc: Star Zeng <star.zeng@intel.com>
>Contributed-under: TianoCore Contribution Agreement 1.0
>Signed-off-by: Laszlo Ersek <lersek@redhat.com>
>---
> MdeModulePkg/Universal/BdsDxe/BdsEntry.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
>diff --git a/MdeModulePkg/Universal/BdsDxe/BdsEntry.c b/MdeModulePkg/Universal/BdsDxe/BdsEntry.c
>index c86cd7a576ad..aacc4a64794d 100644
>--- a/MdeModulePkg/Universal/BdsDxe/BdsEntry.c
>+++ b/MdeModulePkg/Universal/BdsDxe/BdsEntry.c
>@@ -654,7 +654,7 @@ BdsEntry (
>   Status = gBS->LocateProtocol (&gEdkiiVariableLockProtocolGuid, NULL, (VOID **) &VariableLock);
>   DEBUG ((EFI_D_INFO, "[BdsDxe] Locate Variable Lock protocol - %r\n", Status));
>   if (!EFI_ERROR (Status)) {
>-    for (Index = 0; Index < sizeof (mReadOnlyVariables) / sizeof (mReadOnlyVariables[0]); Index++) {
>+    for (Index = 0; Index < ARRAY_SIZE (mReadOnlyVariables); Index++) {
>       Status = VariableLock->RequestToLock (VariableLock, mReadOnlyVariables[Index], &gEfiGlobalVariableGuid);
>       ASSERT_EFI_ERROR (Status);
>     }
>--
>2.9.2
>



^ permalink raw reply	[flat|nested] 98+ messages in thread

* Re: [PATCH 28/47] MdeModulePkg/BdsDxe: rebase to ARRAY_SIZE()
  2016-10-26 19:04 ` [PATCH 28/47] MdeModulePkg/BdsDxe: " Laszlo Ersek
  2016-10-27  1:50   ` Ni, Ruiyu
@ 2016-10-27  1:50   ` Ni, Ruiyu
  1 sibling, 0 replies; 98+ messages in thread
From: Ni, Ruiyu @ 2016-10-27  1:50 UTC (permalink / raw)
  To: Laszlo Ersek, edk2-devel-01; +Cc: Tian, Feng, Zeng, Star

Reviewed-by: Ruiyu Ni <ruiyu.ni@intel.com>

Regards,
Ray

>-----Original Message-----
>From: Laszlo Ersek [mailto:lersek@redhat.com]
>Sent: Thursday, October 27, 2016 3:05 AM
>To: edk2-devel-01 <edk2-devel@ml01.01.org>
>Cc: Tian, Feng <feng.tian@intel.com>; Ni, Ruiyu <ruiyu.ni@intel.com>; Zeng, Star <star.zeng@intel.com>
>Subject: [PATCH 28/47] MdeModulePkg/BdsDxe: rebase to ARRAY_SIZE()
>
>Cc: Feng Tian <feng.tian@intel.com>
>Cc: Ruiyu Ni <ruiyu.ni@intel.com>
>Cc: Star Zeng <star.zeng@intel.com>
>Contributed-under: TianoCore Contribution Agreement 1.0
>Signed-off-by: Laszlo Ersek <lersek@redhat.com>
>---
> MdeModulePkg/Universal/BdsDxe/BdsEntry.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
>diff --git a/MdeModulePkg/Universal/BdsDxe/BdsEntry.c b/MdeModulePkg/Universal/BdsDxe/BdsEntry.c
>index c86cd7a576ad..aacc4a64794d 100644
>--- a/MdeModulePkg/Universal/BdsDxe/BdsEntry.c
>+++ b/MdeModulePkg/Universal/BdsDxe/BdsEntry.c
>@@ -654,7 +654,7 @@ BdsEntry (
>   Status = gBS->LocateProtocol (&gEdkiiVariableLockProtocolGuid, NULL, (VOID **) &VariableLock);
>   DEBUG ((EFI_D_INFO, "[BdsDxe] Locate Variable Lock protocol - %r\n", Status));
>   if (!EFI_ERROR (Status)) {
>-    for (Index = 0; Index < sizeof (mReadOnlyVariables) / sizeof (mReadOnlyVariables[0]); Index++) {
>+    for (Index = 0; Index < ARRAY_SIZE (mReadOnlyVariables); Index++) {
>       Status = VariableLock->RequestToLock (VariableLock, mReadOnlyVariables[Index], &gEfiGlobalVariableGuid);
>       ASSERT_EFI_ERROR (Status);
>     }
>--
>2.9.2
>



^ permalink raw reply	[flat|nested] 98+ messages in thread

* Re: [PATCH 25/47] MdeModulePkg/UefiBootManagerLib: rebase to ARRAY_SIZE()
  2016-10-26 19:04 ` [PATCH 25/47] MdeModulePkg/UefiBootManagerLib: " Laszlo Ersek
@ 2016-10-27  1:50   ` Ni, Ruiyu
  0 siblings, 0 replies; 98+ messages in thread
From: Ni, Ruiyu @ 2016-10-27  1:50 UTC (permalink / raw)
  To: Laszlo Ersek, edk2-devel-01; +Cc: Tian, Feng, Zeng, Star

Reviewed-by: Ruiyu Ni <ruiyu.ni@intel.com>

Regards,
Ray

>-----Original Message-----
>From: Laszlo Ersek [mailto:lersek@redhat.com]
>Sent: Thursday, October 27, 2016 3:05 AM
>To: edk2-devel-01 <edk2-devel@ml01.01.org>
>Cc: Tian, Feng <feng.tian@intel.com>; Ni, Ruiyu <ruiyu.ni@intel.com>; Zeng, Star <star.zeng@intel.com>
>Subject: [PATCH 25/47] MdeModulePkg/UefiBootManagerLib: rebase to ARRAY_SIZE()
>
>Cc: Feng Tian <feng.tian@intel.com>
>Cc: Ruiyu Ni <ruiyu.ni@intel.com>
>Cc: Star Zeng <star.zeng@intel.com>
>Contributed-under: TianoCore Contribution Agreement 1.0
>Signed-off-by: Laszlo Ersek <lersek@redhat.com>
>---
> MdeModulePkg/Library/UefiBootManagerLib/BmBootDescription.c | 2 +-
> MdeModulePkg/Library/UefiBootManagerLib/BmConsole.c         | 2 +-
> MdeModulePkg/Library/UefiBootManagerLib/BmHotkey.c          | 2 +-
> MdeModulePkg/Library/UefiBootManagerLib/BmLoadOption.c      | 4 ++--
> 4 files changed, 5 insertions(+), 5 deletions(-)
>
>diff --git a/MdeModulePkg/Library/UefiBootManagerLib/BmBootDescription.c
>b/MdeModulePkg/Library/UefiBootManagerLib/BmBootDescription.c
>index f086764f24da..050647d8f186 100644
>--- a/MdeModulePkg/Library/UefiBootManagerLib/BmBootDescription.c
>+++ b/MdeModulePkg/Library/UefiBootManagerLib/BmBootDescription.c
>@@ -632,7 +632,7 @@ BmGetBootDescription (
>   // Firstly get the default boot description
>   //
>   DefaultDescription = NULL;
>-  for (Index = 0; Index < sizeof (mBmBootDescriptionHandlers) / sizeof (mBmBootDescriptionHandlers[0]); Index++) {
>+  for (Index = 0; Index < ARRAY_SIZE (mBmBootDescriptionHandlers); Index++) {
>     DefaultDescription = mBmBootDescriptionHandlers[Index] (Handle);
>     if (DefaultDescription != NULL) {
>       //
>diff --git a/MdeModulePkg/Library/UefiBootManagerLib/BmConsole.c
>b/MdeModulePkg/Library/UefiBootManagerLib/BmConsole.c
>index a13917bd0844..43895e10f85b 100644
>--- a/MdeModulePkg/Library/UefiBootManagerLib/BmConsole.c
>+++ b/MdeModulePkg/Library/UefiBootManagerLib/BmConsole.c
>@@ -430,7 +430,7 @@ EfiBootManagerUpdateConsoleVariable (
>   EFI_DEVICE_PATH_PROTOCOL  *NewDevicePath;
>   EFI_DEVICE_PATH_PROTOCOL  *TempNewDevicePath;
>
>-  if (ConsoleType >= sizeof (mConVarName) / sizeof (mConVarName[0])) {
>+  if (ConsoleType >= ARRAY_SIZE (mConVarName)) {
>     return EFI_INVALID_PARAMETER;
>   }
>
>diff --git a/MdeModulePkg/Library/UefiBootManagerLib/BmHotkey.c
>b/MdeModulePkg/Library/UefiBootManagerLib/BmHotkey.c
>index 55df7e9a5f31..35131a94f61d 100644
>--- a/MdeModulePkg/Library/UefiBootManagerLib/BmHotkey.c
>+++ b/MdeModulePkg/Library/UefiBootManagerLib/BmHotkey.c
>@@ -680,7 +680,7 @@ BmProcessKeyOption (
>
>   KeyShiftStateCount = 0;
>   BmGenerateKeyShiftState (0, KeyOption, EFI_SHIFT_STATE_VALID, KeyShiftStates, &KeyShiftStateCount);
>-  ASSERT (KeyShiftStateCount <= sizeof (KeyShiftStates) / sizeof (KeyShiftStates[0]));
>+  ASSERT (KeyShiftStateCount <= ARRAY_SIZE (KeyShiftStates));
>
>   EfiAcquireLock (&mBmHotkeyLock);
>
>diff --git a/MdeModulePkg/Library/UefiBootManagerLib/BmLoadOption.c
>b/MdeModulePkg/Library/UefiBootManagerLib/BmLoadOption.c
>index 9af98de0afaf..e638e5fc67e6 100644
>--- a/MdeModulePkg/Library/UefiBootManagerLib/BmLoadOption.c
>+++ b/MdeModulePkg/Library/UefiBootManagerLib/BmLoadOption.c
>@@ -796,7 +796,7 @@ EfiBootManagerIsValidLoadOptionVariableName (
>     return FALSE;
>   }
>
>-  for (Index = 0; Index < sizeof (mBmLoadOptionName) / sizeof (mBmLoadOptionName[0]); Index++) {
>+  for (Index = 0; Index < ARRAY_SIZE (mBmLoadOptionName); Index++) {
>     if ((VariableNameLen - 4 == StrLen (mBmLoadOptionName[Index])) &&
>         (StrnCmp (VariableName, mBmLoadOptionName[Index], VariableNameLen - 4) == 0)
>         ) {
>@@ -804,7 +804,7 @@ EfiBootManagerIsValidLoadOptionVariableName (
>     }
>   }
>
>-  if (Index == sizeof (mBmLoadOptionName) / sizeof (mBmLoadOptionName[0])) {
>+  if (Index == ARRAY_SIZE (mBmLoadOptionName)) {
>     return FALSE;
>   }
>
>--
>2.9.2
>



^ permalink raw reply	[flat|nested] 98+ messages in thread

* Re: [PATCH 27/47] MdeModulePkg/Logo: rebase to ARRAY_SIZE()
  2016-10-26 19:04 ` [PATCH 27/47] MdeModulePkg/Logo: " Laszlo Ersek
@ 2016-10-27  1:53   ` Ni, Ruiyu
  0 siblings, 0 replies; 98+ messages in thread
From: Ni, Ruiyu @ 2016-10-27  1:53 UTC (permalink / raw)
  To: Laszlo Ersek, edk2-devel-01; +Cc: Tian, Feng, Zeng, Star

Reviewed-by: Ruiyu Ni <ruiyu.ni@intel.com>

Regards,
Ray

>-----Original Message-----
>From: Laszlo Ersek [mailto:lersek@redhat.com]
>Sent: Thursday, October 27, 2016 3:05 AM
>To: edk2-devel-01 <edk2-devel@ml01.01.org>
>Cc: Tian, Feng <feng.tian@intel.com>; Ni, Ruiyu <ruiyu.ni@intel.com>; Zeng, Star <star.zeng@intel.com>
>Subject: [PATCH 27/47] MdeModulePkg/Logo: rebase to ARRAY_SIZE()
>
>Cc: Feng Tian <feng.tian@intel.com>
>Cc: Ruiyu Ni <ruiyu.ni@intel.com>
>Cc: Star Zeng <star.zeng@intel.com>
>Contributed-under: TianoCore Contribution Agreement 1.0
>Signed-off-by: Laszlo Ersek <lersek@redhat.com>
>---
> MdeModulePkg/Logo/Logo.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
>diff --git a/MdeModulePkg/Logo/Logo.c b/MdeModulePkg/Logo/Logo.c
>index f0792addd3a9..313dd4a7937d 100644
>--- a/MdeModulePkg/Logo/Logo.c
>+++ b/MdeModulePkg/Logo/Logo.c
>@@ -69,7 +69,7 @@ GetImage (
>   }
>
>   Current = *Instance;
>-  if (Current >= sizeof (mLogos) / sizeof (mLogos[0])) {
>+  if (Current >= ARRAY_SIZE (mLogos)) {
>     return EFI_NOT_FOUND;
>   }
>
>--
>2.9.2
>



^ permalink raw reply	[flat|nested] 98+ messages in thread

* Re: [PATCH 14/47] FatPkg/EnhancedFatDxe: rebase to ARRAY_SIZE()
  2016-10-26 19:04 ` [PATCH 14/47] FatPkg/EnhancedFatDxe: " Laszlo Ersek
@ 2016-10-27  1:53   ` Ni, Ruiyu
  0 siblings, 0 replies; 98+ messages in thread
From: Ni, Ruiyu @ 2016-10-27  1:53 UTC (permalink / raw)
  To: Laszlo Ersek, edk2-devel-01

Reviewed-by: Ruiyu Ni <ruiyu.ni@intel.com>

Regards,
Ray

>-----Original Message-----
>From: Laszlo Ersek [mailto:lersek@redhat.com]
>Sent: Thursday, October 27, 2016 3:05 AM
>To: edk2-devel-01 <edk2-devel@ml01.01.org>
>Cc: Ni, Ruiyu <ruiyu.ni@intel.com>
>Subject: [PATCH 14/47] FatPkg/EnhancedFatDxe: rebase to ARRAY_SIZE()
>
>Cc: Ruiyu Ni <ruiyu.ni@intel.com>
>Contributed-under: TianoCore Contribution Agreement 1.0
>Signed-off-by: Laszlo Ersek <lersek@redhat.com>
>---
> FatPkg/EnhancedFatDxe/DirectoryManage.c | 4 ++--
> FatPkg/EnhancedFatDxe/FileName.c        | 4 ++--
> FatPkg/EnhancedFatDxe/Hash.c            | 4 ++--
> 3 files changed, 6 insertions(+), 6 deletions(-)
>
>diff --git a/FatPkg/EnhancedFatDxe/DirectoryManage.c b/FatPkg/EnhancedFatDxe/DirectoryManage.c
>index 91e7599e2722..3328ae31fed9 100644
>--- a/FatPkg/EnhancedFatDxe/DirectoryManage.c
>+++ b/FatPkg/EnhancedFatDxe/DirectoryManage.c
>@@ -118,7 +118,7 @@ Returns:
>     SetMem (LfnBuffer, sizeof (CHAR16) * LFN_CHAR_TOTAL * EntryCount, 0xff);
>     Status = StrCpyS (
>                LfnBuffer,
>-               sizeof (LfnBuffer) / sizeof (LfnBuffer[0]),
>+               ARRAY_SIZE (LfnBuffer),
>                DirEnt->FileString
>                );
>     if (EFI_ERROR (Status)) {
>@@ -360,7 +360,7 @@ Returns:
>     FatGetFileNameViaCaseFlag (
>       DirEnt,
>       LfnBuffer,
>-      sizeof (LfnBuffer) / sizeof (LfnBuffer[0])
>+      ARRAY_SIZE (LfnBuffer)
>       );
>   }
>
>diff --git a/FatPkg/EnhancedFatDxe/FileName.c b/FatPkg/EnhancedFatDxe/FileName.c
>index 551cda53b9a4..5df403625d64 100644
>--- a/FatPkg/EnhancedFatDxe/FileName.c
>+++ b/FatPkg/EnhancedFatDxe/FileName.c
>@@ -310,7 +310,7 @@ Returns:
>   // Lower case a copy of the string, if it matches the
>   // original then the string is lower case
>   //
>-  StrCpyS (Buffer, sizeof (Buffer) / sizeof (Buffer[0]), Str);
>+  StrCpyS (Buffer, ARRAY_SIZE (Buffer), Str);
>   FatStrLwr (Buffer);
>   if (StrCmp (Str, Buffer) == 0) {
>     OutCaseFlag = InCaseFlag;
>@@ -319,7 +319,7 @@ Returns:
>   // Upper case a copy of the string, if it matches the
>   // original then the string is upper case
>   //
>-  StrCpyS (Buffer, sizeof (Buffer) / sizeof (Buffer[0]), Str);
>+  StrCpyS (Buffer, ARRAY_SIZE (Buffer), Str);
>   FatStrUpr (Buffer);
>   if (StrCmp (Str, Buffer) == 0) {
>     OutCaseFlag = 0;
>diff --git a/FatPkg/EnhancedFatDxe/Hash.c b/FatPkg/EnhancedFatDxe/Hash.c
>index 3d0ffe6fb879..f827368ef5eb 100644
>--- a/FatPkg/EnhancedFatDxe/Hash.c
>+++ b/FatPkg/EnhancedFatDxe/Hash.c
>@@ -49,9 +49,9 @@ Returns:
>   CHAR16  UpCasedLongFileName[EFI_PATH_STRING_LENGTH];
>   StrnCpyS (
>     UpCasedLongFileName,
>-    sizeof (UpCasedLongFileName) / sizeof (UpCasedLongFileName[0]),
>+    ARRAY_SIZE (UpCasedLongFileName),
>     LongNameString,
>-    sizeof (UpCasedLongFileName) / sizeof (UpCasedLongFileName[0]) - 1
>+    ARRAY_SIZE (UpCasedLongFileName) - 1
>     );
>   FatStrUpr (UpCasedLongFileName);
>   gBS->CalculateCrc32 (UpCasedLongFileName, StrSize (UpCasedLongFileName), &HashValue);
>--
>2.9.2
>



^ permalink raw reply	[flat|nested] 98+ messages in thread

* Re: [PATCH 18/47] MdeModulePkg/PciBusDxe: rebase to ARRAY_SIZE()
  2016-10-26 19:04 ` [PATCH 18/47] MdeModulePkg/PciBusDxe: " Laszlo Ersek
@ 2016-10-27  1:53   ` Ni, Ruiyu
  0 siblings, 0 replies; 98+ messages in thread
From: Ni, Ruiyu @ 2016-10-27  1:53 UTC (permalink / raw)
  To: Laszlo Ersek, edk2-devel-01; +Cc: Tian, Feng, Zeng, Star

Reviewed-by: Ruiyu Ni <ruiyu.ni@intel.com>

Regards,
Ray

>-----Original Message-----
>From: Laszlo Ersek [mailto:lersek@redhat.com]
>Sent: Thursday, October 27, 2016 3:05 AM
>To: edk2-devel-01 <edk2-devel@ml01.01.org>
>Cc: Tian, Feng <feng.tian@intel.com>; Ni, Ruiyu <ruiyu.ni@intel.com>; Zeng, Star <star.zeng@intel.com>
>Subject: [PATCH 18/47] MdeModulePkg/PciBusDxe: rebase to ARRAY_SIZE()
>
>Cc: Feng Tian <feng.tian@intel.com>
>Cc: Ruiyu Ni <ruiyu.ni@intel.com>
>Cc: Star Zeng <star.zeng@intel.com>
>Contributed-under: TianoCore Contribution Agreement 1.0
>Signed-off-by: Laszlo Ersek <lersek@redhat.com>
>---
> MdeModulePkg/Bus/Pci/PciBusDxe/PciLib.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
>diff --git a/MdeModulePkg/Bus/Pci/PciBusDxe/PciLib.c b/MdeModulePkg/Bus/Pci/PciBusDxe/PciLib.c
>index 337a6db7defa..4d297fdb23c7 100644
>--- a/MdeModulePkg/Bus/Pci/PciBusDxe/PciLib.c
>+++ b/MdeModulePkg/Bus/Pci/PciBusDxe/PciLib.c
>@@ -868,7 +868,7 @@ PciHostBridgeResourceAllocator (
>       Resources[2] = PMem32Bridge;
>       Resources[3] = Mem64Bridge;
>       Resources[4] = PMem64Bridge;
>-      DumpResourceMap (RootBridgeDev, Resources, sizeof (Resources) / sizeof (Resources[0]));
>+      DumpResourceMap (RootBridgeDev, Resources, ARRAY_SIZE (Resources));
>     );
>
>     FreePool (AcpiConfig);
>--
>2.9.2
>



^ permalink raw reply	[flat|nested] 98+ messages in thread

* Re: [PATCH 02/47] NetworkPkg/IpsecConfig: guard the definition of ARRAY_SIZE
  2016-10-26 19:04 ` [PATCH 02/47] NetworkPkg/IpsecConfig: " Laszlo Ersek
@ 2016-10-27  1:59   ` Fu, Siyuan
  2016-10-27  2:30   ` Wu, Jiaxin
  1 sibling, 0 replies; 98+ messages in thread
From: Fu, Siyuan @ 2016-10-27  1:59 UTC (permalink / raw)
  To: Laszlo Ersek, edk2-devel-01; +Cc: Wu, Jiaxin



Reviewed-by: Fu Siyuan siyuan.fu@intel.com


> -----Original Message-----
> From: Laszlo Ersek [mailto:lersek@redhat.com]
> Sent: Thursday, October 27, 2016 3:04 AM
> To: edk2-devel-01 <edk2-devel@ml01.01.org>
> Cc: Wu, Jiaxin <jiaxin.wu@intel.com>; Fu, Siyuan <siyuan.fu@intel.com>
> Subject: [PATCH 02/47] NetworkPkg/IpsecConfig: guard the definition of
> ARRAY_SIZE
> 
> In one of the next patches, we'll introduce ARRAY_SIZE in
> "MdePkg/Include/Base.h". In order to proceed in small steps, make the
> module-local definition of ARRAY_SIZE conditional. This way the
> introduction of the macro under MdePkg will silently switch this module
> over (after which we can remove the module-local definition completely).
> 
> Cc: Jiaxin Wu <jiaxin.wu@intel.com>
> Cc: Siyuan Fu <siyuan.fu@intel.com>
> Contributed-under: TianoCore Contribution Agreement 1.0
> Signed-off-by: Laszlo Ersek <lersek@redhat.com>
> ---
>  NetworkPkg/Application/IpsecConfig/IpSecConfig.h | 2 ++
>  1 file changed, 2 insertions(+)
> 
> diff --git a/NetworkPkg/Application/IpsecConfig/IpSecConfig.h
> b/NetworkPkg/Application/IpsecConfig/IpSecConfig.h
> index 8ebc599a12e7..79a436a7b3b2 100644
> --- a/NetworkPkg/Application/IpsecConfig/IpSecConfig.h
> +++ b/NetworkPkg/Application/IpsecConfig/IpSecConfig.h
> @@ -27,7 +27,9 @@
> 
>  #include <Protocol/IpSecConfig.h>
> 
> +#ifndef ARRAY_SIZE
>  #define ARRAY_SIZE(x) (sizeof(x) / sizeof(x[0]))
> +#endif
> 
>  #define IPSECCONFIG_STATUS_NAME    L"IpSecStatus"
> 
> --
> 2.9.2
> 



^ permalink raw reply	[flat|nested] 98+ messages in thread

* Re: [PATCH 07/47] NetworkPkg/IpsecConfig: remove module-local ARRAY_SIZE macro
  2016-10-26 19:04 ` [PATCH 07/47] NetworkPkg/IpsecConfig: " Laszlo Ersek
@ 2016-10-27  1:59   ` Fu, Siyuan
  2016-10-27  2:31   ` Wu, Jiaxin
  1 sibling, 0 replies; 98+ messages in thread
From: Fu, Siyuan @ 2016-10-27  1:59 UTC (permalink / raw)
  To: Laszlo Ersek, edk2-devel-01; +Cc: Wu, Jiaxin



Reviewed-by: Fu Siyuan siyuan.fu@intel.com




> -----Original Message-----
> From: Laszlo Ersek [mailto:lersek@redhat.com]
> Sent: Thursday, October 27, 2016 3:04 AM
> To: edk2-devel-01 <edk2-devel@ml01.01.org>
> Cc: Wu, Jiaxin <jiaxin.wu@intel.com>; Fu, Siyuan <siyuan.fu@intel.com>
> Subject: [PATCH 07/47] NetworkPkg/IpsecConfig: remove module-local
> ARRAY_SIZE macro
> 
> Rely on the central macro definition from "MdePkg/Include/Base.h" instead.
> 
> Cc: Jiaxin Wu <jiaxin.wu@intel.com>
> Cc: Siyuan Fu <siyuan.fu@intel.com>
> Contributed-under: TianoCore Contribution Agreement 1.0
> Signed-off-by: Laszlo Ersek <lersek@redhat.com>
> ---
>  NetworkPkg/Application/IpsecConfig/IpSecConfig.h | 4 ----
>  1 file changed, 4 deletions(-)
> 
> diff --git a/NetworkPkg/Application/IpsecConfig/IpSecConfig.h
> b/NetworkPkg/Application/IpsecConfig/IpSecConfig.h
> index 79a436a7b3b2..95bb6961136d 100644
> --- a/NetworkPkg/Application/IpsecConfig/IpSecConfig.h
> +++ b/NetworkPkg/Application/IpsecConfig/IpSecConfig.h
> @@ -27,10 +27,6 @@
> 
>  #include <Protocol/IpSecConfig.h>
> 
> -#ifndef ARRAY_SIZE
> -#define ARRAY_SIZE(x) (sizeof(x) / sizeof(x[0]))
> -#endif
> -
>  #define IPSECCONFIG_STATUS_NAME    L"IpSecStatus"
> 
>  #define BIT(x)   (UINT32) (1 << (x))
> --
> 2.9.2
> 



^ permalink raw reply	[flat|nested] 98+ messages in thread

* Re: [PATCH 33/47] NetworkPkg/IScsiDxe: rebase to ARRAY_SIZE()
  2016-10-26 19:04 ` [PATCH 33/47] NetworkPkg/IScsiDxe: " Laszlo Ersek
@ 2016-10-27  1:59   ` Fu, Siyuan
  0 siblings, 0 replies; 98+ messages in thread
From: Fu, Siyuan @ 2016-10-27  1:59 UTC (permalink / raw)
  To: Laszlo Ersek, edk2-devel-01; +Cc: Wu, Jiaxin



Reviewed-by: Fu Siyuan siyuan.fu@intel.com




> -----Original Message-----
> From: Laszlo Ersek [mailto:lersek@redhat.com]
> Sent: Thursday, October 27, 2016 3:05 AM
> To: edk2-devel-01 <edk2-devel@ml01.01.org>
> Cc: Wu, Jiaxin <jiaxin.wu@intel.com>; Fu, Siyuan <siyuan.fu@intel.com>
> Subject: [PATCH 33/47] NetworkPkg/IScsiDxe: rebase to ARRAY_SIZE()
> 
> Cc: Jiaxin Wu <jiaxin.wu@intel.com>
> Cc: Siyuan Fu <siyuan.fu@intel.com>
> Contributed-under: TianoCore Contribution Agreement 1.0
> Signed-off-by: Laszlo Ersek <lersek@redhat.com>
> ---
>  NetworkPkg/IScsiDxe/IScsiConfig.c | 4 ++--
>  NetworkPkg/IScsiDxe/IScsiDriver.c | 2 +-
>  NetworkPkg/IScsiDxe/IScsiMisc.c   | 6 +++---
>  3 files changed, 6 insertions(+), 6 deletions(-)
> 
> diff --git a/NetworkPkg/IScsiDxe/IScsiConfig.c
> b/NetworkPkg/IScsiDxe/IScsiConfig.c
> index 3631e72e3455..16a90a6206aa 100644
> --- a/NetworkPkg/IScsiDxe/IScsiConfig.c
> +++ b/NetworkPkg/IScsiDxe/IScsiConfig.c
> @@ -1111,7 +1111,7 @@ IScsiConfigUpdateAttempt (
>    NET_LIST_FOR_EACH (Entry, &mPrivate->AttemptConfigs) {
>      AttemptConfigData = NET_LIST_USER_STRUCT (Entry,
> ISCSI_ATTEMPT_CONFIG_NVDATA, Link);
> 
> -    AsciiStrToUnicodeStrS (AttemptConfigData->AttemptName, AttemptName,
> sizeof (AttemptName) / sizeof (AttemptName[0]));
> +    AsciiStrToUnicodeStrS (AttemptConfigData->AttemptName, AttemptName,
> ARRAY_SIZE (AttemptName));
>      UnicodeSPrint (mPrivate->PortString, (UINTN) 128, L"Attempt %s",
> AttemptName);
>      AttemptConfigData->AttemptTitleToken = HiiSetString (
>                                               mCallbackInfo-
> >RegisteredHandle,
> @@ -1240,7 +1240,7 @@ IScsiConfigDeleteAttempts (
>        mPrivate->SinglePathCount--;
>      }
> 
> -    AsciiStrToUnicodeStrS (AttemptConfigData->MacString, MacString,
> sizeof (MacString) / sizeof (MacString[0]));
> +    AsciiStrToUnicodeStrS (AttemptConfigData->MacString, MacString,
> ARRAY_SIZE (MacString));
> 
>      UnicodeSPrint (
>        mPrivate->PortString,
> diff --git a/NetworkPkg/IScsiDxe/IScsiDriver.c
> b/NetworkPkg/IScsiDxe/IScsiDriver.c
> index 279f1c049679..ac10fa26d1b9 100644
> --- a/NetworkPkg/IScsiDxe/IScsiDriver.c
> +++ b/NetworkPkg/IScsiDxe/IScsiDriver.c
> @@ -673,7 +673,7 @@ IScsiStart (
>      Session->ConfigData = AttemptConfigData;
>      Session->AuthType   = AttemptConfigData->AuthenticationType;
> 
> -    AsciiStrToUnicodeStrS (AttemptConfigData->MacString, MacString,
> sizeof (MacString) / sizeof (MacString[0]));
> +    AsciiStrToUnicodeStrS (AttemptConfigData->MacString, MacString,
> ARRAY_SIZE (MacString));
>      UnicodeSPrint (
>        mPrivate->PortString,
>        (UINTN) ISCSI_NAME_IFR_MAX_SIZE,
> diff --git a/NetworkPkg/IScsiDxe/IScsiMisc.c
> b/NetworkPkg/IScsiDxe/IScsiMisc.c
> index 64bb2ade7b0a..11a80f2e10e4 100644
> --- a/NetworkPkg/IScsiDxe/IScsiMisc.c
> +++ b/NetworkPkg/IScsiDxe/IScsiMisc.c
> @@ -1109,7 +1109,7 @@ IScsiGetConfigData (
>            //
>            // Refresh the state of this attempt to NVR.
>            //
> -          AsciiStrToUnicodeStrS (AttemptTmp->MacString, MacString, sizeof
> (MacString) / sizeof (MacString[0]));
> +          AsciiStrToUnicodeStrS (AttemptTmp->MacString, MacString,
> ARRAY_SIZE (MacString));
>            UnicodeSPrint (
>              mPrivate->PortString,
>              (UINTN) ISCSI_NAME_IFR_MAX_SIZE,
> @@ -1148,7 +1148,7 @@ IScsiGetConfigData (
>          //
>          // Refresh the state of this attempt to NVR.
>          //
> -        AsciiStrToUnicodeStrS (AttemptTmp->MacString, MacString, sizeof
> (MacString) / sizeof (MacString[0]));
> +        AsciiStrToUnicodeStrS (AttemptTmp->MacString, MacString,
> ARRAY_SIZE (MacString));
>          UnicodeSPrint (
>            mPrivate->PortString,
>            (UINTN) ISCSI_NAME_IFR_MAX_SIZE,
> @@ -1239,7 +1239,7 @@ IScsiGetConfigData (
>        //
>        // Refresh the state of this attempt to NVR.
>        //
> -      AsciiStrToUnicodeStrS (AttemptConfigData->MacString, MacString,
> sizeof (MacString) / sizeof (MacString[0]));
> +      AsciiStrToUnicodeStrS (AttemptConfigData->MacString, MacString,
> ARRAY_SIZE (MacString));
>        UnicodeSPrint (
>          mPrivate->PortString,
>          (UINTN) ISCSI_NAME_IFR_MAX_SIZE,
> --
> 2.9.2
> 



^ permalink raw reply	[flat|nested] 98+ messages in thread

* Re: [PATCH 34/47] NetworkPkg/TcpDxe: rebase to ARRAY_SIZE()
  2016-10-26 19:04 ` [PATCH 34/47] NetworkPkg/TcpDxe: " Laszlo Ersek
@ 2016-10-27  2:00   ` Fu, Siyuan
  2016-10-27  2:31   ` Wu, Jiaxin
  1 sibling, 0 replies; 98+ messages in thread
From: Fu, Siyuan @ 2016-10-27  2:00 UTC (permalink / raw)
  To: Laszlo Ersek, edk2-devel-01; +Cc: Wu, Jiaxin



Reviewed-by: Fu Siyuan siyuan.fu@intel.com




> -----Original Message-----
> From: Laszlo Ersek [mailto:lersek@redhat.com]
> Sent: Thursday, October 27, 2016 3:05 AM
> To: edk2-devel-01 <edk2-devel@ml01.01.org>
> Cc: Fu, Siyuan <siyuan.fu@intel.com>; Wu, Jiaxin <jiaxin.wu@intel.com>
> Subject: [PATCH 34/47] NetworkPkg/TcpDxe: rebase to ARRAY_SIZE()
> 
> Cc: Siyuan Fu <siyuan.fu@intel.com>
> Cc: Jiaxin Wu <jiaxin.wu@intel.com>
> Contributed-under: TianoCore Contribution Agreement 1.0
> Signed-off-by: Laszlo Ersek <lersek@redhat.com>
> ---
>  NetworkPkg/TcpDxe/TcpOutput.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/NetworkPkg/TcpDxe/TcpOutput.c b/NetworkPkg/TcpDxe/TcpOutput.c
> index 91e56d369a71..a46cb6099ea8 100644
> --- a/NetworkPkg/TcpDxe/TcpOutput.c
> +++ b/NetworkPkg/TcpDxe/TcpOutput.c
> @@ -797,7 +797,7 @@ TcpToSendData (
>      Len   = TcpDataToSend (Tcb, Force);
>      Seq   = Tcb->SndNxt;
> 
> -    ASSERT ((Tcb->State) < (sizeof (mTcpOutFlag) / sizeof
> (mTcpOutFlag[0])));
> +    ASSERT ((Tcb->State) < (ARRAY_SIZE (mTcpOutFlag)));
>      Flag  = mTcpOutFlag[Tcb->State];
> 
>      if ((Flag & TCP_FLG_SYN) != 0) {
> --
> 2.9.2
> 



^ permalink raw reply	[flat|nested] 98+ messages in thread

* Re: [PATCH 22/47] MdeModulePkg/Core/PiSmmCore: rebase to ARRAY_SIZE()
  2016-10-26 19:04 ` [PATCH 22/47] MdeModulePkg/Core/PiSmmCore: " Laszlo Ersek
@ 2016-10-27  2:20   ` Kinney, Michael D
  0 siblings, 0 replies; 98+ messages in thread
From: Kinney, Michael D @ 2016-10-27  2:20 UTC (permalink / raw)
  To: Laszlo Ersek, edk2-devel-01, Kinney, Michael D; +Cc: Tian, Feng, Zeng, Star

Reviewed-by: Michael Kinney <michael.d.kinney@intel.com>

> -----Original Message-----
> From: Laszlo Ersek [mailto:lersek@redhat.com]
> Sent: Wednesday, October 26, 2016 12:05 PM
> To: edk2-devel-01 <edk2-devel@ml01.01.org>
> Cc: Tian, Feng <feng.tian@intel.com>; Kinney, Michael D <michael.d.kinney@intel.com>;
> Zeng, Star <star.zeng@intel.com>
> Subject: [PATCH 22/47] MdeModulePkg/Core/PiSmmCore: rebase to ARRAY_SIZE()
> 
> Cc: Feng Tian <feng.tian@intel.com>
> Cc: Michael D Kinney <michael.d.kinney@intel.com>
> Cc: Star Zeng <star.zeng@intel.com>
> Contributed-under: TianoCore Contribution Agreement 1.0
> Signed-off-by: Laszlo Ersek <lersek@redhat.com>
> ---
>  MdeModulePkg/Core/PiSmmCore/Pool.c               | 2 +-
>  MdeModulePkg/Core/PiSmmCore/SmramProfileRecord.c | 6 +++---
>  2 files changed, 4 insertions(+), 4 deletions(-)
> 
> diff --git a/MdeModulePkg/Core/PiSmmCore/Pool.c b/MdeModulePkg/Core/PiSmmCore/Pool.c
> index 9d447025883d..02dab0142560 100644
> --- a/MdeModulePkg/Core/PiSmmCore/Pool.c
> +++ b/MdeModulePkg/Core/PiSmmCore/Pool.c
> @@ -42,7 +42,7 @@ SmmInitializeMemoryServices (
>    //
>    // Initialize Pool list
>    //
> -  for (Index = sizeof (mSmmPoolLists) / sizeof (*mSmmPoolLists); Index > 0;) {
> +  for (Index = ARRAY_SIZE (mSmmPoolLists); Index > 0;) {
>      InitializeListHead (&mSmmPoolLists[--Index]);
>    }
>    CurrentSmramRangesIndex = 0;
> diff --git a/MdeModulePkg/Core/PiSmmCore/SmramProfileRecord.c
> b/MdeModulePkg/Core/PiSmmCore/SmramProfileRecord.c
> index 93585f199df9..d983cefbb3dc 100644
> --- a/MdeModulePkg/Core/PiSmmCore/SmramProfileRecord.c
> +++ b/MdeModulePkg/Core/PiSmmCore/SmramProfileRecord.c
> @@ -2670,7 +2670,7 @@ ProfileMemoryTypeToStr (
>    )
>  {
>    UINTN     Index;
> -  for (Index = 0; Index < sizeof (mMemoryTypeString) / sizeof (mMemoryTypeString[0]);
> Index++) {
> +  for (Index = 0; Index < ARRAY_SIZE (mMemoryTypeString); Index++) {
>      if (mMemoryTypeString[Index].MemoryType == MemoryType) {
>        return mMemoryTypeString[Index].MemoryTypeStr;
>      }
> @@ -2697,12 +2697,12 @@ ProfileActionToStr (
>    CHAR8     **ActionString;
> 
>    ActionString = mSmmActionString;
> -  ActionStringCount = sizeof (mSmmActionString) / sizeof (mSmmActionString[0]);
> +  ActionStringCount = ARRAY_SIZE (mSmmActionString);
> 
>    if ((UINTN) (UINT32) Action < ActionStringCount) {
>      return ActionString[Action];
>    }
> -  for (Index = 0; Index < sizeof (mExtActionString) / sizeof (mExtActionString[0]);
> Index++) {
> +  for (Index = 0; Index < ARRAY_SIZE (mExtActionString); Index++) {
>      if (mExtActionString[Index].Action == Action) {
>        return mExtActionString[Index].String;
>      }
> --
> 2.9.2
> 



^ permalink raw reply	[flat|nested] 98+ messages in thread

* Re: [PATCH 05/47] MdePkg/Include/Base.h: introduce the ARRAY_SIZE() function-like macro
  2016-10-26 22:25     ` Laszlo Ersek
@ 2016-10-27  2:21       ` Kinney, Michael D
  0 siblings, 0 replies; 98+ messages in thread
From: Kinney, Michael D @ 2016-10-27  2:21 UTC (permalink / raw)
  To: Laszlo Ersek, edk2-devel-01, Kinney, Michael D
  Cc: Ni, Ruiyu, Tim He, Tian, Feng, Dong, Eric, Cecil Sheng,
	Ard Biesheuvel, Justen, Jordan L, Gao, Liming, Bi, Dandan,
	Wu, Jiaxin, Gary Lin, Zeng, Star, Daryl McDaniel, Carsey, Jaben,
	Fu, Siyuan, Fan, Jeff, Zhang, Chao B, Wei, David

With that change:

Reviewed-by: Michael Kinney <michael.d.kinney@intel.com>

Mike

> -----Original Message-----
> From: Laszlo Ersek [mailto:lersek@redhat.com]
> Sent: Wednesday, October 26, 2016 3:26 PM
> To: Kinney, Michael D <michael.d.kinney@intel.com>; edk2-devel-01 <edk2-
> devel@ml01.01.org>
> Cc: Ni, Ruiyu <ruiyu.ni@intel.com>; Tim He <tim.he@intel.com>; Tian, Feng
> <feng.tian@intel.com>; Dong, Eric <eric.dong@intel.com>; Cecil Sheng
> <cecil.sheng@hpe.com>; Ard Biesheuvel <ard.biesheuvel@linaro.org>; Justen, Jordan L
> <jordan.l.justen@intel.com>; Gao, Liming <liming.gao@intel.com>; Bi, Dandan
> <dandan.bi@intel.com>; Wu, Jiaxin <jiaxin.wu@intel.com>; Gary Lin <glin@suse.com>;
> Zeng, Star <star.zeng@intel.com>; Daryl McDaniel <edk2-lists@mc2research.org>; Carsey,
> Jaben <jaben.carsey@intel.com>; Fu, Siyuan <siyuan.fu@intel.com>; Fan, Jeff
> <jeff.fan@intel.com>; Zhang, Chao B <chao.b.zhang@intel.com>; Wei, David
> <david.wei@intel.com>
> Subject: Re: [edk2] [PATCH 05/47] MdePkg/Include/Base.h: introduce the ARRAY_SIZE()
> function-like macro
> 
> On 10/27/16 00:13, Kinney, Michael D wrote:
> > Hi Laszlo,
> >
> > One comment inline below.
> >
> > Mike
> >
> >> -----Original Message-----
> >> From: edk2-devel [mailto:edk2-devel-bounces@lists.01.org] On Behalf Of Laszlo Ersek
> >> Sent: Wednesday, October 26, 2016 12:04 PM
> >> To: edk2-devel-01 <edk2-devel@ml01.01.org>
> >> Cc: Ni, Ruiyu <ruiyu.ni@intel.com>; Tim He <tim.he@intel.com>; Tian, Feng
> >> <feng.tian@intel.com>; Kinney, Michael D <michael.d.kinney@intel.com>; Dong, Eric
> >> <eric.dong@intel.com>; Cecil Sheng <cecil.sheng@hpe.com>; Ard Biesheuvel
> >> <ard.biesheuvel@linaro.org>; Justen, Jordan L <jordan.l.justen@intel.com>; Gao,
> Liming
> >> <liming.gao@intel.com>; Bi, Dandan <dandan.bi@intel.com>; Wu, Jiaxin
> >> <jiaxin.wu@intel.com>; Gary Lin <glin@suse.com>; Zeng, Star <star.zeng@intel.com>;
> >> Daryl McDaniel <edk2-lists@mc2research.org>; Carsey, Jaben <jaben.carsey@intel.com>;
> >> Fu, Siyuan <siyuan.fu@intel.com>; Fan, Jeff <jeff.fan@intel.com>; Zhang, Chao B
> >> <chao.b.zhang@intel.com>; Wei, David <david.wei@intel.com>
> >> Subject: [edk2] [PATCH 05/47] MdePkg/Include/Base.h: introduce the ARRAY_SIZE()
> >> function-like macro
> >>
> >> Several modules use ARRAY_SIZE() already; centralize the definition. (The
> >> module-specific macro definitions are guarded by #ifndef directives at
> >> this point.)
> >>
> >> Cc: Ard Biesheuvel <ard.biesheuvel@linaro.org>
> >> Cc: Cecil Sheng <cecil.sheng@hpe.com>
> >> Cc: Chao Zhang <chao.b.zhang@intel.com>
> >> Cc: Dandan Bi <dandan.bi@intel.com>
> >> Cc: Daryl McDaniel <edk2-lists@mc2research.org>
> >> Cc: David Wei <david.wei@intel.com>
> >> Cc: Eric Dong <eric.dong@intel.com>
> >> Cc: Feng Tian <feng.tian@intel.com>
> >> Cc: Gary Lin <glin@suse.com>
> >> Cc: Jaben Carsey <jaben.carsey@intel.com>
> >> Cc: Jeff Fan <jeff.fan@intel.com>
> >> Cc: Jiaxin Wu <jiaxin.wu@intel.com>
> >> Cc: Jordan Justen <jordan.l.justen@intel.com>
> >> Cc: Liming Gao <liming.gao@intel.com>
> >> Cc: Michael D Kinney <michael.d.kinney@intel.com>
> >> Cc: Ruiyu Ni <ruiyu.ni@intel.com>
> >> Cc: Siyuan Fu <siyuan.fu@intel.com>
> >> Cc: Star Zeng <star.zeng@intel.com>
> >> Cc: Tim He <tim.he@intel.com>
> >> Contributed-under: TianoCore Contribution Agreement 1.0
> >> Signed-off-by: Laszlo Ersek <lersek@redhat.com>
> >> ---
> >>  MdePkg/Include/Base.h | 13 +++++++++++++
> >>  1 file changed, 13 insertions(+)
> >>
> >> diff --git a/MdePkg/Include/Base.h b/MdePkg/Include/Base.h
> >> index c66614846488..8bdb257e37bd 100644
> >> --- a/MdePkg/Include/Base.h
> >> +++ b/MdePkg/Include/Base.h
> >> @@ -1211,5 +1211,18 @@ typedef UINTN RETURN_STATUS;
> >>    #define RETURN_ADDRESS(L)     ((VOID *) 0)
> >>  #endif
> >>
> >> +/**
> >> +  Return the number of elements in an array.
> >> +
> >> +  @param  Array  An object of array type. Array is only used as an argument to
> >> +                 the sizeof operator, therefore Array is never evaluated. The
> >> +                 caller is responsible for ensuring that Array's type is not
> >> +                 incomplete; that is, Array must have known constant size.
> >> +
> >> +  @return The number of elements in Array. The result has type UINTN.
> >> +
> >> +**/
> >> +#define ARRAY_SIZE(Array) (sizeof (Array) / sizeof (Array)[0])
> >
> > I think adding one extra set of () makes this clearer:
> >
> > #define ARRAY_SIZE(Array) (sizeof (Array) / sizeof ((Array)[0]))
> 
> Sure, will do.
> 
> Thanks!
> Laszlo
> 
> >> +
> >>  #endif
> >>
> >> --
> >> 2.9.2
> >>
> >>
> >> _______________________________________________
> >> edk2-devel mailing list
> >> edk2-devel@lists.01.org
> >> https://lists.01.org/mailman/listinfo/edk2-devel



^ permalink raw reply	[flat|nested] 98+ messages in thread

* Re: [PATCH 02/47] NetworkPkg/IpsecConfig: guard the definition of ARRAY_SIZE
  2016-10-26 19:04 ` [PATCH 02/47] NetworkPkg/IpsecConfig: " Laszlo Ersek
  2016-10-27  1:59   ` Fu, Siyuan
@ 2016-10-27  2:30   ` Wu, Jiaxin
  1 sibling, 0 replies; 98+ messages in thread
From: Wu, Jiaxin @ 2016-10-27  2:30 UTC (permalink / raw)
  To: Laszlo Ersek, edk2-devel-01; +Cc: Fu, Siyuan

Reviewed-By: Wu Jiaxin <jiaxin.wu@intel.com>

Best Regards!
Jiaxin

> -----Original Message-----
> From: Laszlo Ersek [mailto:lersek@redhat.com]
> Sent: Thursday, October 27, 2016 3:04 AM
> To: edk2-devel-01 <edk2-devel@ml01.01.org>
> Cc: Wu, Jiaxin <jiaxin.wu@intel.com>; Fu, Siyuan <siyuan.fu@intel.com>
> Subject: [PATCH 02/47] NetworkPkg/IpsecConfig: guard the definition of
> ARRAY_SIZE
> 
> In one of the next patches, we'll introduce ARRAY_SIZE in
> "MdePkg/Include/Base.h". In order to proceed in small steps, make the
> module-local definition of ARRAY_SIZE conditional. This way the introduction of
> the macro under MdePkg will silently switch this module over (after which we
> can remove the module-local definition completely).
> 
> Cc: Jiaxin Wu <jiaxin.wu@intel.com>
> Cc: Siyuan Fu <siyuan.fu@intel.com>
> Contributed-under: TianoCore Contribution Agreement 1.0
> Signed-off-by: Laszlo Ersek <lersek@redhat.com>
> ---
>  NetworkPkg/Application/IpsecConfig/IpSecConfig.h | 2 ++
>  1 file changed, 2 insertions(+)
> 
> diff --git a/NetworkPkg/Application/IpsecConfig/IpSecConfig.h
> b/NetworkPkg/Application/IpsecConfig/IpSecConfig.h
> index 8ebc599a12e7..79a436a7b3b2 100644
> --- a/NetworkPkg/Application/IpsecConfig/IpSecConfig.h
> +++ b/NetworkPkg/Application/IpsecConfig/IpSecConfig.h
> @@ -27,7 +27,9 @@
> 
>  #include <Protocol/IpSecConfig.h>
> 
> +#ifndef ARRAY_SIZE
>  #define ARRAY_SIZE(x) (sizeof(x) / sizeof(x[0]))
> +#endif
> 
>  #define IPSECCONFIG_STATUS_NAME    L"IpSecStatus"
> 
> --
> 2.9.2
> 



^ permalink raw reply	[flat|nested] 98+ messages in thread

* Re: [PATCH 07/47] NetworkPkg/IpsecConfig: remove module-local ARRAY_SIZE macro
  2016-10-26 19:04 ` [PATCH 07/47] NetworkPkg/IpsecConfig: " Laszlo Ersek
  2016-10-27  1:59   ` Fu, Siyuan
@ 2016-10-27  2:31   ` Wu, Jiaxin
  1 sibling, 0 replies; 98+ messages in thread
From: Wu, Jiaxin @ 2016-10-27  2:31 UTC (permalink / raw)
  To: Laszlo Ersek, edk2-devel-01; +Cc: Fu, Siyuan

Reviewed-By: Wu Jiaxin <jiaxin.wu@intel.com>

Best Regards!
Jiaxin

> -----Original Message-----
> From: Laszlo Ersek [mailto:lersek@redhat.com]
> Sent: Thursday, October 27, 2016 3:04 AM
> To: edk2-devel-01 <edk2-devel@ml01.01.org>
> Cc: Wu, Jiaxin <jiaxin.wu@intel.com>; Fu, Siyuan <siyuan.fu@intel.com>
> Subject: [PATCH 07/47] NetworkPkg/IpsecConfig: remove module-local
> ARRAY_SIZE macro
> 
> Rely on the central macro definition from "MdePkg/Include/Base.h" instead.
> 
> Cc: Jiaxin Wu <jiaxin.wu@intel.com>
> Cc: Siyuan Fu <siyuan.fu@intel.com>
> Contributed-under: TianoCore Contribution Agreement 1.0
> Signed-off-by: Laszlo Ersek <lersek@redhat.com>
> ---
>  NetworkPkg/Application/IpsecConfig/IpSecConfig.h | 4 ----
>  1 file changed, 4 deletions(-)
> 
> diff --git a/NetworkPkg/Application/IpsecConfig/IpSecConfig.h
> b/NetworkPkg/Application/IpsecConfig/IpSecConfig.h
> index 79a436a7b3b2..95bb6961136d 100644
> --- a/NetworkPkg/Application/IpsecConfig/IpSecConfig.h
> +++ b/NetworkPkg/Application/IpsecConfig/IpSecConfig.h
> @@ -27,10 +27,6 @@
> 
>  #include <Protocol/IpSecConfig.h>
> 
> -#ifndef ARRAY_SIZE
> -#define ARRAY_SIZE(x) (sizeof(x) / sizeof(x[0])) -#endif
> -
>  #define IPSECCONFIG_STATUS_NAME    L"IpSecStatus"
> 
>  #define BIT(x)   (UINT32) (1 << (x))
> --
> 2.9.2
> 



^ permalink raw reply	[flat|nested] 98+ messages in thread

* Re: [PATCH 34/47] NetworkPkg/TcpDxe: rebase to ARRAY_SIZE()
  2016-10-26 19:04 ` [PATCH 34/47] NetworkPkg/TcpDxe: " Laszlo Ersek
  2016-10-27  2:00   ` Fu, Siyuan
@ 2016-10-27  2:31   ` Wu, Jiaxin
  1 sibling, 0 replies; 98+ messages in thread
From: Wu, Jiaxin @ 2016-10-27  2:31 UTC (permalink / raw)
  To: Laszlo Ersek, edk2-devel-01; +Cc: Fu, Siyuan

Reviewed-By: Wu Jiaxin <jiaxin.wu@intel.com>


Best Regards!
Jiaxin

> -----Original Message-----
> From: Laszlo Ersek [mailto:lersek@redhat.com]
> Sent: Thursday, October 27, 2016 3:05 AM
> To: edk2-devel-01 <edk2-devel@ml01.01.org>
> Cc: Fu, Siyuan <siyuan.fu@intel.com>; Wu, Jiaxin <jiaxin.wu@intel.com>
> Subject: [PATCH 34/47] NetworkPkg/TcpDxe: rebase to ARRAY_SIZE()
> 
> Cc: Siyuan Fu <siyuan.fu@intel.com>
> Cc: Jiaxin Wu <jiaxin.wu@intel.com>
> Contributed-under: TianoCore Contribution Agreement 1.0
> Signed-off-by: Laszlo Ersek <lersek@redhat.com>
> ---
>  NetworkPkg/TcpDxe/TcpOutput.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/NetworkPkg/TcpDxe/TcpOutput.c
> b/NetworkPkg/TcpDxe/TcpOutput.c index 91e56d369a71..a46cb6099ea8
> 100644
> --- a/NetworkPkg/TcpDxe/TcpOutput.c
> +++ b/NetworkPkg/TcpDxe/TcpOutput.c
> @@ -797,7 +797,7 @@ TcpToSendData (
>      Len   = TcpDataToSend (Tcb, Force);
>      Seq   = Tcb->SndNxt;
> 
> -    ASSERT ((Tcb->State) < (sizeof (mTcpOutFlag) / sizeof (mTcpOutFlag[0])));
> +    ASSERT ((Tcb->State) < (ARRAY_SIZE (mTcpOutFlag)));
>      Flag  = mTcpOutFlag[Tcb->State];
> 
>      if ((Flag & TCP_FLG_SYN) != 0) {
> --
> 2.9.2
> 



^ permalink raw reply	[flat|nested] 98+ messages in thread

* Re: [PATCH 00/47] edk2: centralize and adopt ARRAY_SIZE()
  2016-10-27  1:17 ` Tian, Feng
@ 2016-10-27  2:37   ` Zeng, Star
  0 siblings, 0 replies; 98+ messages in thread
From: Zeng, Star @ 2016-10-27  2:37 UTC (permalink / raw)
  To: Tian, Feng, Laszlo Ersek, edk2-devel-01
  Cc: Ard Biesheuvel, Cecil Sheng, Zhang, Chao B, Bi, Dandan,
	Daryl McDaniel, Wei, David, Dong, Eric, Gary Lin, Carsey, Jaben,
	Fan, Jeff, Wu, Jiaxin, Justen, Jordan L, Gao, Liming,
	Kinney, Michael D, Ni, Ruiyu, Fu, Siyuan, Tim He, Zeng, Star

Reviewed-by: Star Zeng <star.zeng@intel.com> to MdeModulePkg changes.

Thanks,
Star
-----Original Message-----
From: Tian, Feng 
Sent: Thursday, October 27, 2016 9:17 AM
To: Laszlo Ersek <lersek@redhat.com>; edk2-devel-01 <edk2-devel@ml01.01.org>
Cc: Ard Biesheuvel <ard.biesheuvel@linaro.org>; Cecil Sheng <cecil.sheng@hpe.com>; Zhang, Chao B <chao.b.zhang@intel.com>; Bi, Dandan <dandan.bi@intel.com>; Daryl McDaniel <edk2-lists@mc2research.org>; Wei, David <david.wei@intel.com>; Dong, Eric <eric.dong@intel.com>; Gary Lin <glin@suse.com>; Carsey, Jaben <jaben.carsey@intel.com>; Fan, Jeff <jeff.fan@intel.com>; Wu, Jiaxin <jiaxin.wu@intel.com>; Justen, Jordan L <jordan.l.justen@intel.com>; Gao, Liming <liming.gao@intel.com>; Kinney, Michael D <michael.d.kinney@intel.com>; Ni, Ruiyu <ruiyu.ni@intel.com>; Fu, Siyuan <siyuan.fu@intel.com>; Zeng, Star <star.zeng@intel.com>; Tim He <tim.he@intel.com>; Tian, Feng <feng.tian@intel.com>
Subject: RE: [PATCH 00/47] edk2: centralize and adopt ARRAY_SIZE()

MdeModulePkg

reviewed-by: Feng Tian <feng.tian@Intel.com>

Thanks
Feng

-----Original Message-----
From: Laszlo Ersek [mailto:lersek@redhat.com] 
Sent: Thursday, October 27, 2016 3:04 AM
To: edk2-devel-01 <edk2-devel@ml01.01.org>
Cc: Ard Biesheuvel <ard.biesheuvel@linaro.org>; Cecil Sheng <cecil.sheng@hpe.com>; Zhang, Chao B <chao.b.zhang@intel.com>; Bi, Dandan <dandan.bi@intel.com>; Daryl McDaniel <edk2-lists@mc2research.org>; Wei, David <david.wei@intel.com>; Dong, Eric <eric.dong@intel.com>; Tian, Feng <feng.tian@intel.com>; Gary Lin <glin@suse.com>; Carsey, Jaben <jaben.carsey@intel.com>; Fan, Jeff <jeff.fan@intel.com>; Wu, Jiaxin <jiaxin.wu@intel.com>; Justen, Jordan L <jordan.l.justen@intel.com>; Gao, Liming <liming.gao@intel.com>; Kinney, Michael D <michael.d.kinney@intel.com>; Ni, Ruiyu <ruiyu.ni@intel.com>; Fu, Siyuan <siyuan.fu@intel.com>; Zeng, Star <star.zeng@intel.com>; Tim He <tim.he@intel.com>
Subject: [PATCH 00/47] edk2: centralize and adopt ARRAY_SIZE()

I'm sure most of us have wished at some point that ARRAY_SIZE() had existed in a central header file, like it does in many other open source projects. This series implements that.

Patches 01-04 round up the modules that #define ARRAY_SIZE() just for themselves, and wrap their definitions in #ifndef ARRAY_SIZE.

Patch 05 defines ARRAY_SIZE() in "MdePkg/Include/Base.h". This flips the previously modified modules to MdePkg's macro definition.

Patches 06-09 modify the same set of modules as patches 01-04 do; this time the (now unused) module-local ARRAY_SIZE() macro definitions are eliminated.

The rest of the patches (10-47) migrate the edk2 tree to ARRAY_SIZE(), covering the most obvious open-coded ARRAY_SIZE() expressions. These expressions were located and converted with the following shell
pipeline:

  git ls-files \
  | xargs --no-run-if-empty -- \
      sed --regexp-extended --in-place \
        --expression='s,sizeof \(([a-zA-Z0-9_]+)\) / sizeof \((\*\1|\1\[0\])\),ARRAY_SIZE (\1),g' \
        --

This pipeline lists all tracked files with "git". The pathnames are then composed with "xargs" into maximal length "sed" command lines, and those "sed" commands are run.

Here the "sed" stream editor filters and modifies all the listed files in place. The extended regular expression replaces the following two
patterns:

  sizeof (ArrayName) / sizeof (*ArrayName)
  sizeof (ArrayName) / sizeof (ArrayName[0])

with

  ARRAY_SIZE (ArrayName)

The regexp uses a backreference in the match, ensuring that the sizeof operator in the dividend and the sizeof operator in the divisor both refer to the same ArrayName. If there are multiple occurrences on the same line, the sed command replaces all of them.

I collected the changes into patches manually, and I reviewed them all.

I test-built all of the modified packages, repeating the command

  build -a X64 -t GCC48 -b DEBUG -p FooPkg/FooPkg.dsc

as many times as necessary. Two packages were impossible to build like
this: Nt32Pkg and Vlv2TbltDevicePkg, so I couldn't build-test them.

I did some light-weight testing with OVMF: boot with Secure Boot enabled, S3 suspend/resume with and without SMM. I also booted ArmVirtQemu once.

Repository: https://github.com/lersek/edk2.git
Branch:     array_size

Cc: Ard Biesheuvel <ard.biesheuvel@linaro.org>
Cc: Cecil Sheng <cecil.sheng@hpe.com>
Cc: Chao Zhang <chao.b.zhang@intel.com>
Cc: Dandan Bi <dandan.bi@intel.com>
Cc: Daryl McDaniel <edk2-lists@mc2research.org>
Cc: David Wei <david.wei@intel.com>
Cc: Eric Dong <eric.dong@intel.com>
Cc: Feng Tian <feng.tian@intel.com>
Cc: Gary Lin <glin@suse.com>
Cc: Jaben Carsey <jaben.carsey@intel.com>
Cc: Jeff Fan <jeff.fan@intel.com>
Cc: Jiaxin Wu <jiaxin.wu@intel.com>
Cc: Jordan Justen <jordan.l.justen@intel.com>
Cc: Liming Gao <liming.gao@intel.com>
Cc: Michael D Kinney <michael.d.kinney@intel.com>
Cc: Ruiyu Ni <ruiyu.ni@intel.com>
Cc: Siyuan Fu <siyuan.fu@intel.com>
Cc: Star Zeng <star.zeng@intel.com>
Cc: Tim He <tim.he@intel.com>

Thanks
Laszlo

Laszlo Ersek (47):
  MdeModulePkg/RegularExpressionDxe: guard the definition of ARRAY_SIZE
  NetworkPkg/IpsecConfig: guard the definition of ARRAY_SIZE
  OvmfPkg/PlatformBootManagerLib: guard the definition of ARRAY_SIZE
  OvmfPkg/XenBusDxe: guard the definition of ARRAY_SIZE
  MdePkg/Include/Base.h: introduce the ARRAY_SIZE() function-like macro
  MdeModulePkg/RegularExpressionDxe: remove module-local ARRAY_SIZE
    macro
  NetworkPkg/IpsecConfig: remove module-local ARRAY_SIZE macro
  OvmfPkg/PlatformBootManagerLib: remove module-local ARRAY_SIZE macro
  OvmfPkg/XenBusDxe: remove module-local ARRAY_SIZE macro
  ArmVirtPkg/NorFlashQemuLib: rebase to ARRAY_SIZE()
  DuetPkg/DuetBdsLib: rebase to ARRAY_SIZE()
  EdkCompatibilityPkg/FrameworkHiiOnUefiHiiThunk: rebase to ARRAY_SIZE()
  EdkCompatibilityPkg/Sample/Tools: rebase to ARRAY_SIZE()
  FatPkg/EnhancedFatDxe: rebase to ARRAY_SIZE()
  IntelFrameworkModulePkg/LegacyBootManagerLib: rebase to ARRAY_SIZE()
  IntelFrameworkModulePkg/BdsDxe: rebase to ARRAY_SIZE()
  MdeModulePkg/MemoryProfileInfo: rebase to ARRAY_SIZE()
  MdeModulePkg/PciBusDxe: rebase to ARRAY_SIZE()
  MdeModulePkg/PciHostBridgeDxe: rebase to ARRAY_SIZE()
  MdeModulePkg/UsbBusDxe: rebase to ARRAY_SIZE()
  MdeModulePkg/Core/Dxe: rebase to ARRAY_SIZE()
  MdeModulePkg/Core/PiSmmCore: rebase to ARRAY_SIZE()
  MdeModulePkg/BootMaintenanceManagerUiLib: rebase to ARRAY_SIZE()
  MdeModulePkg/BootManagerUiLib: rebase to ARRAY_SIZE()
  MdeModulePkg/UefiBootManagerLib: rebase to ARRAY_SIZE()
  MdeModulePkg/VarCheckHiiLib: rebase to ARRAY_SIZE()
  MdeModulePkg/Logo: rebase to ARRAY_SIZE()
  MdeModulePkg/BdsDxe: rebase to ARRAY_SIZE()
  MdeModulePkg/DisplayEngineDxe: rebase to ARRAY_SIZE()
  MdeModulePkg/EbcDxe: rebase to ARRAY_SIZE()
  MdeModulePkg/Tcp4Dxe: rebase to ARRAY_SIZE()
  MdeModulePkg/Variable/RuntimeDxe: rebase to ARRAY_SIZE()
  NetworkPkg/IScsiDxe: rebase to ARRAY_SIZE()
  NetworkPkg/TcpDxe: rebase to ARRAY_SIZE()
  Nt32Pkg/WinNtSerialIoDxe: rebase to ARRAY_SIZE()
  OptionRomPkg/AtapiPassThruDxe: rebase to ARRAY_SIZE()
  OvmfPkg/QemuBootOrderLib: rebase to ARRAY_SIZE()
  OvmfPkg/QemuVideoDxe: rebase to ARRAY_SIZE()
  PerformancePkg/Dp_App: rebase to ARRAY_SIZE()
  SecurityPkg/AuthVariableLib: rebase to ARRAY_SIZE()
  ShellPkg/UefiDpLib: rebase to ARRAY_SIZE()
  ShellPkg/UefiShellLevel2CommandsLib: rebase to ARRAY_SIZE()
  Vlv2TbltDevicePkg/FirmwareUpdate: rebase to ARRAY_SIZE()
  Vlv2TbltDevicePkg/PlatformInitPei: rebase to ARRAY_SIZE()
  Vlv2TbltDevicePkg/PlatformPei: rebase to ARRAY_SIZE()
  Vlv2TbltDevicePkg/PlatformSetupDxe: rebase to ARRAY_SIZE()
  Vlv2TbltDevicePkg/SmBiosMiscDxe: rebase to ARRAY_SIZE()

 ArmVirtPkg/Library/NorFlashQemuLib/NorFlashQemuLib.c                          |  2 +-
 DuetPkg/Library/DuetBdsLib/BdsPlatform.c                                      |  2 +-
 EdkCompatibilityPkg/Compatibility/FrameworkHiiOnUefiHiiThunk/OpcodeCreation.c |  2 +-
 EdkCompatibilityPkg/Sample/Tools/Source/EfiRom/EfiRom.c                       |  4 ++--
 EdkCompatibilityPkg/Sample/Tools/Source/HiiPack/IfrParse.c                    |  2 +-
 FatPkg/EnhancedFatDxe/DirectoryManage.c                                       |  4 ++--
 FatPkg/EnhancedFatDxe/FileName.c                                              |  4 ++--
 FatPkg/EnhancedFatDxe/Hash.c                                                  |  4 ++--
 IntelFrameworkModulePkg/Library/LegacyBootManagerLib/LegacyBm.c               |  2 +-
 IntelFrameworkModulePkg/Universal/BdsDxe/BdsEntry.c                           |  2 +-
 IntelFrameworkModulePkg/Universal/BdsDxe/BootMaint/BBSsupport.c               |  4 ++--
 IntelFrameworkModulePkg/Universal/BdsDxe/BootMaint/BootMaint.c                |  8 ++++----
 IntelFrameworkModulePkg/Universal/BdsDxe/BootMaint/BootOption.c               |  2 +-
 IntelFrameworkModulePkg/Universal/BdsDxe/BootMaint/ConsoleOption.c            |  6 +++---
 IntelFrameworkModulePkg/Universal/BdsDxe/BootMaint/UpdatePage.c               | 10 +++++-----
 IntelFrameworkModulePkg/Universal/BdsDxe/BootMaint/Variable.c                 |  2 +-
 IntelFrameworkModulePkg/Universal/BdsDxe/BootMngr/BootManager.c               |  2 +-
 MdeModulePkg/Application/MemoryProfileInfo/MemoryProfileInfo.c                |  6 +++---
 MdeModulePkg/Bus/Pci/PciBusDxe/PciLib.c                                       |  2 +-
 MdeModulePkg/Bus/Pci/PciHostBridgeDxe/PciHostBridge.c                         |  2 +-
 MdeModulePkg/Bus/Usb/UsbBusDxe/UsbHub.c                                       |  4 ++--
 MdeModulePkg/Core/Dxe/Mem/Pool.c                                              |  2 +-
 MdeModulePkg/Core/PiSmmCore/Pool.c                                            |  2 +-
 MdeModulePkg/Core/PiSmmCore/SmramProfileRecord.c                              |  6 +++---
 MdeModulePkg/Library/BootMaintenanceManagerUiLib/BootMaintenance.c            |  8 ++++----
 MdeModulePkg/Library/BootMaintenanceManagerUiLib/ConsoleOption.c              |  8 ++++----
 MdeModulePkg/Library/BootMaintenanceManagerUiLib/UpdatePage.c                 | 12 ++++++------
 MdeModulePkg/Library/BootMaintenanceManagerUiLib/Variable.c                   |  2 +-
 MdeModulePkg/Library/BootManagerUiLib/BootManager.c                           |  6 +++---
 MdeModulePkg/Library/UefiBootManagerLib/BmBootDescription.c                   |  2 +-
 MdeModulePkg/Library/UefiBootManagerLib/BmConsole.c                           |  2 +-
 MdeModulePkg/Library/UefiBootManagerLib/BmHotkey.c                            |  2 +-
 MdeModulePkg/Library/UefiBootManagerLib/BmLoadOption.c                        |  4 ++--
 MdeModulePkg/Library/VarCheckHiiLib/VarCheckHiiGen.c                          |  4 ++--
 MdeModulePkg/Library/VarCheckHiiLib/VarCheckHiiLibNullClass.c                 |  2 +-
 MdeModulePkg/Logo/Logo.c                                                      |  2 +-
 MdeModulePkg/Universal/BdsDxe/BdsEntry.c                                      |  2 +-
 MdeModulePkg/Universal/DisplayEngineDxe/FormDisplay.c                         |  4 ++--
 MdeModulePkg/Universal/DisplayEngineDxe/InputHandler.c                        |  6 +++---
 MdeModulePkg/Universal/EbcDxe/EbcExecute.c                                    |  2 +-
 MdeModulePkg/Universal/Network/Tcp4Dxe/Tcp4Output.c                           |  2 +-
 MdeModulePkg/Universal/RegularExpressionDxe/RegularExpressionDxe.h            |  2 --
 MdeModulePkg/Universal/Variable/RuntimeDxe/Variable.c                         |  2 +-
 MdePkg/Include/Base.h                                                         | 13 +++++++++++++
 NetworkPkg/Application/IpsecConfig/IpSecConfig.h                              |  2 --
 NetworkPkg/IScsiDxe/IScsiConfig.c                                             |  4 ++--
 NetworkPkg/IScsiDxe/IScsiDriver.c                                             |  2 +-
 NetworkPkg/IScsiDxe/IScsiMisc.c                                               |  6 +++---
 NetworkPkg/TcpDxe/TcpOutput.c                                                 |  2 +-
 Nt32Pkg/WinNtSerialIoDxe/WinNtSerialIo.c                                      |  2 +-
 OptionRomPkg/AtapiPassThruDxe/AtapiPassThru.c                                 |  4 ++--
 OvmfPkg/Library/PlatformBootManagerLib/BdsPlatform.c                          |  5 -----
 OvmfPkg/Library/QemuBootOrderLib/QemuBootOrderLib.c                           | 12 ++++++------
 OvmfPkg/QemuVideoDxe/Initialize.c                                             |  4 ++--
 OvmfPkg/XenBusDxe/XenStore.c                                                  |  1 -
 PerformancePkg/Dp_App/Dp.c                                                    |  2 +-
 PerformancePkg/Dp_App/DpTrace.c                                               | 10 +++++-----
 SecurityPkg/Library/AuthVariableLib/AuthVariableLib.c                         |  4 ++--
 ShellPkg/Library/UefiDpLib/DpTrace.c                                          | 10 +++++-----
 ShellPkg/Library/UefiShellLevel2CommandsLib/TimeDate.c                        |  2 +-
 Vlv2TbltDevicePkg/Application/FirmwareUpdate/FirmwareUpdate.c                 |  2 +-
 Vlv2TbltDevicePkg/PlatformInitPei/FlashMap.c                                  |  2 +-
 Vlv2TbltDevicePkg/PlatformPei/BootMode.c                                      |  6 +++---
 Vlv2TbltDevicePkg/PlatformSetupDxe/SetupInfoRecords.c                         |  2 +-
 Vlv2TbltDevicePkg/SmBiosMiscDxe/MiscOemType0x94Function.c                     |  2 +-
 65 files changed, 131 insertions(+), 128 deletions(-)

--
2.9.2



^ permalink raw reply	[flat|nested] 98+ messages in thread

* Re: [PATCH 15/47] IntelFrameworkModulePkg/LegacyBootManagerLib: rebase to ARRAY_SIZE()
  2016-10-26 19:04 ` [PATCH 15/47] IntelFrameworkModulePkg/LegacyBootManagerLib: " Laszlo Ersek
@ 2016-10-27  3:09   ` Fan, Jeff
  0 siblings, 0 replies; 98+ messages in thread
From: Fan, Jeff @ 2016-10-27  3:09 UTC (permalink / raw)
  To: Laszlo Ersek, edk2-devel-01

Reviewed-by: Jeff Fan <jeff.fan@intel.com>

-----Original Message-----
From: Laszlo Ersek [mailto:lersek@redhat.com] 
Sent: Thursday, October 27, 2016 3:05 AM
To: edk2-devel-01
Cc: Fan, Jeff
Subject: [PATCH 15/47] IntelFrameworkModulePkg/LegacyBootManagerLib: rebase to ARRAY_SIZE()

Cc: Jeff Fan <jeff.fan@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Laszlo Ersek <lersek@redhat.com>
---
 IntelFrameworkModulePkg/Library/LegacyBootManagerLib/LegacyBm.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/IntelFrameworkModulePkg/Library/LegacyBootManagerLib/LegacyBm.c b/IntelFrameworkModulePkg/Library/LegacyBootManagerLib/LegacyBm.c
index d3b48e8d0b9e..c56a8786391a 100644
--- a/IntelFrameworkModulePkg/Library/LegacyBootManagerLib/LegacyBm.c
+++ b/IntelFrameworkModulePkg/Library/LegacyBootManagerLib/LegacyBm.c
@@ -183,7 +183,7 @@ LegacyBmBuildLegacyDevNameString (
     //
     CopyMem (StringBufferA, StringDesc, LEGACY_BM_BOOT_DESCRIPTION_LENGTH);
     StringBufferA[LEGACY_BM_BOOT_DESCRIPTION_LENGTH] = 0;
-    AsciiStrToUnicodeStrS (StringBufferA, StringBufferU, sizeof (StringBufferU) / sizeof (StringBufferU[0]));
+    AsciiStrToUnicodeStrS (StringBufferA, StringBufferU, ARRAY_SIZE (StringBufferU));
     Fmt   = L"%s";
     Type  = StringBufferU;
   }
-- 
2.9.2




^ permalink raw reply related	[flat|nested] 98+ messages in thread

* Re: [PATCH 16/47] IntelFrameworkModulePkg/BdsDxe: rebase to ARRAY_SIZE()
  2016-10-26 19:04 ` [PATCH 16/47] IntelFrameworkModulePkg/BdsDxe: " Laszlo Ersek
@ 2016-10-27  3:12   ` Fan, Jeff
  0 siblings, 0 replies; 98+ messages in thread
From: Fan, Jeff @ 2016-10-27  3:12 UTC (permalink / raw)
  To: Laszlo Ersek, edk2-devel-01

Reviewed-by: Jeff Fan <jeff.fan@intel.com>

-----Original Message-----
From: Laszlo Ersek [mailto:lersek@redhat.com] 
Sent: Thursday, October 27, 2016 3:05 AM
To: edk2-devel-01
Cc: Fan, Jeff
Subject: [PATCH 16/47] IntelFrameworkModulePkg/BdsDxe: rebase to ARRAY_SIZE()

Cc: Jeff Fan <jeff.fan@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Laszlo Ersek <lersek@redhat.com>
---
 IntelFrameworkModulePkg/Universal/BdsDxe/BdsEntry.c                |  2 +-
 IntelFrameworkModulePkg/Universal/BdsDxe/BootMaint/BBSsupport.c    |  4 ++--
 IntelFrameworkModulePkg/Universal/BdsDxe/BootMaint/BootMaint.c     |  8 ++++----
 IntelFrameworkModulePkg/Universal/BdsDxe/BootMaint/BootOption.c    |  2 +-
 IntelFrameworkModulePkg/Universal/BdsDxe/BootMaint/ConsoleOption.c |  6 +++---
 IntelFrameworkModulePkg/Universal/BdsDxe/BootMaint/UpdatePage.c    | 10 +++++-----
 IntelFrameworkModulePkg/Universal/BdsDxe/BootMaint/Variable.c      |  2 +-
 IntelFrameworkModulePkg/Universal/BdsDxe/BootMngr/BootManager.c    |  2 +-
 8 files changed, 18 insertions(+), 18 deletions(-)

diff --git a/IntelFrameworkModulePkg/Universal/BdsDxe/BdsEntry.c b/IntelFrameworkModulePkg/Universal/BdsDxe/BdsEntry.c
index ae7ad2153c51..bf81de40a31d 100644
--- a/IntelFrameworkModulePkg/Universal/BdsDxe/BdsEntry.c
+++ b/IntelFrameworkModulePkg/Universal/BdsDxe/BdsEntry.c
@@ -581,7 +581,7 @@ BdsEntry (
   Status = gBS->LocateProtocol (&gEdkiiVariableLockProtocolGuid, NULL, (VOID **) &VariableLock);
   DEBUG ((EFI_D_INFO, "[BdsDxe] Locate Variable Lock protocol - %r\n", Status));
   if (!EFI_ERROR (Status)) {
-    for (Index = 0; Index < sizeof (mReadOnlyVariables) / sizeof (mReadOnlyVariables[0]); Index++) {
+    for (Index = 0; Index < ARRAY_SIZE (mReadOnlyVariables); Index++) {
       Status = VariableLock->RequestToLock (VariableLock, mReadOnlyVariables[Index], &gEfiGlobalVariableGuid);
       ASSERT_EFI_ERROR (Status);
     }
diff --git a/IntelFrameworkModulePkg/Universal/BdsDxe/BootMaint/BBSsupport.c b/IntelFrameworkModulePkg/Universal/BdsDxe/BootMaint/BBSsupport.c
index 6a0b525f1581..2ef9cf13ebb8 100644
--- a/IntelFrameworkModulePkg/Universal/BdsDxe/BootMaint/BBSsupport.c
+++ b/IntelFrameworkModulePkg/Universal/BdsDxe/BootMaint/BBSsupport.c
@@ -206,7 +206,7 @@ GroupMultipleLegacyBootOption4SameType (
       //
       // Legacy Boot Option
       //
-      ASSERT ((((BBS_BBS_DEVICE_PATH *) BootOption->DevicePath)->DeviceType & 0xF) < sizeof (DeviceTypeIndex) / sizeof (DeviceTypeIndex[0]));
+      ASSERT ((((BBS_BBS_DEVICE_PATH *) 
+ BootOption->DevicePath)->DeviceType & 0xF) < ARRAY_SIZE 
+ (DeviceTypeIndex));
       NextIndex = &DeviceTypeIndex[((BBS_BBS_DEVICE_PATH *) BootOption->DevicePath)->DeviceType & 0xF];
 
       if (*NextIndex == (UINTN) -1) {
@@ -225,7 +225,7 @@ GroupMultipleLegacyBootOption4SameType (
         //
         // Update the DeviceTypeIndex array to reflect the right shift operation
         //
-        for (DeviceIndex = 0; DeviceIndex < sizeof (DeviceTypeIndex) / sizeof (DeviceTypeIndex[0]); DeviceIndex++) {
+        for (DeviceIndex = 0; DeviceIndex < ARRAY_SIZE 
+ (DeviceTypeIndex); DeviceIndex++) {
           if (DeviceTypeIndex[DeviceIndex] != (UINTN) -1 && DeviceTypeIndex[DeviceIndex] >= *NextIndex) {
             DeviceTypeIndex[DeviceIndex]++;
           }
diff --git a/IntelFrameworkModulePkg/Universal/BdsDxe/BootMaint/BootMaint.c b/IntelFrameworkModulePkg/Universal/BdsDxe/BootMaint/BootMaint.c
index 96f84ece2a9a..d5ea0f457705 100644
--- a/IntelFrameworkModulePkg/Universal/BdsDxe/BootMaint/BootMaint.c
+++ b/IntelFrameworkModulePkg/Universal/BdsDxe/BootMaint/BootMaint.c
@@ -520,16 +520,16 @@ BootMaintRouteConfig (
     ASSERT (NewMenuEntry != NULL);
     NewTerminalContext = (BM_TERMINAL_CONTEXT *) NewMenuEntry->VariableContext;
     NewTerminalContext->BaudRateIndex = NewBmmData->COMBaudRate[Index];
-    ASSERT (NewBmmData->COMBaudRate[Index] < (sizeof (BaudRateList) / sizeof (BaudRateList[0])));
+    ASSERT (NewBmmData->COMBaudRate[Index] < (ARRAY_SIZE 
+ (BaudRateList)));
     NewTerminalContext->BaudRate      = BaudRateList[NewBmmData->COMBaudRate[Index]].Value;
     NewTerminalContext->DataBitsIndex = NewBmmData->COMDataRate[Index];
-    ASSERT (NewBmmData->COMDataRate[Index] < (sizeof (DataBitsList) / sizeof (DataBitsList[0])));
+    ASSERT (NewBmmData->COMDataRate[Index] < (ARRAY_SIZE 
+ (DataBitsList)));
     NewTerminalContext->DataBits      = (UINT8) DataBitsList[NewBmmData->COMDataRate[Index]].Value;
     NewTerminalContext->StopBitsIndex = NewBmmData->COMStopBits[Index];
-    ASSERT (NewBmmData->COMStopBits[Index] < (sizeof (StopBitsList) / sizeof (StopBitsList[0])));
+    ASSERT (NewBmmData->COMStopBits[Index] < (ARRAY_SIZE 
+ (StopBitsList)));
     NewTerminalContext->StopBits      = (UINT8) StopBitsList[NewBmmData->COMStopBits[Index]].Value;
     NewTerminalContext->ParityIndex   = NewBmmData->COMParity[Index];
-    ASSERT (NewBmmData->COMParity[Index] < (sizeof (ParityList) / sizeof (ParityList[0])));
+    ASSERT (NewBmmData->COMParity[Index] < (ARRAY_SIZE (ParityList)));
     NewTerminalContext->Parity        = (UINT8) ParityList[NewBmmData->COMParity[Index]].Value;
     NewTerminalContext->TerminalType  = NewBmmData->COMTerminalType[Index];
     NewTerminalContext->FlowControl   = NewBmmData->COMFlowControl[Index];
diff --git a/IntelFrameworkModulePkg/Universal/BdsDxe/BootMaint/BootOption.c b/IntelFrameworkModulePkg/Universal/BdsDxe/BootMaint/BootOption.c
index 56bcfab23f43..5898fb31bb2b 100644
--- a/IntelFrameworkModulePkg/Universal/BdsDxe/BootMaint/BootOption.c
+++ b/IntelFrameworkModulePkg/Universal/BdsDxe/BootMaint/BootOption.c
@@ -1702,7 +1702,7 @@ GetLegacyDeviceOrder (
   LegacyOrder = NULL;
   OldData     = NULL;
   DisMap      = ZeroMem (CallbackData->BmmFakeNvData.DisableMap, sizeof (CallbackData->BmmFakeNvData.DisableMap));
-  PageNum     = sizeof (PageIdList) / sizeof (PageIdList[0]);
+  PageNum     = ARRAY_SIZE (PageIdList);
   VarData     = BdsLibGetVariableAndSize (
                   VAR_LEGACY_DEV_ORDER,
                   &gEfiLegacyDevOrderVariableGuid, diff --git a/IntelFrameworkModulePkg/Universal/BdsDxe/BootMaint/ConsoleOption.c b/IntelFrameworkModulePkg/Universal/BdsDxe/BootMaint/ConsoleOption.c
index 1854b98c360f..126feeb9ae51 100644
--- a/IntelFrameworkModulePkg/Universal/BdsDxe/BootMaint/ConsoleOption.c
+++ b/IntelFrameworkModulePkg/Universal/BdsDxe/BootMaint/ConsoleOption.c
@@ -1167,21 +1167,21 @@ GetTerminalAttribute (
         break;
       }
     }
-    for (AttributeIndex = 0; AttributeIndex < sizeof (DataBitsList) / sizeof (DataBitsList[0]); AttributeIndex++) {
+    for (AttributeIndex = 0; AttributeIndex < ARRAY_SIZE 
+ (DataBitsList); AttributeIndex++) {
       if (NewTerminalContext->DataBits == (UINT64) (DataBitsList[AttributeIndex].Value)) {
         NewTerminalContext->DataBitsIndex = AttributeIndex;
         break;
       }
     }    
     
-    for (AttributeIndex = 0; AttributeIndex < sizeof (ParityList) / sizeof (ParityList[0]); AttributeIndex++) {
+    for (AttributeIndex = 0; AttributeIndex < ARRAY_SIZE (ParityList); 
+ AttributeIndex++) {
       if (NewTerminalContext->Parity == (UINT64) (ParityList[AttributeIndex].Value)) {
         NewTerminalContext->ParityIndex = AttributeIndex;
         break;
       }
     }            
     
-    for (AttributeIndex = 0; AttributeIndex < sizeof (StopBitsList) / sizeof (StopBitsList[0]); AttributeIndex++) {
+    for (AttributeIndex = 0; AttributeIndex < ARRAY_SIZE 
+ (StopBitsList); AttributeIndex++) {
       if (NewTerminalContext->StopBits == (UINT64) (StopBitsList[AttributeIndex].Value)) {
         NewTerminalContext->StopBitsIndex = AttributeIndex;
         break;
diff --git a/IntelFrameworkModulePkg/Universal/BdsDxe/BootMaint/UpdatePage.c b/IntelFrameworkModulePkg/Universal/BdsDxe/BootMaint/UpdatePage.c
index b13ed116303b..02efefd2a614 100644
--- a/IntelFrameworkModulePkg/Universal/BdsDxe/BootMaint/UpdatePage.c
+++ b/IntelFrameworkModulePkg/Universal/BdsDxe/BootMaint/UpdatePage.c
@@ -830,7 +830,7 @@ UpdateConModePage (
     //
     UnicodeValueToString (ModeString, 0, Col, 0);
     PStr = &ModeString[0];
-    StrCatS (PStr, sizeof (ModeString) / sizeof (ModeString[0]), L" x ");
+    StrCatS (PStr, ARRAY_SIZE (ModeString), L" x ");
     PStr = PStr + StrLen (PStr);
     UnicodeValueToString (PStr , 0, Row, 0);
 
@@ -939,7 +939,7 @@ UpdateTerminalPage (
   OptionsOpCodeHandle = HiiAllocateOpCodeHandle ();
   ASSERT (OptionsOpCodeHandle != NULL);
 
-  for (Index = 0; Index < sizeof (DataBitsList) / sizeof (DataBitsList[0]); Index++) {
+  for (Index = 0; Index < ARRAY_SIZE (DataBitsList); Index++) {
     CheckFlags = 0;
 
     if (DataBitsList[Index].Value == 8) { @@ -972,7 +972,7 @@ UpdateTerminalPage (
   OptionsOpCodeHandle = HiiAllocateOpCodeHandle ();
   ASSERT (OptionsOpCodeHandle != NULL);
 
-  for (Index = 0; Index < sizeof (ParityList) / sizeof (ParityList[0]); Index++) {
+  for (Index = 0; Index < ARRAY_SIZE (ParityList); Index++) {
     CheckFlags = 0;
     if (ParityList[Index].Value ==  NoParity) {
       CheckFlags |= EFI_IFR_OPTION_DEFAULT; @@ -1004,7 +1004,7 @@ UpdateTerminalPage (
   OptionsOpCodeHandle = HiiAllocateOpCodeHandle ();
   ASSERT (OptionsOpCodeHandle != NULL);
 
-  for (Index = 0; Index < sizeof (StopBitsList) / sizeof (StopBitsList[0]); Index++) {
+  for (Index = 0; Index < ARRAY_SIZE (StopBitsList); Index++) {
     CheckFlags = 0;
     if (StopBitsList[Index].Value == OneStopBit) {
       CheckFlags |= EFI_IFR_OPTION_DEFAULT; @@ -1068,7 +1068,7 @@ UpdateTerminalPage (
   OptionsOpCodeHandle = HiiAllocateOpCodeHandle ();
   ASSERT (OptionsOpCodeHandle != NULL);
 
-  for (Index = 0; Index < sizeof (mFlowControlType) / sizeof (mFlowControlType[0]); Index++) {
+  for (Index = 0; Index < ARRAY_SIZE (mFlowControlType); Index++) {
   CheckFlags = 0;
     if (Index == 0) {
       CheckFlags |= EFI_IFR_OPTION_DEFAULT; diff --git a/IntelFrameworkModulePkg/Universal/BdsDxe/BootMaint/Variable.c b/IntelFrameworkModulePkg/Universal/BdsDxe/BootMaint/Variable.c
index b933dd9699cb..414367cf2387 100644
--- a/IntelFrameworkModulePkg/Universal/BdsDxe/BootMaint/Variable.c
+++ b/IntelFrameworkModulePkg/Universal/BdsDxe/BootMaint/Variable.c
@@ -448,7 +448,7 @@ Var_UpdateConsoleOption (
       Vendor.Header.Type    = MESSAGING_DEVICE_PATH;
       Vendor.Header.SubType = MSG_VENDOR_DP;
       
-      ASSERT (NewTerminalContext->TerminalType < (sizeof (TerminalTypeGuid) / sizeof (TerminalTypeGuid[0])));
+      ASSERT (NewTerminalContext->TerminalType < (ARRAY_SIZE 
+ (TerminalTypeGuid)));
       CopyMem (
         &Vendor.Guid,
         &TerminalTypeGuid[NewTerminalContext->TerminalType],
diff --git a/IntelFrameworkModulePkg/Universal/BdsDxe/BootMngr/BootManager.c b/IntelFrameworkModulePkg/Universal/BdsDxe/BootMngr/BootManager.c
index 6efd783ab219..9ee063859ce1 100644
--- a/IntelFrameworkModulePkg/Universal/BdsDxe/BootMngr/BootManager.c
+++ b/IntelFrameworkModulePkg/Universal/BdsDxe/BootMngr/BootManager.c
@@ -305,7 +305,7 @@ CallBootManager (
                      HiiHandle,
                      0,
                      mDeviceTypeStr[
-                       MIN (DeviceType & 0xF, sizeof (mDeviceTypeStr) / sizeof (mDeviceTypeStr[0]) - 1)
+                       MIN (DeviceType & 0xF, ARRAY_SIZE 
+ (mDeviceTypeStr) - 1)
                        ],
                      NULL
                      );
--
2.9.2




^ permalink raw reply related	[flat|nested] 98+ messages in thread

* Re: [PATCH 04/47] OvmfPkg/XenBusDxe: guard the definition of ARRAY_SIZE
  2016-10-26 19:04 ` [PATCH 04/47] OvmfPkg/XenBusDxe: " Laszlo Ersek
@ 2016-10-27  3:15   ` Gary Lin
  0 siblings, 0 replies; 98+ messages in thread
From: Gary Lin @ 2016-10-27  3:15 UTC (permalink / raw)
  To: Laszlo Ersek; +Cc: edk2-devel-01, Jordan Justen

On Wed, Oct 26, 2016 at 09:04:21PM +0200, Laszlo Ersek wrote:
> In one of the next patches, we'll introduce ARRAY_SIZE in
> "MdePkg/Include/Base.h". In order to proceed in small steps, make the
> module-local definition of ARRAY_SIZE conditional. This way the
> introduction of the macro under MdePkg will silently switch this module
> over (after which we can remove the module-local definition completely).

It's nice to have a centralized macro.

Reviewed-by: Gary Lin <glin@suse.com>

> 
> Cc: Gary Lin <glin@suse.com>
> Cc: Jordan Justen <jordan.l.justen@intel.com>
> Contributed-under: TianoCore Contribution Agreement 1.0
> Signed-off-by: Laszlo Ersek <lersek@redhat.com>
> ---
>  OvmfPkg/XenBusDxe/XenStore.c | 2 ++
>  1 file changed, 2 insertions(+)
> 
> diff --git a/OvmfPkg/XenBusDxe/XenStore.c b/OvmfPkg/XenBusDxe/XenStore.c
> index b7ae1d04863d..9eeb6f54fb50 100644
> --- a/OvmfPkg/XenBusDxe/XenStore.c
> +++ b/OvmfPkg/XenBusDxe/XenStore.c
> @@ -713,7 +713,9 @@ static XenStoreErrors gXenStoreErrors[] = {
>    { XENSTORE_STATUS_EISCONN, "EISCONN" },
>    { XENSTORE_STATUS_E2BIG, "E2BIG" }
>  };
> +#ifndef ARRAY_SIZE
>  #define ARRAY_SIZE(x) (sizeof(x) / sizeof(x[0]))
> +#endif
>  
>  STATIC
>  XENSTORE_STATUS
> -- 
> 2.9.2
> 
> 
> 


^ permalink raw reply	[flat|nested] 98+ messages in thread

* Re: [PATCH 09/47] OvmfPkg/XenBusDxe: remove module-local ARRAY_SIZE macro
  2016-10-26 19:04 ` [PATCH 09/47] OvmfPkg/XenBusDxe: " Laszlo Ersek
@ 2016-10-27  3:16   ` Gary Lin
  0 siblings, 0 replies; 98+ messages in thread
From: Gary Lin @ 2016-10-27  3:16 UTC (permalink / raw)
  To: Laszlo Ersek; +Cc: edk2-devel-01, Jordan Justen

On Wed, Oct 26, 2016 at 09:04:26PM +0200, Laszlo Ersek wrote:
> Rely on the central macro definition from "MdePkg/Include/Base.h" instead.
> 
Reviewed-by: Gary Lin <glin@suse.com>

> Cc: Gary Lin <glin@suse.com>
> Cc: Jordan Justen <jordan.l.justen@intel.com>
> Contributed-under: TianoCore Contribution Agreement 1.0
> Signed-off-by: Laszlo Ersek <lersek@redhat.com>
> ---
>  OvmfPkg/XenBusDxe/XenStore.c | 3 ---
>  1 file changed, 3 deletions(-)
> 
> diff --git a/OvmfPkg/XenBusDxe/XenStore.c b/OvmfPkg/XenBusDxe/XenStore.c
> index 9eeb6f54fb50..1666c4b8f90f 100644
> --- a/OvmfPkg/XenBusDxe/XenStore.c
> +++ b/OvmfPkg/XenBusDxe/XenStore.c
> @@ -713,9 +713,6 @@ static XenStoreErrors gXenStoreErrors[] = {
>    { XENSTORE_STATUS_EISCONN, "EISCONN" },
>    { XENSTORE_STATUS_E2BIG, "E2BIG" }
>  };
> -#ifndef ARRAY_SIZE
> -#define ARRAY_SIZE(x) (sizeof(x) / sizeof(x[0]))
> -#endif
>  
>  STATIC
>  XENSTORE_STATUS
> -- 
> 2.9.2
> 
> 
> 


^ permalink raw reply	[flat|nested] 98+ messages in thread

* Re: [PATCH 00/47] edk2: centralize and adopt ARRAY_SIZE()
  2016-10-26 19:04 [PATCH 00/47] edk2: centralize and adopt ARRAY_SIZE() Laszlo Ersek
                   ` (48 preceding siblings ...)
  2016-10-27  1:17 ` Tian, Feng
@ 2016-10-27  4:43 ` Gary Lin
  2016-10-27  7:52   ` Laszlo Ersek
  2016-10-27  6:05 ` Jordan Justen
  2016-10-27  9:27 ` Laszlo Ersek
  51 siblings, 1 reply; 98+ messages in thread
From: Gary Lin @ 2016-10-27  4:43 UTC (permalink / raw)
  To: Laszlo Ersek
  Cc: edk2-devel-01, Ruiyu Ni, Tim He, Feng Tian, Michael D Kinney,
	Eric Dong, Cecil Sheng, Ard Biesheuvel, Jordan Justen, Liming Gao,
	Dandan Bi, Jiaxin Wu, Star Zeng, Daryl McDaniel, Jaben Carsey,
	Siyuan Fu, Jeff Fan, Chao Zhang, David Wei

On Wed, Oct 26, 2016 at 09:04:17PM +0200, Laszlo Ersek wrote:
> I'm sure most of us have wished at some point that ARRAY_SIZE()
> had existed in a central header file, like it does in many other
> open source projects. This series implements that.
> 
> Patches 01-04 round up the modules that #define ARRAY_SIZE() just
> for themselves, and wrap their definitions in #ifndef ARRAY_SIZE.
> 
> Patch 05 defines ARRAY_SIZE() in "MdePkg/Include/Base.h". This
> flips the previously modified modules to MdePkg's macro definition.
> 
> Patches 06-09 modify the same set of modules as patches 01-04 do; this
> time the (now unused) module-local ARRAY_SIZE() macro definitions are
> eliminated.
> 
> The rest of the patches (10-47) migrate the edk2 tree to ARRAY_SIZE(),
> covering the most obvious open-coded ARRAY_SIZE() expressions. These
> expressions were located and converted with the following shell
> pipeline:
> 
>   git ls-files \
>   | xargs --no-run-if-empty -- \
>       sed --regexp-extended --in-place \
>         --expression='s,sizeof \(([a-zA-Z0-9_]+)\) / sizeof \((\*\1|\1\[0\])\),ARRAY_SIZE (\1),g' \
>         --
Hi Laszlo,

I found several missing cases in OvmfPkg:

Library/PciHostBridgeLib/PciHostBridgeLib.c:

421:      ASSERT (Descriptor->ResType <
422:              (sizeof (mPciHostBridgeLibAcpiAddressSpaceTypeStr) /
423:               sizeof (mPciHostBridgeLibAcpiAddressSpaceTypeStr[0])
424:              )
425:             );

--
VirtioGpuDxe/Gop.c:

207:  if (ModeNumber >= sizeof mGopResolutions / sizeof mGopResolutions[0]) {


242:  if (ModeNumber >= sizeof mGopResolutions / sizeof mGopResolutions[0]) {

261:    VgpuGop->GopMode.MaxMode         = (UINT32)(sizeof mGopResolutions /
262:                                                sizeof mGopResolutions[0]);

--
Library/LoadLinuxLib/Linux.c:

360:  if (E820EntryCount >= (sizeof (Bp->e820_map) / sizeof (Bp->e820_map[0]))) {

--
Csm/CsmSupportLib/LegacyRegion.c:

133:  for (Index = 0; Index < (sizeof(mSectionArray) / sizeof (mSectionArray[0])); Index++) {

139:  ASSERT (Index < (sizeof(mSectionArray) / sizeof (mSectionArray[0])));

144:  for (Index = StartIndex; Index < (sizeof(mSectionArray) / sizeof (mSectionArray[0])); Index++) {

180:  ASSERT (Index < (sizeof(mSectionArray) / sizeof (mSectionArray[0])));


Cheers,

Gary Lin

> 
> This pipeline lists all tracked files with "git". The pathnames are then
> composed with "xargs" into maximal length "sed" command lines, and those
> "sed" commands are run.
> 
> Here the "sed" stream editor filters and modifies all the listed files
> in place. The extended regular expression replaces the following two
> patterns:
> 
>   sizeof (ArrayName) / sizeof (*ArrayName)
>   sizeof (ArrayName) / sizeof (ArrayName[0])
> 
> with
> 
>   ARRAY_SIZE (ArrayName)
> 
> The regexp uses a backreference in the match, ensuring that the sizeof
> operator in the dividend and the sizeof operator in the divisor both
> refer to the same ArrayName. If there are multiple occurrences on the
> same line, the sed command replaces all of them.
> 
> I collected the changes into patches manually, and I reviewed them all.
> 
> I test-built all of the modified packages, repeating the command
> 
>   build -a X64 -t GCC48 -b DEBUG -p FooPkg/FooPkg.dsc
> 
> as many times as necessary. Two packages were impossible to build like
> this: Nt32Pkg and Vlv2TbltDevicePkg, so I couldn't build-test them.
> 
> I did some light-weight testing with OVMF: boot with Secure Boot
> enabled, S3 suspend/resume with and without SMM. I also booted
> ArmVirtQemu once.
> 
> Repository: https://github.com/lersek/edk2.git
> Branch:     array_size
> 
> Cc: Ard Biesheuvel <ard.biesheuvel@linaro.org>
> Cc: Cecil Sheng <cecil.sheng@hpe.com>
> Cc: Chao Zhang <chao.b.zhang@intel.com>
> Cc: Dandan Bi <dandan.bi@intel.com>
> Cc: Daryl McDaniel <edk2-lists@mc2research.org>
> Cc: David Wei <david.wei@intel.com>
> Cc: Eric Dong <eric.dong@intel.com>
> Cc: Feng Tian <feng.tian@intel.com>
> Cc: Gary Lin <glin@suse.com>
> Cc: Jaben Carsey <jaben.carsey@intel.com>
> Cc: Jeff Fan <jeff.fan@intel.com>
> Cc: Jiaxin Wu <jiaxin.wu@intel.com>
> Cc: Jordan Justen <jordan.l.justen@intel.com>
> Cc: Liming Gao <liming.gao@intel.com>
> Cc: Michael D Kinney <michael.d.kinney@intel.com>
> Cc: Ruiyu Ni <ruiyu.ni@intel.com>
> Cc: Siyuan Fu <siyuan.fu@intel.com>
> Cc: Star Zeng <star.zeng@intel.com>
> Cc: Tim He <tim.he@intel.com>
> 
> Thanks
> Laszlo
> 
> Laszlo Ersek (47):
>   MdeModulePkg/RegularExpressionDxe: guard the definition of ARRAY_SIZE
>   NetworkPkg/IpsecConfig: guard the definition of ARRAY_SIZE
>   OvmfPkg/PlatformBootManagerLib: guard the definition of ARRAY_SIZE
>   OvmfPkg/XenBusDxe: guard the definition of ARRAY_SIZE
>   MdePkg/Include/Base.h: introduce the ARRAY_SIZE() function-like macro
>   MdeModulePkg/RegularExpressionDxe: remove module-local ARRAY_SIZE
>     macro
>   NetworkPkg/IpsecConfig: remove module-local ARRAY_SIZE macro
>   OvmfPkg/PlatformBootManagerLib: remove module-local ARRAY_SIZE macro
>   OvmfPkg/XenBusDxe: remove module-local ARRAY_SIZE macro
>   ArmVirtPkg/NorFlashQemuLib: rebase to ARRAY_SIZE()
>   DuetPkg/DuetBdsLib: rebase to ARRAY_SIZE()
>   EdkCompatibilityPkg/FrameworkHiiOnUefiHiiThunk: rebase to ARRAY_SIZE()
>   EdkCompatibilityPkg/Sample/Tools: rebase to ARRAY_SIZE()
>   FatPkg/EnhancedFatDxe: rebase to ARRAY_SIZE()
>   IntelFrameworkModulePkg/LegacyBootManagerLib: rebase to ARRAY_SIZE()
>   IntelFrameworkModulePkg/BdsDxe: rebase to ARRAY_SIZE()
>   MdeModulePkg/MemoryProfileInfo: rebase to ARRAY_SIZE()
>   MdeModulePkg/PciBusDxe: rebase to ARRAY_SIZE()
>   MdeModulePkg/PciHostBridgeDxe: rebase to ARRAY_SIZE()
>   MdeModulePkg/UsbBusDxe: rebase to ARRAY_SIZE()
>   MdeModulePkg/Core/Dxe: rebase to ARRAY_SIZE()
>   MdeModulePkg/Core/PiSmmCore: rebase to ARRAY_SIZE()
>   MdeModulePkg/BootMaintenanceManagerUiLib: rebase to ARRAY_SIZE()
>   MdeModulePkg/BootManagerUiLib: rebase to ARRAY_SIZE()
>   MdeModulePkg/UefiBootManagerLib: rebase to ARRAY_SIZE()
>   MdeModulePkg/VarCheckHiiLib: rebase to ARRAY_SIZE()
>   MdeModulePkg/Logo: rebase to ARRAY_SIZE()
>   MdeModulePkg/BdsDxe: rebase to ARRAY_SIZE()
>   MdeModulePkg/DisplayEngineDxe: rebase to ARRAY_SIZE()
>   MdeModulePkg/EbcDxe: rebase to ARRAY_SIZE()
>   MdeModulePkg/Tcp4Dxe: rebase to ARRAY_SIZE()
>   MdeModulePkg/Variable/RuntimeDxe: rebase to ARRAY_SIZE()
>   NetworkPkg/IScsiDxe: rebase to ARRAY_SIZE()
>   NetworkPkg/TcpDxe: rebase to ARRAY_SIZE()
>   Nt32Pkg/WinNtSerialIoDxe: rebase to ARRAY_SIZE()
>   OptionRomPkg/AtapiPassThruDxe: rebase to ARRAY_SIZE()
>   OvmfPkg/QemuBootOrderLib: rebase to ARRAY_SIZE()
>   OvmfPkg/QemuVideoDxe: rebase to ARRAY_SIZE()
>   PerformancePkg/Dp_App: rebase to ARRAY_SIZE()
>   SecurityPkg/AuthVariableLib: rebase to ARRAY_SIZE()
>   ShellPkg/UefiDpLib: rebase to ARRAY_SIZE()
>   ShellPkg/UefiShellLevel2CommandsLib: rebase to ARRAY_SIZE()
>   Vlv2TbltDevicePkg/FirmwareUpdate: rebase to ARRAY_SIZE()
>   Vlv2TbltDevicePkg/PlatformInitPei: rebase to ARRAY_SIZE()
>   Vlv2TbltDevicePkg/PlatformPei: rebase to ARRAY_SIZE()
>   Vlv2TbltDevicePkg/PlatformSetupDxe: rebase to ARRAY_SIZE()
>   Vlv2TbltDevicePkg/SmBiosMiscDxe: rebase to ARRAY_SIZE()
> 
>  ArmVirtPkg/Library/NorFlashQemuLib/NorFlashQemuLib.c                          |  2 +-
>  DuetPkg/Library/DuetBdsLib/BdsPlatform.c                                      |  2 +-
>  EdkCompatibilityPkg/Compatibility/FrameworkHiiOnUefiHiiThunk/OpcodeCreation.c |  2 +-
>  EdkCompatibilityPkg/Sample/Tools/Source/EfiRom/EfiRom.c                       |  4 ++--
>  EdkCompatibilityPkg/Sample/Tools/Source/HiiPack/IfrParse.c                    |  2 +-
>  FatPkg/EnhancedFatDxe/DirectoryManage.c                                       |  4 ++--
>  FatPkg/EnhancedFatDxe/FileName.c                                              |  4 ++--
>  FatPkg/EnhancedFatDxe/Hash.c                                                  |  4 ++--
>  IntelFrameworkModulePkg/Library/LegacyBootManagerLib/LegacyBm.c               |  2 +-
>  IntelFrameworkModulePkg/Universal/BdsDxe/BdsEntry.c                           |  2 +-
>  IntelFrameworkModulePkg/Universal/BdsDxe/BootMaint/BBSsupport.c               |  4 ++--
>  IntelFrameworkModulePkg/Universal/BdsDxe/BootMaint/BootMaint.c                |  8 ++++----
>  IntelFrameworkModulePkg/Universal/BdsDxe/BootMaint/BootOption.c               |  2 +-
>  IntelFrameworkModulePkg/Universal/BdsDxe/BootMaint/ConsoleOption.c            |  6 +++---
>  IntelFrameworkModulePkg/Universal/BdsDxe/BootMaint/UpdatePage.c               | 10 +++++-----
>  IntelFrameworkModulePkg/Universal/BdsDxe/BootMaint/Variable.c                 |  2 +-
>  IntelFrameworkModulePkg/Universal/BdsDxe/BootMngr/BootManager.c               |  2 +-
>  MdeModulePkg/Application/MemoryProfileInfo/MemoryProfileInfo.c                |  6 +++---
>  MdeModulePkg/Bus/Pci/PciBusDxe/PciLib.c                                       |  2 +-
>  MdeModulePkg/Bus/Pci/PciHostBridgeDxe/PciHostBridge.c                         |  2 +-
>  MdeModulePkg/Bus/Usb/UsbBusDxe/UsbHub.c                                       |  4 ++--
>  MdeModulePkg/Core/Dxe/Mem/Pool.c                                              |  2 +-
>  MdeModulePkg/Core/PiSmmCore/Pool.c                                            |  2 +-
>  MdeModulePkg/Core/PiSmmCore/SmramProfileRecord.c                              |  6 +++---
>  MdeModulePkg/Library/BootMaintenanceManagerUiLib/BootMaintenance.c            |  8 ++++----
>  MdeModulePkg/Library/BootMaintenanceManagerUiLib/ConsoleOption.c              |  8 ++++----
>  MdeModulePkg/Library/BootMaintenanceManagerUiLib/UpdatePage.c                 | 12 ++++++------
>  MdeModulePkg/Library/BootMaintenanceManagerUiLib/Variable.c                   |  2 +-
>  MdeModulePkg/Library/BootManagerUiLib/BootManager.c                           |  6 +++---
>  MdeModulePkg/Library/UefiBootManagerLib/BmBootDescription.c                   |  2 +-
>  MdeModulePkg/Library/UefiBootManagerLib/BmConsole.c                           |  2 +-
>  MdeModulePkg/Library/UefiBootManagerLib/BmHotkey.c                            |  2 +-
>  MdeModulePkg/Library/UefiBootManagerLib/BmLoadOption.c                        |  4 ++--
>  MdeModulePkg/Library/VarCheckHiiLib/VarCheckHiiGen.c                          |  4 ++--
>  MdeModulePkg/Library/VarCheckHiiLib/VarCheckHiiLibNullClass.c                 |  2 +-
>  MdeModulePkg/Logo/Logo.c                                                      |  2 +-
>  MdeModulePkg/Universal/BdsDxe/BdsEntry.c                                      |  2 +-
>  MdeModulePkg/Universal/DisplayEngineDxe/FormDisplay.c                         |  4 ++--
>  MdeModulePkg/Universal/DisplayEngineDxe/InputHandler.c                        |  6 +++---
>  MdeModulePkg/Universal/EbcDxe/EbcExecute.c                                    |  2 +-
>  MdeModulePkg/Universal/Network/Tcp4Dxe/Tcp4Output.c                           |  2 +-
>  MdeModulePkg/Universal/RegularExpressionDxe/RegularExpressionDxe.h            |  2 --
>  MdeModulePkg/Universal/Variable/RuntimeDxe/Variable.c                         |  2 +-
>  MdePkg/Include/Base.h                                                         | 13 +++++++++++++
>  NetworkPkg/Application/IpsecConfig/IpSecConfig.h                              |  2 --
>  NetworkPkg/IScsiDxe/IScsiConfig.c                                             |  4 ++--
>  NetworkPkg/IScsiDxe/IScsiDriver.c                                             |  2 +-
>  NetworkPkg/IScsiDxe/IScsiMisc.c                                               |  6 +++---
>  NetworkPkg/TcpDxe/TcpOutput.c                                                 |  2 +-
>  Nt32Pkg/WinNtSerialIoDxe/WinNtSerialIo.c                                      |  2 +-
>  OptionRomPkg/AtapiPassThruDxe/AtapiPassThru.c                                 |  4 ++--
>  OvmfPkg/Library/PlatformBootManagerLib/BdsPlatform.c                          |  5 -----
>  OvmfPkg/Library/QemuBootOrderLib/QemuBootOrderLib.c                           | 12 ++++++------
>  OvmfPkg/QemuVideoDxe/Initialize.c                                             |  4 ++--
>  OvmfPkg/XenBusDxe/XenStore.c                                                  |  1 -
>  PerformancePkg/Dp_App/Dp.c                                                    |  2 +-
>  PerformancePkg/Dp_App/DpTrace.c                                               | 10 +++++-----
>  SecurityPkg/Library/AuthVariableLib/AuthVariableLib.c                         |  4 ++--
>  ShellPkg/Library/UefiDpLib/DpTrace.c                                          | 10 +++++-----
>  ShellPkg/Library/UefiShellLevel2CommandsLib/TimeDate.c                        |  2 +-
>  Vlv2TbltDevicePkg/Application/FirmwareUpdate/FirmwareUpdate.c                 |  2 +-
>  Vlv2TbltDevicePkg/PlatformInitPei/FlashMap.c                                  |  2 +-
>  Vlv2TbltDevicePkg/PlatformPei/BootMode.c                                      |  6 +++---
>  Vlv2TbltDevicePkg/PlatformSetupDxe/SetupInfoRecords.c                         |  2 +-
>  Vlv2TbltDevicePkg/SmBiosMiscDxe/MiscOemType0x94Function.c                     |  2 +-
>  65 files changed, 131 insertions(+), 128 deletions(-)
> 
> -- 
> 2.9.2
> 
> _______________________________________________
> edk2-devel mailing list
> edk2-devel@lists.01.org
> https://lists.01.org/mailman/listinfo/edk2-devel
> 


^ permalink raw reply	[flat|nested] 98+ messages in thread

* Re: [PATCH 00/47] edk2: centralize and adopt ARRAY_SIZE()
  2016-10-26 19:04 [PATCH 00/47] edk2: centralize and adopt ARRAY_SIZE() Laszlo Ersek
                   ` (49 preceding siblings ...)
  2016-10-27  4:43 ` Gary Lin
@ 2016-10-27  6:05 ` Jordan Justen
  2016-10-27  8:49   ` Laszlo Ersek
  2016-10-27  9:27 ` Laszlo Ersek
  51 siblings, 1 reply; 98+ messages in thread
From: Jordan Justen @ 2016-10-27  6:05 UTC (permalink / raw)
  To: Laszlo Ersek, edk2-devel-01
  Cc: Ard Biesheuvel, Cecil Sheng, Chao Zhang, Dandan Bi,
	Daryl McDaniel, David Wei, Eric Dong, Feng Tian, Gary Lin,
	Jaben Carsey, Jeff Fan, Jiaxin Wu, Liming Gao, Michael D Kinney,
	Ruiyu Ni, Siyuan Fu, Star Zeng, Tim He

On 2016-10-26 12:04:17, Laszlo Ersek wrote:
> I'm sure most of us have wished at some point that ARRAY_SIZE()
> had existed in a central header file, like it does in many other
> open source projects.

Indeed!

> This series implements that.
> 
> Patches 01-04 round up the modules that #define ARRAY_SIZE() just
> for themselves, and wrap their definitions in #ifndef ARRAY_SIZE.
> 
> Patch 05 defines ARRAY_SIZE() in "MdePkg/Include/Base.h". This
> flips the previously modified modules to MdePkg's macro definition.
> 
> Patches 06-09 modify the same set of modules as patches 01-04 do; this
> time the (now unused) module-local ARRAY_SIZE() macro definitions are
> eliminated.
> 
> The rest of the patches (10-47) migrate the edk2 tree to ARRAY_SIZE(),
> covering the most obvious open-coded ARRAY_SIZE() expressions. These
> expressions were located and converted with the following shell
> pipeline:
> 
>   git ls-files \
>   | xargs --no-run-if-empty -- \
>       sed --regexp-extended --in-place \
>         --expression='s,sizeof \(([a-zA-Z0-9_]+)\) / sizeof \((\*\1|\1\[0\])\),ARRAY_SIZE (\1),g' \
>         --
> 
> This pipeline lists all tracked files with "git". The pathnames are then
> composed with "xargs" into maximal length "sed" command lines, and those
> "sed" commands are run.
> 
> Here the "sed" stream editor filters and modifies all the listed files
> in place. The extended regular expression replaces the following two
> patterns:
> 
>   sizeof (ArrayName) / sizeof (*ArrayName)
>   sizeof (ArrayName) / sizeof (ArrayName[0])
> 
> with
> 
>   ARRAY_SIZE (ArrayName)
> 
> The regexp uses a backreference in the match, ensuring that the sizeof
> operator in the dividend and the sizeof operator in the divisor both
> refer to the same ArrayName. If there are multiple occurrences on the
> same line, the sed command replaces all of them.
> 
> I collected the changes into patches manually, and I reviewed them all.
> 
> I test-built all of the modified packages, repeating the command
> 
>   build -a X64 -t GCC48 -b DEBUG -p FooPkg/FooPkg.dsc
> 
> as many times as necessary. Two packages were impossible to build like
> this: Nt32Pkg and Vlv2TbltDevicePkg, so I couldn't build-test them.
> 
> I did some light-weight testing with OVMF: boot with Secure Boot
> enabled, S3 suspend/resume with and without SMM. I also booted
> ArmVirtQemu once.
> 
> Repository: https://github.com/lersek/edk2.git
> Branch:     array_size
> 
> Cc: Ard Biesheuvel <ard.biesheuvel@linaro.org>
> Cc: Cecil Sheng <cecil.sheng@hpe.com>
> Cc: Chao Zhang <chao.b.zhang@intel.com>
> Cc: Dandan Bi <dandan.bi@intel.com>
> Cc: Daryl McDaniel <edk2-lists@mc2research.org>
> Cc: David Wei <david.wei@intel.com>
> Cc: Eric Dong <eric.dong@intel.com>
> Cc: Feng Tian <feng.tian@intel.com>
> Cc: Gary Lin <glin@suse.com>
> Cc: Jaben Carsey <jaben.carsey@intel.com>
> Cc: Jeff Fan <jeff.fan@intel.com>
> Cc: Jiaxin Wu <jiaxin.wu@intel.com>
> Cc: Jordan Justen <jordan.l.justen@intel.com>
> Cc: Liming Gao <liming.gao@intel.com>
> Cc: Michael D Kinney <michael.d.kinney@intel.com>
> Cc: Ruiyu Ni <ruiyu.ni@intel.com>
> Cc: Siyuan Fu <siyuan.fu@intel.com>
> Cc: Star Zeng <star.zeng@intel.com>
> Cc: Tim He <tim.he@intel.com>
> 
> Thanks
> Laszlo
> 
> Laszlo Ersek (47):
>   MdeModulePkg/RegularExpressionDxe: guard the definition of ARRAY_SIZE
>   NetworkPkg/IpsecConfig: guard the definition of ARRAY_SIZE
>   OvmfPkg/PlatformBootManagerLib: guard the definition of ARRAY_SIZE
>   OvmfPkg/XenBusDxe: guard the definition of ARRAY_SIZE
>   MdePkg/Include/Base.h: introduce the ARRAY_SIZE() function-like macro
>   MdeModulePkg/RegularExpressionDxe: remove module-local ARRAY_SIZE
>     macro
>   NetworkPkg/IpsecConfig: remove module-local ARRAY_SIZE macro
>   OvmfPkg/PlatformBootManagerLib: remove module-local ARRAY_SIZE macro
>   OvmfPkg/XenBusDxe: remove module-local ARRAY_SIZE macro
>   ArmVirtPkg/NorFlashQemuLib: rebase to ARRAY_SIZE()

Maybe "Make use of" or something like that might be preferable to
"rebase to", but it is not a big deal.

I think I also saw some 'after' lines longer than 80 columns, but sed
can only invoke a limited level of magic after all. :) I think you
fixed *many* overly long lines in this series. Thanks for that as
well! :)

Series Reviewed-by: Jordan Justen <jordan.l.justen@intel.com>

>   DuetPkg/DuetBdsLib: rebase to ARRAY_SIZE()
>   EdkCompatibilityPkg/FrameworkHiiOnUefiHiiThunk: rebase to ARRAY_SIZE()
>   EdkCompatibilityPkg/Sample/Tools: rebase to ARRAY_SIZE()
>   FatPkg/EnhancedFatDxe: rebase to ARRAY_SIZE()
>   IntelFrameworkModulePkg/LegacyBootManagerLib: rebase to ARRAY_SIZE()
>   IntelFrameworkModulePkg/BdsDxe: rebase to ARRAY_SIZE()
>   MdeModulePkg/MemoryProfileInfo: rebase to ARRAY_SIZE()
>   MdeModulePkg/PciBusDxe: rebase to ARRAY_SIZE()
>   MdeModulePkg/PciHostBridgeDxe: rebase to ARRAY_SIZE()
>   MdeModulePkg/UsbBusDxe: rebase to ARRAY_SIZE()
>   MdeModulePkg/Core/Dxe: rebase to ARRAY_SIZE()
>   MdeModulePkg/Core/PiSmmCore: rebase to ARRAY_SIZE()
>   MdeModulePkg/BootMaintenanceManagerUiLib: rebase to ARRAY_SIZE()
>   MdeModulePkg/BootManagerUiLib: rebase to ARRAY_SIZE()
>   MdeModulePkg/UefiBootManagerLib: rebase to ARRAY_SIZE()
>   MdeModulePkg/VarCheckHiiLib: rebase to ARRAY_SIZE()
>   MdeModulePkg/Logo: rebase to ARRAY_SIZE()
>   MdeModulePkg/BdsDxe: rebase to ARRAY_SIZE()
>   MdeModulePkg/DisplayEngineDxe: rebase to ARRAY_SIZE()
>   MdeModulePkg/EbcDxe: rebase to ARRAY_SIZE()
>   MdeModulePkg/Tcp4Dxe: rebase to ARRAY_SIZE()
>   MdeModulePkg/Variable/RuntimeDxe: rebase to ARRAY_SIZE()
>   NetworkPkg/IScsiDxe: rebase to ARRAY_SIZE()
>   NetworkPkg/TcpDxe: rebase to ARRAY_SIZE()
>   Nt32Pkg/WinNtSerialIoDxe: rebase to ARRAY_SIZE()
>   OptionRomPkg/AtapiPassThruDxe: rebase to ARRAY_SIZE()
>   OvmfPkg/QemuBootOrderLib: rebase to ARRAY_SIZE()
>   OvmfPkg/QemuVideoDxe: rebase to ARRAY_SIZE()
>   PerformancePkg/Dp_App: rebase to ARRAY_SIZE()
>   SecurityPkg/AuthVariableLib: rebase to ARRAY_SIZE()
>   ShellPkg/UefiDpLib: rebase to ARRAY_SIZE()
>   ShellPkg/UefiShellLevel2CommandsLib: rebase to ARRAY_SIZE()
>   Vlv2TbltDevicePkg/FirmwareUpdate: rebase to ARRAY_SIZE()
>   Vlv2TbltDevicePkg/PlatformInitPei: rebase to ARRAY_SIZE()
>   Vlv2TbltDevicePkg/PlatformPei: rebase to ARRAY_SIZE()
>   Vlv2TbltDevicePkg/PlatformSetupDxe: rebase to ARRAY_SIZE()
>   Vlv2TbltDevicePkg/SmBiosMiscDxe: rebase to ARRAY_SIZE()
> 
>  ArmVirtPkg/Library/NorFlashQemuLib/NorFlashQemuLib.c                          |  2 +-
>  DuetPkg/Library/DuetBdsLib/BdsPlatform.c                                      |  2 +-
>  EdkCompatibilityPkg/Compatibility/FrameworkHiiOnUefiHiiThunk/OpcodeCreation.c |  2 +-
>  EdkCompatibilityPkg/Sample/Tools/Source/EfiRom/EfiRom.c                       |  4 ++--
>  EdkCompatibilityPkg/Sample/Tools/Source/HiiPack/IfrParse.c                    |  2 +-
>  FatPkg/EnhancedFatDxe/DirectoryManage.c                                       |  4 ++--
>  FatPkg/EnhancedFatDxe/FileName.c                                              |  4 ++--
>  FatPkg/EnhancedFatDxe/Hash.c                                                  |  4 ++--
>  IntelFrameworkModulePkg/Library/LegacyBootManagerLib/LegacyBm.c               |  2 +-
>  IntelFrameworkModulePkg/Universal/BdsDxe/BdsEntry.c                           |  2 +-
>  IntelFrameworkModulePkg/Universal/BdsDxe/BootMaint/BBSsupport.c               |  4 ++--
>  IntelFrameworkModulePkg/Universal/BdsDxe/BootMaint/BootMaint.c                |  8 ++++----
>  IntelFrameworkModulePkg/Universal/BdsDxe/BootMaint/BootOption.c               |  2 +-
>  IntelFrameworkModulePkg/Universal/BdsDxe/BootMaint/ConsoleOption.c            |  6 +++---
>  IntelFrameworkModulePkg/Universal/BdsDxe/BootMaint/UpdatePage.c               | 10 +++++-----
>  IntelFrameworkModulePkg/Universal/BdsDxe/BootMaint/Variable.c                 |  2 +-
>  IntelFrameworkModulePkg/Universal/BdsDxe/BootMngr/BootManager.c               |  2 +-
>  MdeModulePkg/Application/MemoryProfileInfo/MemoryProfileInfo.c                |  6 +++---
>  MdeModulePkg/Bus/Pci/PciBusDxe/PciLib.c                                       |  2 +-
>  MdeModulePkg/Bus/Pci/PciHostBridgeDxe/PciHostBridge.c                         |  2 +-
>  MdeModulePkg/Bus/Usb/UsbBusDxe/UsbHub.c                                       |  4 ++--
>  MdeModulePkg/Core/Dxe/Mem/Pool.c                                              |  2 +-
>  MdeModulePkg/Core/PiSmmCore/Pool.c                                            |  2 +-
>  MdeModulePkg/Core/PiSmmCore/SmramProfileRecord.c                              |  6 +++---
>  MdeModulePkg/Library/BootMaintenanceManagerUiLib/BootMaintenance.c            |  8 ++++----
>  MdeModulePkg/Library/BootMaintenanceManagerUiLib/ConsoleOption.c              |  8 ++++----
>  MdeModulePkg/Library/BootMaintenanceManagerUiLib/UpdatePage.c                 | 12 ++++++------
>  MdeModulePkg/Library/BootMaintenanceManagerUiLib/Variable.c                   |  2 +-
>  MdeModulePkg/Library/BootManagerUiLib/BootManager.c                           |  6 +++---
>  MdeModulePkg/Library/UefiBootManagerLib/BmBootDescription.c                   |  2 +-
>  MdeModulePkg/Library/UefiBootManagerLib/BmConsole.c                           |  2 +-
>  MdeModulePkg/Library/UefiBootManagerLib/BmHotkey.c                            |  2 +-
>  MdeModulePkg/Library/UefiBootManagerLib/BmLoadOption.c                        |  4 ++--
>  MdeModulePkg/Library/VarCheckHiiLib/VarCheckHiiGen.c                          |  4 ++--
>  MdeModulePkg/Library/VarCheckHiiLib/VarCheckHiiLibNullClass.c                 |  2 +-
>  MdeModulePkg/Logo/Logo.c                                                      |  2 +-
>  MdeModulePkg/Universal/BdsDxe/BdsEntry.c                                      |  2 +-
>  MdeModulePkg/Universal/DisplayEngineDxe/FormDisplay.c                         |  4 ++--
>  MdeModulePkg/Universal/DisplayEngineDxe/InputHandler.c                        |  6 +++---
>  MdeModulePkg/Universal/EbcDxe/EbcExecute.c                                    |  2 +-
>  MdeModulePkg/Universal/Network/Tcp4Dxe/Tcp4Output.c                           |  2 +-
>  MdeModulePkg/Universal/RegularExpressionDxe/RegularExpressionDxe.h            |  2 --
>  MdeModulePkg/Universal/Variable/RuntimeDxe/Variable.c                         |  2 +-
>  MdePkg/Include/Base.h                                                         | 13 +++++++++++++
>  NetworkPkg/Application/IpsecConfig/IpSecConfig.h                              |  2 --
>  NetworkPkg/IScsiDxe/IScsiConfig.c                                             |  4 ++--
>  NetworkPkg/IScsiDxe/IScsiDriver.c                                             |  2 +-
>  NetworkPkg/IScsiDxe/IScsiMisc.c                                               |  6 +++---
>  NetworkPkg/TcpDxe/TcpOutput.c                                                 |  2 +-
>  Nt32Pkg/WinNtSerialIoDxe/WinNtSerialIo.c                                      |  2 +-
>  OptionRomPkg/AtapiPassThruDxe/AtapiPassThru.c                                 |  4 ++--
>  OvmfPkg/Library/PlatformBootManagerLib/BdsPlatform.c                          |  5 -----
>  OvmfPkg/Library/QemuBootOrderLib/QemuBootOrderLib.c                           | 12 ++++++------
>  OvmfPkg/QemuVideoDxe/Initialize.c                                             |  4 ++--
>  OvmfPkg/XenBusDxe/XenStore.c                                                  |  1 -
>  PerformancePkg/Dp_App/Dp.c                                                    |  2 +-
>  PerformancePkg/Dp_App/DpTrace.c                                               | 10 +++++-----
>  SecurityPkg/Library/AuthVariableLib/AuthVariableLib.c                         |  4 ++--
>  ShellPkg/Library/UefiDpLib/DpTrace.c                                          | 10 +++++-----
>  ShellPkg/Library/UefiShellLevel2CommandsLib/TimeDate.c                        |  2 +-
>  Vlv2TbltDevicePkg/Application/FirmwareUpdate/FirmwareUpdate.c                 |  2 +-
>  Vlv2TbltDevicePkg/PlatformInitPei/FlashMap.c                                  |  2 +-
>  Vlv2TbltDevicePkg/PlatformPei/BootMode.c                                      |  6 +++---
>  Vlv2TbltDevicePkg/PlatformSetupDxe/SetupInfoRecords.c                         |  2 +-
>  Vlv2TbltDevicePkg/SmBiosMiscDxe/MiscOemType0x94Function.c                     |  2 +-
>  65 files changed, 131 insertions(+), 128 deletions(-)
> 
> -- 
> 2.9.2
> 


^ permalink raw reply	[flat|nested] 98+ messages in thread

* Re: [PATCH 43/47] Vlv2TbltDevicePkg/FirmwareUpdate: rebase to ARRAY_SIZE()
  2016-10-26 19:05 ` [PATCH 43/47] Vlv2TbltDevicePkg/FirmwareUpdate: " Laszlo Ersek
@ 2016-10-27  7:08   ` Guo, Mang
  0 siblings, 0 replies; 98+ messages in thread
From: Guo, Mang @ 2016-10-27  7:08 UTC (permalink / raw)
  To: Laszlo Ersek, edk2-devel-01; +Cc: Tim He, Wei, David

Reviewed-by: Guo, Mang <mang.guo@intel.com>.


-----Original Message-----
From: edk2-devel [mailto:edk2-devel-bounces@lists.01.org] On Behalf Of Laszlo Ersek
Sent: Thursday, October 27, 2016 3:05 AM
To: edk2-devel-01
Cc: Tim He; Wei, David
Subject: [edk2] [PATCH 43/47] Vlv2TbltDevicePkg/FirmwareUpdate: rebase to ARRAY_SIZE()

Cc: David Wei <david.wei@intel.com>
Cc: Tim He <tim.he@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Laszlo Ersek <lersek@redhat.com>
---
 Vlv2TbltDevicePkg/Application/FirmwareUpdate/FirmwareUpdate.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/Vlv2TbltDevicePkg/Application/FirmwareUpdate/FirmwareUpdate.c b/Vlv2TbltDevicePkg/Application/FirmwareUpdate/FirmwareUpdate.c
index 16629bf93bf3..8e44224e6779 100644
--- a/Vlv2TbltDevicePkg/Application/FirmwareUpdate/FirmwareUpdate.c
+++ b/Vlv2TbltDevicePkg/Application/FirmwareUpdate/FirmwareUpdate.c
@@ -34,7 +34,7 @@ FV_REGION_INFO mRegionInfo[] = {
   {FixedPcdGet32 (PcdBiosRomBase), FixedPcdGet32 (PcdBiosRomSize), TRUE}  };
 
-UINTN mRegionInfoCount = sizeof (mRegionInfo) / sizeof (mRegionInfo[0]);
+UINTN mRegionInfoCount = ARRAY_SIZE (mRegionInfo);
 
 FV_INPUT_DATA mInputData = {0};
 
--
2.9.2


_______________________________________________
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


^ permalink raw reply related	[flat|nested] 98+ messages in thread

* Re: [PATCH 44/47] Vlv2TbltDevicePkg/PlatformInitPei: rebase to ARRAY_SIZE()
  2016-10-26 19:05 ` [PATCH 44/47] Vlv2TbltDevicePkg/PlatformInitPei: " Laszlo Ersek
@ 2016-10-27  7:10   ` Guo, Mang
  0 siblings, 0 replies; 98+ messages in thread
From: Guo, Mang @ 2016-10-27  7:10 UTC (permalink / raw)
  To: Laszlo Ersek, edk2-devel-01

Reviewed-by: Guo, Mang <mang.guo@intel.com>.


-----Original Message-----
From: edk2-devel [mailto:edk2-devel-bounces@lists.01.org] On Behalf Of Laszlo Ersek
Sent: Thursday, October 27, 2016 3:05 AM
To: edk2-devel-01
Subject: [edk2] [PATCH 44/47] Vlv2TbltDevicePkg/PlatformInitPei: rebase to ARRAY_SIZE()

M: David Wei <david.wei@intel.com>
M: Tim He <tim.he@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Laszlo Ersek <lersek@redhat.com>
---
 Vlv2TbltDevicePkg/PlatformInitPei/FlashMap.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/Vlv2TbltDevicePkg/PlatformInitPei/FlashMap.c b/Vlv2TbltDevicePkg/PlatformInitPei/FlashMap.c
index 282faa85ffb6..54ad42bb27a0 100644
--- a/Vlv2TbltDevicePkg/PlatformInitPei/FlashMap.c
+++ b/Vlv2TbltDevicePkg/PlatformInitPei/FlashMap.c
@@ -72,7 +72,7 @@ static EFI_FLASH_AREA_DATA          mFlashAreaData[]  = {
 
 };
 
-#define NUM_FLASH_AREA_DATA (sizeof (mFlashAreaData) / sizeof (mFlashAreaData[0]))
+#define NUM_FLASH_AREA_DATA (ARRAY_SIZE (mFlashAreaData))
 
 /**
   Build GUID HOBs for platform specific flash map.
-- 
2.9.2


_______________________________________________
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


^ permalink raw reply related	[flat|nested] 98+ messages in thread

* Re: [PATCH 45/47] Vlv2TbltDevicePkg/PlatformPei: rebase to ARRAY_SIZE()
  2016-10-26 19:05 ` [PATCH 45/47] Vlv2TbltDevicePkg/PlatformPei: " Laszlo Ersek
@ 2016-10-27  7:12   ` Guo, Mang
  0 siblings, 0 replies; 98+ messages in thread
From: Guo, Mang @ 2016-10-27  7:12 UTC (permalink / raw)
  To: Laszlo Ersek, edk2-devel-01; +Cc: Tim He, Wei, David

Reviewed-by: Guo, Mang <mang.guo@intel.com>.

-----Original Message-----
From: edk2-devel [mailto:edk2-devel-bounces@lists.01.org] On Behalf Of Laszlo Ersek
Sent: Thursday, October 27, 2016 3:05 AM
To: edk2-devel-01
Cc: Tim He; Wei, David
Subject: [edk2] [PATCH 45/47] Vlv2TbltDevicePkg/PlatformPei: rebase to ARRAY_SIZE()

Cc: David Wei <david.wei@intel.com>
Cc: Tim He <tim.he@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Laszlo Ersek <lersek@redhat.com>
---
 Vlv2TbltDevicePkg/PlatformPei/BootMode.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/Vlv2TbltDevicePkg/PlatformPei/BootMode.c b/Vlv2TbltDevicePkg/PlatformPei/BootMode.c
index 4d933a09db0e..95be1c0f2851 100644
--- a/Vlv2TbltDevicePkg/PlatformPei/BootMode.c
+++ b/Vlv2TbltDevicePkg/PlatformPei/BootMode.c
@@ -372,13 +372,13 @@ PrioritizeBootMode (
   // Find the position of the current boot mode in our priority array
   //
   for ( CurrentIndex = 0;
-        CurrentIndex < sizeof (mBootModePriority) / sizeof (mBootModePriority[0]);
+        CurrentIndex < ARRAY_SIZE (mBootModePriority);
         CurrentIndex++) {
     if (mBootModePriority[CurrentIndex] == *CurrentBootMode) {
       break;
     }
   }
-  if (CurrentIndex >= sizeof (mBootModePriority) / sizeof (mBootModePriority[0])) {
+  if (CurrentIndex >= ARRAY_SIZE (mBootModePriority)) {
     return EFI_NOT_FOUND;
   }
 
@@ -386,7 +386,7 @@ PrioritizeBootMode (
   // Find the position of the new boot mode in our priority array
   //
   for ( NewIndex = 0;
-        NewIndex < sizeof (mBootModePriority) / sizeof (mBootModePriority[0]);
+        NewIndex < ARRAY_SIZE (mBootModePriority);
         NewIndex++) {
     if (mBootModePriority[NewIndex] == NewBootMode) {
       //
-- 
2.9.2


_______________________________________________
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


^ permalink raw reply related	[flat|nested] 98+ messages in thread

* Re: [PATCH 46/47] Vlv2TbltDevicePkg/PlatformSetupDxe: rebase to ARRAY_SIZE()
  2016-10-26 19:05 ` [PATCH 46/47] Vlv2TbltDevicePkg/PlatformSetupDxe: " Laszlo Ersek
@ 2016-10-27  7:14   ` Guo, Mang
  0 siblings, 0 replies; 98+ messages in thread
From: Guo, Mang @ 2016-10-27  7:14 UTC (permalink / raw)
  To: Laszlo Ersek, edk2-devel-01; +Cc: Tim He, Wei, David

Reviewed-by: Guo, Mang <mang.guo@intel.com>.

-----Original Message-----
From: edk2-devel [mailto:edk2-devel-bounces@lists.01.org] On Behalf Of Laszlo Ersek
Sent: Thursday, October 27, 2016 3:05 AM
To: edk2-devel-01
Cc: Tim He; Wei, David
Subject: [edk2] [PATCH 46/47] Vlv2TbltDevicePkg/PlatformSetupDxe: rebase to ARRAY_SIZE()

Cc: David Wei <david.wei@intel.com>
Cc: Tim He <tim.he@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Laszlo Ersek <lersek@redhat.com>
---
 Vlv2TbltDevicePkg/PlatformSetupDxe/SetupInfoRecords.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/Vlv2TbltDevicePkg/PlatformSetupDxe/SetupInfoRecords.c b/Vlv2TbltDevicePkg/PlatformSetupDxe/SetupInfoRecords.c
index 3cdb0132cd04..b0e29f02d067 100644
--- a/Vlv2TbltDevicePkg/PlatformSetupDxe/SetupInfoRecords.c
+++ b/Vlv2TbltDevicePkg/PlatformSetupDxe/SetupInfoRecords.c
@@ -1371,7 +1371,7 @@ UpdatePlatformInformation (
                             );
 
          Data8 = MmioRead8 (PciD31F0RegBase + R_PCH_LPC_RID_CC);
-         count = sizeof (SBRevisionTable) / sizeof (SBRevisionTable[0]);
+         count = ARRAY_SIZE (SBRevisionTable);
          for (Index = 0; Index < count; Index++) {
            if(Data8 == SBRevisionTable[Index].RevId) {
               UnicodeSPrint (Buffer, sizeof (Buffer), L"%02x %a", Data8, SBRevisionTable[Index].String);
-- 
2.9.2


_______________________________________________
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


^ permalink raw reply related	[flat|nested] 98+ messages in thread

* Re: [PATCH 47/47] Vlv2TbltDevicePkg/SmBiosMiscDxe: rebase to ARRAY_SIZE()
  2016-10-26 19:05 ` [PATCH 47/47] Vlv2TbltDevicePkg/SmBiosMiscDxe: " Laszlo Ersek
@ 2016-10-27  7:14   ` Guo, Mang
  0 siblings, 0 replies; 98+ messages in thread
From: Guo, Mang @ 2016-10-27  7:14 UTC (permalink / raw)
  To: Laszlo Ersek, edk2-devel-01; +Cc: Tim He, Wei, David

Reviewed-by: Guo, Mang <mang.guo@intel.com>.

-----Original Message-----
From: edk2-devel [mailto:edk2-devel-bounces@lists.01.org] On Behalf Of Laszlo Ersek
Sent: Thursday, October 27, 2016 3:05 AM
To: edk2-devel-01
Cc: Tim He; Wei, David
Subject: [edk2] [PATCH 47/47] Vlv2TbltDevicePkg/SmBiosMiscDxe: rebase to ARRAY_SIZE()

Cc: David Wei <david.wei@intel.com>
Cc: Tim He <tim.he@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Laszlo Ersek <lersek@redhat.com>
---
 Vlv2TbltDevicePkg/SmBiosMiscDxe/MiscOemType0x94Function.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/Vlv2TbltDevicePkg/SmBiosMiscDxe/MiscOemType0x94Function.c b/Vlv2TbltDevicePkg/SmBiosMiscDxe/MiscOemType0x94Function.c
index 898fc7cf0db3..657d19a6e757 100644
--- a/Vlv2TbltDevicePkg/SmBiosMiscDxe/MiscOemType0x94Function.c
+++ b/Vlv2TbltDevicePkg/SmBiosMiscDxe/MiscOemType0x94Function.c
@@ -691,7 +691,7 @@ UpdatePlatformInformation (
                             );
 
          Data8 = MmioRead8 (PciD31F0RegBase + R_PCH_LPC_RID_CC);
-         count = sizeof (SBRevisionTable) / sizeof (SBRevisionTable[0]);
+         count = ARRAY_SIZE (SBRevisionTable);
          for (Index = 0; Index < count; Index++) {
            if(Data8 == SBRevisionTable[Index].RevId) {
               UnicodeSPrint (Buffer, sizeof (Buffer), L"%02x %a", Data8, SBRevisionTable[Index].String);
-- 
2.9.2

_______________________________________________
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


^ permalink raw reply related	[flat|nested] 98+ messages in thread

* Re: [PATCH 10/47] ArmVirtPkg/NorFlashQemuLib: rebase to ARRAY_SIZE()
  2016-10-26 19:04 ` [PATCH 10/47] ArmVirtPkg/NorFlashQemuLib: rebase to ARRAY_SIZE() Laszlo Ersek
@ 2016-10-27  7:30   ` Ard Biesheuvel
  0 siblings, 0 replies; 98+ messages in thread
From: Ard Biesheuvel @ 2016-10-27  7:30 UTC (permalink / raw)
  To: Laszlo Ersek; +Cc: edk2-devel-01

On 26 October 2016 at 20:04, Laszlo Ersek <lersek@redhat.com> wrote:
> Cc: Ard Biesheuvel <ard.biesheuvel@linaro.org>
> Contributed-under: TianoCore Contribution Agreement 1.0
> Signed-off-by: Laszlo Ersek <lersek@redhat.com>

Reviewed-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>

> ---
>  ArmVirtPkg/Library/NorFlashQemuLib/NorFlashQemuLib.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/ArmVirtPkg/Library/NorFlashQemuLib/NorFlashQemuLib.c b/ArmVirtPkg/Library/NorFlashQemuLib/NorFlashQemuLib.c
> index 7f346077e6b5..d63a2d989f69 100644
> --- a/ArmVirtPkg/Library/NorFlashQemuLib/NorFlashQemuLib.c
> +++ b/ArmVirtPkg/Library/NorFlashQemuLib/NorFlashQemuLib.c
> @@ -46,6 +46,6 @@ NorFlashPlatformGetDevices (
>    )
>  {
>    *NorFlashDescriptions = mNorFlashDevices;
> -  *Count = sizeof (mNorFlashDevices) / sizeof (mNorFlashDevices[0]);
> +  *Count = ARRAY_SIZE (mNorFlashDevices);
>    return EFI_SUCCESS;
>  }
> --
> 2.9.2
>
>


^ permalink raw reply	[flat|nested] 98+ messages in thread

* Re: [PATCH 00/47] edk2: centralize and adopt ARRAY_SIZE()
  2016-10-27  4:43 ` Gary Lin
@ 2016-10-27  7:52   ` Laszlo Ersek
  0 siblings, 0 replies; 98+ messages in thread
From: Laszlo Ersek @ 2016-10-27  7:52 UTC (permalink / raw)
  To: Gary Lin
  Cc: edk2-devel-01, Ruiyu Ni, Tim He, Feng Tian, Michael D Kinney,
	Eric Dong, Cecil Sheng, Ard Biesheuvel, Jordan Justen, Liming Gao,
	Dandan Bi, Jiaxin Wu, Star Zeng, Daryl McDaniel, Jaben Carsey,
	Siyuan Fu, Jeff Fan, Chao Zhang, David Wei

On 10/27/16 06:43, Gary Lin wrote:
> On Wed, Oct 26, 2016 at 09:04:17PM +0200, Laszlo Ersek wrote:
>> I'm sure most of us have wished at some point that ARRAY_SIZE()
>> had existed in a central header file, like it does in many other
>> open source projects. This series implements that.
>>
>> Patches 01-04 round up the modules that #define ARRAY_SIZE() just
>> for themselves, and wrap their definitions in #ifndef ARRAY_SIZE.
>>
>> Patch 05 defines ARRAY_SIZE() in "MdePkg/Include/Base.h". This
>> flips the previously modified modules to MdePkg's macro definition.
>>
>> Patches 06-09 modify the same set of modules as patches 01-04 do; this
>> time the (now unused) module-local ARRAY_SIZE() macro definitions are
>> eliminated.
>>
>> The rest of the patches (10-47) migrate the edk2 tree to ARRAY_SIZE(),
>> covering the most obvious open-coded ARRAY_SIZE() expressions. These
>> expressions were located and converted with the following shell
>> pipeline:
>>
>>   git ls-files \
>>   | xargs --no-run-if-empty -- \
>>       sed --regexp-extended --in-place \
>>         --expression='s,sizeof \(([a-zA-Z0-9_]+)\) / sizeof \((\*\1|\1\[0\])\),ARRAY_SIZE (\1),g' \
>>         --
> Hi Laszlo,
> 
> I found several missing cases in OvmfPkg:
> 
> Library/PciHostBridgeLib/PciHostBridgeLib.c:
> 
> 421:      ASSERT (Descriptor->ResType <
> 422:              (sizeof (mPciHostBridgeLibAcpiAddressSpaceTypeStr) /
> 423:               sizeof (mPciHostBridgeLibAcpiAddressSpaceTypeStr[0])
> 424:              )
> 425:             );

Well, this is a multi-line one; it's no surprise the SED regexp didn't
match. I only meant the SED command to convert the most obvious,
clear-cut cases.

You would be very much welcome to submit patches that manually convert
(some of) the remaining instances, after I commit this series :)

> 
> --
> VirtioGpuDxe/Gop.c:
> 
> 207:  if (ModeNumber >= sizeof mGopResolutions / sizeof mGopResolutions[0]) {
> 
> 
> 242:  if (ModeNumber >= sizeof mGopResolutions / sizeof mGopResolutions[0]) {

Yes, these didn't match because I only use parentheses in the operand of
the sizeof operator when it is required by the C language standard.
(I.e., for type names.) When writing the SED regexp, I focused on the
pattern (with the technically superfluous parens) that pretty much every
other developer prefers.

> 261:    VgpuGop->GopMode.MaxMode         = (UINT32)(sizeof mGopResolutions /
> 262:                                                sizeof mGopResolutions[0]);
> 

Multi-line :)

> --
> Library/LoadLinuxLib/Linux.c:
> 
> 360:  if (E820EntryCount >= (sizeof (Bp->e820_map) / sizeof (Bp->e820_map[0]))) {
> 

This didn't match because the parenthesized operand is not a simple
identifier, it uses the -> operator inside.

> --
> Csm/CsmSupportLib/LegacyRegion.c:
> 
> 133:  for (Index = 0; Index < (sizeof(mSectionArray) / sizeof (mSectionArray[0])); Index++) {
> 
> 139:  ASSERT (Index < (sizeof(mSectionArray) / sizeof (mSectionArray[0])));
> 
> 144:  for (Index = StartIndex; Index < (sizeof(mSectionArray) / sizeof (mSectionArray[0])); Index++) {
> 
> 180:  ASSERT (Index < (sizeof(mSectionArray) / sizeof (mSectionArray[0])));

These didn't match because there is no space character between the first
"sizeof" operator and its operand.

Converting these would be very valuable, but I didn't want to un-focus
my series with manual conversions. Can you please submit a patch for
these instances (one per module) after I commit this series?

Thank you!
Laszlo

> 
> 
> Cheers,
> 
> Gary Lin
> 
>>
>> This pipeline lists all tracked files with "git". The pathnames are then
>> composed with "xargs" into maximal length "sed" command lines, and those
>> "sed" commands are run.
>>
>> Here the "sed" stream editor filters and modifies all the listed files
>> in place. The extended regular expression replaces the following two
>> patterns:
>>
>>   sizeof (ArrayName) / sizeof (*ArrayName)
>>   sizeof (ArrayName) / sizeof (ArrayName[0])
>>
>> with
>>
>>   ARRAY_SIZE (ArrayName)
>>
>> The regexp uses a backreference in the match, ensuring that the sizeof
>> operator in the dividend and the sizeof operator in the divisor both
>> refer to the same ArrayName. If there are multiple occurrences on the
>> same line, the sed command replaces all of them.
>>
>> I collected the changes into patches manually, and I reviewed them all.
>>
>> I test-built all of the modified packages, repeating the command
>>
>>   build -a X64 -t GCC48 -b DEBUG -p FooPkg/FooPkg.dsc
>>
>> as many times as necessary. Two packages were impossible to build like
>> this: Nt32Pkg and Vlv2TbltDevicePkg, so I couldn't build-test them.
>>
>> I did some light-weight testing with OVMF: boot with Secure Boot
>> enabled, S3 suspend/resume with and without SMM. I also booted
>> ArmVirtQemu once.
>>
>> Repository: https://github.com/lersek/edk2.git
>> Branch:     array_size
>>
>> Cc: Ard Biesheuvel <ard.biesheuvel@linaro.org>
>> Cc: Cecil Sheng <cecil.sheng@hpe.com>
>> Cc: Chao Zhang <chao.b.zhang@intel.com>
>> Cc: Dandan Bi <dandan.bi@intel.com>
>> Cc: Daryl McDaniel <edk2-lists@mc2research.org>
>> Cc: David Wei <david.wei@intel.com>
>> Cc: Eric Dong <eric.dong@intel.com>
>> Cc: Feng Tian <feng.tian@intel.com>
>> Cc: Gary Lin <glin@suse.com>
>> Cc: Jaben Carsey <jaben.carsey@intel.com>
>> Cc: Jeff Fan <jeff.fan@intel.com>
>> Cc: Jiaxin Wu <jiaxin.wu@intel.com>
>> Cc: Jordan Justen <jordan.l.justen@intel.com>
>> Cc: Liming Gao <liming.gao@intel.com>
>> Cc: Michael D Kinney <michael.d.kinney@intel.com>
>> Cc: Ruiyu Ni <ruiyu.ni@intel.com>
>> Cc: Siyuan Fu <siyuan.fu@intel.com>
>> Cc: Star Zeng <star.zeng@intel.com>
>> Cc: Tim He <tim.he@intel.com>
>>
>> Thanks
>> Laszlo
>>
>> Laszlo Ersek (47):
>>   MdeModulePkg/RegularExpressionDxe: guard the definition of ARRAY_SIZE
>>   NetworkPkg/IpsecConfig: guard the definition of ARRAY_SIZE
>>   OvmfPkg/PlatformBootManagerLib: guard the definition of ARRAY_SIZE
>>   OvmfPkg/XenBusDxe: guard the definition of ARRAY_SIZE
>>   MdePkg/Include/Base.h: introduce the ARRAY_SIZE() function-like macro
>>   MdeModulePkg/RegularExpressionDxe: remove module-local ARRAY_SIZE
>>     macro
>>   NetworkPkg/IpsecConfig: remove module-local ARRAY_SIZE macro
>>   OvmfPkg/PlatformBootManagerLib: remove module-local ARRAY_SIZE macro
>>   OvmfPkg/XenBusDxe: remove module-local ARRAY_SIZE macro
>>   ArmVirtPkg/NorFlashQemuLib: rebase to ARRAY_SIZE()
>>   DuetPkg/DuetBdsLib: rebase to ARRAY_SIZE()
>>   EdkCompatibilityPkg/FrameworkHiiOnUefiHiiThunk: rebase to ARRAY_SIZE()
>>   EdkCompatibilityPkg/Sample/Tools: rebase to ARRAY_SIZE()
>>   FatPkg/EnhancedFatDxe: rebase to ARRAY_SIZE()
>>   IntelFrameworkModulePkg/LegacyBootManagerLib: rebase to ARRAY_SIZE()
>>   IntelFrameworkModulePkg/BdsDxe: rebase to ARRAY_SIZE()
>>   MdeModulePkg/MemoryProfileInfo: rebase to ARRAY_SIZE()
>>   MdeModulePkg/PciBusDxe: rebase to ARRAY_SIZE()
>>   MdeModulePkg/PciHostBridgeDxe: rebase to ARRAY_SIZE()
>>   MdeModulePkg/UsbBusDxe: rebase to ARRAY_SIZE()
>>   MdeModulePkg/Core/Dxe: rebase to ARRAY_SIZE()
>>   MdeModulePkg/Core/PiSmmCore: rebase to ARRAY_SIZE()
>>   MdeModulePkg/BootMaintenanceManagerUiLib: rebase to ARRAY_SIZE()
>>   MdeModulePkg/BootManagerUiLib: rebase to ARRAY_SIZE()
>>   MdeModulePkg/UefiBootManagerLib: rebase to ARRAY_SIZE()
>>   MdeModulePkg/VarCheckHiiLib: rebase to ARRAY_SIZE()
>>   MdeModulePkg/Logo: rebase to ARRAY_SIZE()
>>   MdeModulePkg/BdsDxe: rebase to ARRAY_SIZE()
>>   MdeModulePkg/DisplayEngineDxe: rebase to ARRAY_SIZE()
>>   MdeModulePkg/EbcDxe: rebase to ARRAY_SIZE()
>>   MdeModulePkg/Tcp4Dxe: rebase to ARRAY_SIZE()
>>   MdeModulePkg/Variable/RuntimeDxe: rebase to ARRAY_SIZE()
>>   NetworkPkg/IScsiDxe: rebase to ARRAY_SIZE()
>>   NetworkPkg/TcpDxe: rebase to ARRAY_SIZE()
>>   Nt32Pkg/WinNtSerialIoDxe: rebase to ARRAY_SIZE()
>>   OptionRomPkg/AtapiPassThruDxe: rebase to ARRAY_SIZE()
>>   OvmfPkg/QemuBootOrderLib: rebase to ARRAY_SIZE()
>>   OvmfPkg/QemuVideoDxe: rebase to ARRAY_SIZE()
>>   PerformancePkg/Dp_App: rebase to ARRAY_SIZE()
>>   SecurityPkg/AuthVariableLib: rebase to ARRAY_SIZE()
>>   ShellPkg/UefiDpLib: rebase to ARRAY_SIZE()
>>   ShellPkg/UefiShellLevel2CommandsLib: rebase to ARRAY_SIZE()
>>   Vlv2TbltDevicePkg/FirmwareUpdate: rebase to ARRAY_SIZE()
>>   Vlv2TbltDevicePkg/PlatformInitPei: rebase to ARRAY_SIZE()
>>   Vlv2TbltDevicePkg/PlatformPei: rebase to ARRAY_SIZE()
>>   Vlv2TbltDevicePkg/PlatformSetupDxe: rebase to ARRAY_SIZE()
>>   Vlv2TbltDevicePkg/SmBiosMiscDxe: rebase to ARRAY_SIZE()
>>
>>  ArmVirtPkg/Library/NorFlashQemuLib/NorFlashQemuLib.c                          |  2 +-
>>  DuetPkg/Library/DuetBdsLib/BdsPlatform.c                                      |  2 +-
>>  EdkCompatibilityPkg/Compatibility/FrameworkHiiOnUefiHiiThunk/OpcodeCreation.c |  2 +-
>>  EdkCompatibilityPkg/Sample/Tools/Source/EfiRom/EfiRom.c                       |  4 ++--
>>  EdkCompatibilityPkg/Sample/Tools/Source/HiiPack/IfrParse.c                    |  2 +-
>>  FatPkg/EnhancedFatDxe/DirectoryManage.c                                       |  4 ++--
>>  FatPkg/EnhancedFatDxe/FileName.c                                              |  4 ++--
>>  FatPkg/EnhancedFatDxe/Hash.c                                                  |  4 ++--
>>  IntelFrameworkModulePkg/Library/LegacyBootManagerLib/LegacyBm.c               |  2 +-
>>  IntelFrameworkModulePkg/Universal/BdsDxe/BdsEntry.c                           |  2 +-
>>  IntelFrameworkModulePkg/Universal/BdsDxe/BootMaint/BBSsupport.c               |  4 ++--
>>  IntelFrameworkModulePkg/Universal/BdsDxe/BootMaint/BootMaint.c                |  8 ++++----
>>  IntelFrameworkModulePkg/Universal/BdsDxe/BootMaint/BootOption.c               |  2 +-
>>  IntelFrameworkModulePkg/Universal/BdsDxe/BootMaint/ConsoleOption.c            |  6 +++---
>>  IntelFrameworkModulePkg/Universal/BdsDxe/BootMaint/UpdatePage.c               | 10 +++++-----
>>  IntelFrameworkModulePkg/Universal/BdsDxe/BootMaint/Variable.c                 |  2 +-
>>  IntelFrameworkModulePkg/Universal/BdsDxe/BootMngr/BootManager.c               |  2 +-
>>  MdeModulePkg/Application/MemoryProfileInfo/MemoryProfileInfo.c                |  6 +++---
>>  MdeModulePkg/Bus/Pci/PciBusDxe/PciLib.c                                       |  2 +-
>>  MdeModulePkg/Bus/Pci/PciHostBridgeDxe/PciHostBridge.c                         |  2 +-
>>  MdeModulePkg/Bus/Usb/UsbBusDxe/UsbHub.c                                       |  4 ++--
>>  MdeModulePkg/Core/Dxe/Mem/Pool.c                                              |  2 +-
>>  MdeModulePkg/Core/PiSmmCore/Pool.c                                            |  2 +-
>>  MdeModulePkg/Core/PiSmmCore/SmramProfileRecord.c                              |  6 +++---
>>  MdeModulePkg/Library/BootMaintenanceManagerUiLib/BootMaintenance.c            |  8 ++++----
>>  MdeModulePkg/Library/BootMaintenanceManagerUiLib/ConsoleOption.c              |  8 ++++----
>>  MdeModulePkg/Library/BootMaintenanceManagerUiLib/UpdatePage.c                 | 12 ++++++------
>>  MdeModulePkg/Library/BootMaintenanceManagerUiLib/Variable.c                   |  2 +-
>>  MdeModulePkg/Library/BootManagerUiLib/BootManager.c                           |  6 +++---
>>  MdeModulePkg/Library/UefiBootManagerLib/BmBootDescription.c                   |  2 +-
>>  MdeModulePkg/Library/UefiBootManagerLib/BmConsole.c                           |  2 +-
>>  MdeModulePkg/Library/UefiBootManagerLib/BmHotkey.c                            |  2 +-
>>  MdeModulePkg/Library/UefiBootManagerLib/BmLoadOption.c                        |  4 ++--
>>  MdeModulePkg/Library/VarCheckHiiLib/VarCheckHiiGen.c                          |  4 ++--
>>  MdeModulePkg/Library/VarCheckHiiLib/VarCheckHiiLibNullClass.c                 |  2 +-
>>  MdeModulePkg/Logo/Logo.c                                                      |  2 +-
>>  MdeModulePkg/Universal/BdsDxe/BdsEntry.c                                      |  2 +-
>>  MdeModulePkg/Universal/DisplayEngineDxe/FormDisplay.c                         |  4 ++--
>>  MdeModulePkg/Universal/DisplayEngineDxe/InputHandler.c                        |  6 +++---
>>  MdeModulePkg/Universal/EbcDxe/EbcExecute.c                                    |  2 +-
>>  MdeModulePkg/Universal/Network/Tcp4Dxe/Tcp4Output.c                           |  2 +-
>>  MdeModulePkg/Universal/RegularExpressionDxe/RegularExpressionDxe.h            |  2 --
>>  MdeModulePkg/Universal/Variable/RuntimeDxe/Variable.c                         |  2 +-
>>  MdePkg/Include/Base.h                                                         | 13 +++++++++++++
>>  NetworkPkg/Application/IpsecConfig/IpSecConfig.h                              |  2 --
>>  NetworkPkg/IScsiDxe/IScsiConfig.c                                             |  4 ++--
>>  NetworkPkg/IScsiDxe/IScsiDriver.c                                             |  2 +-
>>  NetworkPkg/IScsiDxe/IScsiMisc.c                                               |  6 +++---
>>  NetworkPkg/TcpDxe/TcpOutput.c                                                 |  2 +-
>>  Nt32Pkg/WinNtSerialIoDxe/WinNtSerialIo.c                                      |  2 +-
>>  OptionRomPkg/AtapiPassThruDxe/AtapiPassThru.c                                 |  4 ++--
>>  OvmfPkg/Library/PlatformBootManagerLib/BdsPlatform.c                          |  5 -----
>>  OvmfPkg/Library/QemuBootOrderLib/QemuBootOrderLib.c                           | 12 ++++++------
>>  OvmfPkg/QemuVideoDxe/Initialize.c                                             |  4 ++--
>>  OvmfPkg/XenBusDxe/XenStore.c                                                  |  1 -
>>  PerformancePkg/Dp_App/Dp.c                                                    |  2 +-
>>  PerformancePkg/Dp_App/DpTrace.c                                               | 10 +++++-----
>>  SecurityPkg/Library/AuthVariableLib/AuthVariableLib.c                         |  4 ++--
>>  ShellPkg/Library/UefiDpLib/DpTrace.c                                          | 10 +++++-----
>>  ShellPkg/Library/UefiShellLevel2CommandsLib/TimeDate.c                        |  2 +-
>>  Vlv2TbltDevicePkg/Application/FirmwareUpdate/FirmwareUpdate.c                 |  2 +-
>>  Vlv2TbltDevicePkg/PlatformInitPei/FlashMap.c                                  |  2 +-
>>  Vlv2TbltDevicePkg/PlatformPei/BootMode.c                                      |  6 +++---
>>  Vlv2TbltDevicePkg/PlatformSetupDxe/SetupInfoRecords.c                         |  2 +-
>>  Vlv2TbltDevicePkg/SmBiosMiscDxe/MiscOemType0x94Function.c                     |  2 +-
>>  65 files changed, 131 insertions(+), 128 deletions(-)
>>
>> -- 
>> 2.9.2
>>
>> _______________________________________________
>> edk2-devel mailing list
>> edk2-devel@lists.01.org
>> https://lists.01.org/mailman/listinfo/edk2-devel
>>



^ permalink raw reply	[flat|nested] 98+ messages in thread

* Re: [PATCH 11/47] DuetPkg/DuetBdsLib: rebase to ARRAY_SIZE()
  2016-10-26 19:04 ` [PATCH 11/47] DuetPkg/DuetBdsLib: " Laszlo Ersek
@ 2016-10-27  8:16   ` Laszlo Ersek
  2016-10-27  9:04     ` Ni, Ruiyu
  0 siblings, 1 reply; 98+ messages in thread
From: Laszlo Ersek @ 2016-10-27  8:16 UTC (permalink / raw)
  To: edk2-devel-01, Ruiyu Ni

Ray,

On 10/26/16 21:04, Laszlo Ersek wrote:
> Contributed-under: TianoCore Contribution Agreement 1.0
> Signed-off-by: Laszlo Ersek <lersek@redhat.com>
> ---
>  DuetPkg/Library/DuetBdsLib/BdsPlatform.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/DuetPkg/Library/DuetBdsLib/BdsPlatform.c b/DuetPkg/Library/DuetBdsLib/BdsPlatform.c
> index 1875dc963680..a4b2aa947322 100644
> --- a/DuetPkg/Library/DuetBdsLib/BdsPlatform.c
> +++ b/DuetPkg/Library/DuetBdsLib/BdsPlatform.c
> @@ -64,7 +64,7 @@ Returns:
>    //
>    // Iteratively add ACPI Table, SMBIOS Table, MPS Table to EFI System Table
>    //
> -  for (Index = 0; Index < sizeof (gTableGuidArray) / sizeof (*gTableGuidArray); ++Index) {
> +  for (Index = 0; Index < ARRAY_SIZE (gTableGuidArray); ++Index) {
>      GuidHob.Raw = GetNextGuidHob (gTableGuidArray[Index], HobStart.Raw);
>      if (GuidHob.Raw != NULL) {
>        Table = GET_GUID_HOB_DATA (GuidHob.Guid);
> 

I'm very sorry, I forgot to CC you on this patch originally. Can you
please review it?

Thank you!
Laszlo


^ permalink raw reply	[flat|nested] 98+ messages in thread

* Re: [PATCH 00/47] edk2: centralize and adopt ARRAY_SIZE()
  2016-10-27  6:05 ` Jordan Justen
@ 2016-10-27  8:49   ` Laszlo Ersek
  0 siblings, 0 replies; 98+ messages in thread
From: Laszlo Ersek @ 2016-10-27  8:49 UTC (permalink / raw)
  To: Jordan Justen, edk2-devel-01
  Cc: Ruiyu Ni, Tim He, Feng Tian, Michael D Kinney, Eric Dong,
	Cecil Sheng, Ard Biesheuvel, Liming Gao, Dandan Bi, Jiaxin Wu,
	Gary Lin, Star Zeng, Daryl McDaniel, Jaben Carsey, Siyuan Fu,
	Jeff Fan, Chao Zhang, David Wei

On 10/27/16 08:05, Jordan Justen wrote:
> On 2016-10-26 12:04:17, Laszlo Ersek wrote:
>> I'm sure most of us have wished at some point that ARRAY_SIZE()
>> had existed in a central header file, like it does in many other
>> open source projects.
> 
> Indeed!
> 
>> This series implements that.
>>
>> Patches 01-04 round up the modules that #define ARRAY_SIZE() just
>> for themselves, and wrap their definitions in #ifndef ARRAY_SIZE.
>>
>> Patch 05 defines ARRAY_SIZE() in "MdePkg/Include/Base.h". This
>> flips the previously modified modules to MdePkg's macro definition.
>>
>> Patches 06-09 modify the same set of modules as patches 01-04 do; this
>> time the (now unused) module-local ARRAY_SIZE() macro definitions are
>> eliminated.
>>
>> The rest of the patches (10-47) migrate the edk2 tree to ARRAY_SIZE(),
>> covering the most obvious open-coded ARRAY_SIZE() expressions. These
>> expressions were located and converted with the following shell
>> pipeline:
>>
>>   git ls-files \
>>   | xargs --no-run-if-empty -- \
>>       sed --regexp-extended --in-place \
>>         --expression='s,sizeof \(([a-zA-Z0-9_]+)\) / sizeof \((\*\1|\1\[0\])\),ARRAY_SIZE (\1),g' \
>>         --
>>
>> This pipeline lists all tracked files with "git". The pathnames are then
>> composed with "xargs" into maximal length "sed" command lines, and those
>> "sed" commands are run.
>>
>> Here the "sed" stream editor filters and modifies all the listed files
>> in place. The extended regular expression replaces the following two
>> patterns:
>>
>>   sizeof (ArrayName) / sizeof (*ArrayName)
>>   sizeof (ArrayName) / sizeof (ArrayName[0])
>>
>> with
>>
>>   ARRAY_SIZE (ArrayName)
>>
>> The regexp uses a backreference in the match, ensuring that the sizeof
>> operator in the dividend and the sizeof operator in the divisor both
>> refer to the same ArrayName. If there are multiple occurrences on the
>> same line, the sed command replaces all of them.
>>
>> I collected the changes into patches manually, and I reviewed them all.
>>
>> I test-built all of the modified packages, repeating the command
>>
>>   build -a X64 -t GCC48 -b DEBUG -p FooPkg/FooPkg.dsc
>>
>> as many times as necessary. Two packages were impossible to build like
>> this: Nt32Pkg and Vlv2TbltDevicePkg, so I couldn't build-test them.
>>
>> I did some light-weight testing with OVMF: boot with Secure Boot
>> enabled, S3 suspend/resume with and without SMM. I also booted
>> ArmVirtQemu once.
>>
>> Repository: https://github.com/lersek/edk2.git
>> Branch:     array_size
>>
>> Cc: Ard Biesheuvel <ard.biesheuvel@linaro.org>
>> Cc: Cecil Sheng <cecil.sheng@hpe.com>
>> Cc: Chao Zhang <chao.b.zhang@intel.com>
>> Cc: Dandan Bi <dandan.bi@intel.com>
>> Cc: Daryl McDaniel <edk2-lists@mc2research.org>
>> Cc: David Wei <david.wei@intel.com>
>> Cc: Eric Dong <eric.dong@intel.com>
>> Cc: Feng Tian <feng.tian@intel.com>
>> Cc: Gary Lin <glin@suse.com>
>> Cc: Jaben Carsey <jaben.carsey@intel.com>
>> Cc: Jeff Fan <jeff.fan@intel.com>
>> Cc: Jiaxin Wu <jiaxin.wu@intel.com>
>> Cc: Jordan Justen <jordan.l.justen@intel.com>
>> Cc: Liming Gao <liming.gao@intel.com>
>> Cc: Michael D Kinney <michael.d.kinney@intel.com>
>> Cc: Ruiyu Ni <ruiyu.ni@intel.com>
>> Cc: Siyuan Fu <siyuan.fu@intel.com>
>> Cc: Star Zeng <star.zeng@intel.com>
>> Cc: Tim He <tim.he@intel.com>
>>
>> Thanks
>> Laszlo
>>
>> Laszlo Ersek (47):
>>   MdeModulePkg/RegularExpressionDxe: guard the definition of ARRAY_SIZE
>>   NetworkPkg/IpsecConfig: guard the definition of ARRAY_SIZE
>>   OvmfPkg/PlatformBootManagerLib: guard the definition of ARRAY_SIZE
>>   OvmfPkg/XenBusDxe: guard the definition of ARRAY_SIZE
>>   MdePkg/Include/Base.h: introduce the ARRAY_SIZE() function-like macro
>>   MdeModulePkg/RegularExpressionDxe: remove module-local ARRAY_SIZE
>>     macro
>>   NetworkPkg/IpsecConfig: remove module-local ARRAY_SIZE macro
>>   OvmfPkg/PlatformBootManagerLib: remove module-local ARRAY_SIZE macro
>>   OvmfPkg/XenBusDxe: remove module-local ARRAY_SIZE macro
>>   ArmVirtPkg/NorFlashQemuLib: rebase to ARRAY_SIZE()
> 
> Maybe "Make use of" or something like that might be preferable to
> "rebase to", but it is not a big deal.

Yes, "utilize" and "adopt" crossed my mind at some point, but then I had
been quite into the middle of the series. Oh well. :)

> 
> I think I also saw some 'after' lines longer than 80 columns, but sed
> can only invoke a limited level of magic after all. :) I think you
> fixed *many* overly long lines in this series. Thanks for that as
> well! :)

Right, I was happy to see that as well. The shortening seemed especially
useful for:
- the new safe string functions, where ARRAY_SIZE() got applied to a
CHAR16 array,
- controlling expressions of "if" and "for" statements,
- assertions.

I saw that some lines remained that were still too long, but one wants
to get only so clever in a SED regexp, like you say :)

> Series Reviewed-by: Jordan Justen <jordan.l.justen@intel.com>

Thank you!
Laszlo

> 
>>   DuetPkg/DuetBdsLib: rebase to ARRAY_SIZE()
>>   EdkCompatibilityPkg/FrameworkHiiOnUefiHiiThunk: rebase to ARRAY_SIZE()
>>   EdkCompatibilityPkg/Sample/Tools: rebase to ARRAY_SIZE()
>>   FatPkg/EnhancedFatDxe: rebase to ARRAY_SIZE()
>>   IntelFrameworkModulePkg/LegacyBootManagerLib: rebase to ARRAY_SIZE()
>>   IntelFrameworkModulePkg/BdsDxe: rebase to ARRAY_SIZE()
>>   MdeModulePkg/MemoryProfileInfo: rebase to ARRAY_SIZE()
>>   MdeModulePkg/PciBusDxe: rebase to ARRAY_SIZE()
>>   MdeModulePkg/PciHostBridgeDxe: rebase to ARRAY_SIZE()
>>   MdeModulePkg/UsbBusDxe: rebase to ARRAY_SIZE()
>>   MdeModulePkg/Core/Dxe: rebase to ARRAY_SIZE()
>>   MdeModulePkg/Core/PiSmmCore: rebase to ARRAY_SIZE()
>>   MdeModulePkg/BootMaintenanceManagerUiLib: rebase to ARRAY_SIZE()
>>   MdeModulePkg/BootManagerUiLib: rebase to ARRAY_SIZE()
>>   MdeModulePkg/UefiBootManagerLib: rebase to ARRAY_SIZE()
>>   MdeModulePkg/VarCheckHiiLib: rebase to ARRAY_SIZE()
>>   MdeModulePkg/Logo: rebase to ARRAY_SIZE()
>>   MdeModulePkg/BdsDxe: rebase to ARRAY_SIZE()
>>   MdeModulePkg/DisplayEngineDxe: rebase to ARRAY_SIZE()
>>   MdeModulePkg/EbcDxe: rebase to ARRAY_SIZE()
>>   MdeModulePkg/Tcp4Dxe: rebase to ARRAY_SIZE()
>>   MdeModulePkg/Variable/RuntimeDxe: rebase to ARRAY_SIZE()
>>   NetworkPkg/IScsiDxe: rebase to ARRAY_SIZE()
>>   NetworkPkg/TcpDxe: rebase to ARRAY_SIZE()
>>   Nt32Pkg/WinNtSerialIoDxe: rebase to ARRAY_SIZE()
>>   OptionRomPkg/AtapiPassThruDxe: rebase to ARRAY_SIZE()
>>   OvmfPkg/QemuBootOrderLib: rebase to ARRAY_SIZE()
>>   OvmfPkg/QemuVideoDxe: rebase to ARRAY_SIZE()
>>   PerformancePkg/Dp_App: rebase to ARRAY_SIZE()
>>   SecurityPkg/AuthVariableLib: rebase to ARRAY_SIZE()
>>   ShellPkg/UefiDpLib: rebase to ARRAY_SIZE()
>>   ShellPkg/UefiShellLevel2CommandsLib: rebase to ARRAY_SIZE()
>>   Vlv2TbltDevicePkg/FirmwareUpdate: rebase to ARRAY_SIZE()
>>   Vlv2TbltDevicePkg/PlatformInitPei: rebase to ARRAY_SIZE()
>>   Vlv2TbltDevicePkg/PlatformPei: rebase to ARRAY_SIZE()
>>   Vlv2TbltDevicePkg/PlatformSetupDxe: rebase to ARRAY_SIZE()
>>   Vlv2TbltDevicePkg/SmBiosMiscDxe: rebase to ARRAY_SIZE()
>>
>>  ArmVirtPkg/Library/NorFlashQemuLib/NorFlashQemuLib.c                          |  2 +-
>>  DuetPkg/Library/DuetBdsLib/BdsPlatform.c                                      |  2 +-
>>  EdkCompatibilityPkg/Compatibility/FrameworkHiiOnUefiHiiThunk/OpcodeCreation.c |  2 +-
>>  EdkCompatibilityPkg/Sample/Tools/Source/EfiRom/EfiRom.c                       |  4 ++--
>>  EdkCompatibilityPkg/Sample/Tools/Source/HiiPack/IfrParse.c                    |  2 +-
>>  FatPkg/EnhancedFatDxe/DirectoryManage.c                                       |  4 ++--
>>  FatPkg/EnhancedFatDxe/FileName.c                                              |  4 ++--
>>  FatPkg/EnhancedFatDxe/Hash.c                                                  |  4 ++--
>>  IntelFrameworkModulePkg/Library/LegacyBootManagerLib/LegacyBm.c               |  2 +-
>>  IntelFrameworkModulePkg/Universal/BdsDxe/BdsEntry.c                           |  2 +-
>>  IntelFrameworkModulePkg/Universal/BdsDxe/BootMaint/BBSsupport.c               |  4 ++--
>>  IntelFrameworkModulePkg/Universal/BdsDxe/BootMaint/BootMaint.c                |  8 ++++----
>>  IntelFrameworkModulePkg/Universal/BdsDxe/BootMaint/BootOption.c               |  2 +-
>>  IntelFrameworkModulePkg/Universal/BdsDxe/BootMaint/ConsoleOption.c            |  6 +++---
>>  IntelFrameworkModulePkg/Universal/BdsDxe/BootMaint/UpdatePage.c               | 10 +++++-----
>>  IntelFrameworkModulePkg/Universal/BdsDxe/BootMaint/Variable.c                 |  2 +-
>>  IntelFrameworkModulePkg/Universal/BdsDxe/BootMngr/BootManager.c               |  2 +-
>>  MdeModulePkg/Application/MemoryProfileInfo/MemoryProfileInfo.c                |  6 +++---
>>  MdeModulePkg/Bus/Pci/PciBusDxe/PciLib.c                                       |  2 +-
>>  MdeModulePkg/Bus/Pci/PciHostBridgeDxe/PciHostBridge.c                         |  2 +-
>>  MdeModulePkg/Bus/Usb/UsbBusDxe/UsbHub.c                                       |  4 ++--
>>  MdeModulePkg/Core/Dxe/Mem/Pool.c                                              |  2 +-
>>  MdeModulePkg/Core/PiSmmCore/Pool.c                                            |  2 +-
>>  MdeModulePkg/Core/PiSmmCore/SmramProfileRecord.c                              |  6 +++---
>>  MdeModulePkg/Library/BootMaintenanceManagerUiLib/BootMaintenance.c            |  8 ++++----
>>  MdeModulePkg/Library/BootMaintenanceManagerUiLib/ConsoleOption.c              |  8 ++++----
>>  MdeModulePkg/Library/BootMaintenanceManagerUiLib/UpdatePage.c                 | 12 ++++++------
>>  MdeModulePkg/Library/BootMaintenanceManagerUiLib/Variable.c                   |  2 +-
>>  MdeModulePkg/Library/BootManagerUiLib/BootManager.c                           |  6 +++---
>>  MdeModulePkg/Library/UefiBootManagerLib/BmBootDescription.c                   |  2 +-
>>  MdeModulePkg/Library/UefiBootManagerLib/BmConsole.c                           |  2 +-
>>  MdeModulePkg/Library/UefiBootManagerLib/BmHotkey.c                            |  2 +-
>>  MdeModulePkg/Library/UefiBootManagerLib/BmLoadOption.c                        |  4 ++--
>>  MdeModulePkg/Library/VarCheckHiiLib/VarCheckHiiGen.c                          |  4 ++--
>>  MdeModulePkg/Library/VarCheckHiiLib/VarCheckHiiLibNullClass.c                 |  2 +-
>>  MdeModulePkg/Logo/Logo.c                                                      |  2 +-
>>  MdeModulePkg/Universal/BdsDxe/BdsEntry.c                                      |  2 +-
>>  MdeModulePkg/Universal/DisplayEngineDxe/FormDisplay.c                         |  4 ++--
>>  MdeModulePkg/Universal/DisplayEngineDxe/InputHandler.c                        |  6 +++---
>>  MdeModulePkg/Universal/EbcDxe/EbcExecute.c                                    |  2 +-
>>  MdeModulePkg/Universal/Network/Tcp4Dxe/Tcp4Output.c                           |  2 +-
>>  MdeModulePkg/Universal/RegularExpressionDxe/RegularExpressionDxe.h            |  2 --
>>  MdeModulePkg/Universal/Variable/RuntimeDxe/Variable.c                         |  2 +-
>>  MdePkg/Include/Base.h                                                         | 13 +++++++++++++
>>  NetworkPkg/Application/IpsecConfig/IpSecConfig.h                              |  2 --
>>  NetworkPkg/IScsiDxe/IScsiConfig.c                                             |  4 ++--
>>  NetworkPkg/IScsiDxe/IScsiDriver.c                                             |  2 +-
>>  NetworkPkg/IScsiDxe/IScsiMisc.c                                               |  6 +++---
>>  NetworkPkg/TcpDxe/TcpOutput.c                                                 |  2 +-
>>  Nt32Pkg/WinNtSerialIoDxe/WinNtSerialIo.c                                      |  2 +-
>>  OptionRomPkg/AtapiPassThruDxe/AtapiPassThru.c                                 |  4 ++--
>>  OvmfPkg/Library/PlatformBootManagerLib/BdsPlatform.c                          |  5 -----
>>  OvmfPkg/Library/QemuBootOrderLib/QemuBootOrderLib.c                           | 12 ++++++------
>>  OvmfPkg/QemuVideoDxe/Initialize.c                                             |  4 ++--
>>  OvmfPkg/XenBusDxe/XenStore.c                                                  |  1 -
>>  PerformancePkg/Dp_App/Dp.c                                                    |  2 +-
>>  PerformancePkg/Dp_App/DpTrace.c                                               | 10 +++++-----
>>  SecurityPkg/Library/AuthVariableLib/AuthVariableLib.c                         |  4 ++--
>>  ShellPkg/Library/UefiDpLib/DpTrace.c                                          | 10 +++++-----
>>  ShellPkg/Library/UefiShellLevel2CommandsLib/TimeDate.c                        |  2 +-
>>  Vlv2TbltDevicePkg/Application/FirmwareUpdate/FirmwareUpdate.c                 |  2 +-
>>  Vlv2TbltDevicePkg/PlatformInitPei/FlashMap.c                                  |  2 +-
>>  Vlv2TbltDevicePkg/PlatformPei/BootMode.c                                      |  6 +++---
>>  Vlv2TbltDevicePkg/PlatformSetupDxe/SetupInfoRecords.c                         |  2 +-
>>  Vlv2TbltDevicePkg/SmBiosMiscDxe/MiscOemType0x94Function.c                     |  2 +-
>>  65 files changed, 131 insertions(+), 128 deletions(-)
>>
>> -- 
>> 2.9.2
>>
> _______________________________________________
> edk2-devel mailing list
> edk2-devel@lists.01.org
> https://lists.01.org/mailman/listinfo/edk2-devel
> 



^ permalink raw reply	[flat|nested] 98+ messages in thread

* Re: [PATCH 11/47] DuetPkg/DuetBdsLib: rebase to ARRAY_SIZE()
  2016-10-27  8:16   ` Laszlo Ersek
@ 2016-10-27  9:04     ` Ni, Ruiyu
  2016-10-27  9:12       ` Laszlo Ersek
  0 siblings, 1 reply; 98+ messages in thread
From: Ni, Ruiyu @ 2016-10-27  9:04 UTC (permalink / raw)
  To: Laszlo Ersek, edk2-devel-01

Reviewed-by: Ruiyu Ni <ruiyu.ni@intel.com>

Regards,
Ray

From: edk2-devel [mailto:edk2-devel-bounces@lists.01.org] On Behalf Of Laszlo Ersek
Sent: Thursday, October 27, 2016 4:17 PM
To: edk2-devel-01 <edk2-devel@ml01.01.org>; Ni, Ruiyu <ruiyu.ni@intel.com>
Subject: Re: [edk2] [PATCH 11/47] DuetPkg/DuetBdsLib: rebase to ARRAY_SIZE()

Ray,

On 10/26/16 21:04, Laszlo Ersek wrote:
> Contributed-under: TianoCore Contribution Agreement 1.0
> Signed-off-by: Laszlo Ersek <lersek@redhat.com<mailto:lersek@redhat.com>>
> ---
>  DuetPkg/Library/DuetBdsLib/BdsPlatform.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/DuetPkg/Library/DuetBdsLib/BdsPlatform.c b/DuetPkg/Library/DuetBdsLib/BdsPlatform.c
> index 1875dc963680..a4b2aa947322 100644
> --- a/DuetPkg/Library/DuetBdsLib/BdsPlatform.c
> +++ b/DuetPkg/Library/DuetBdsLib/BdsPlatform.c
> @@ -64,7 +64,7 @@ Returns:
>    //
>    // Iteratively add ACPI Table, SMBIOS Table, MPS Table to EFI System Table
>    //
> -  for (Index = 0; Index < sizeof (gTableGuidArray) / sizeof (*gTableGuidArray); ++Index) {
> +  for (Index = 0; Index < ARRAY_SIZE (gTableGuidArray); ++Index) {
>      GuidHob.Raw = GetNextGuidHob (gTableGuidArray[Index], HobStart.Raw);
>      if (GuidHob.Raw != NULL) {
>        Table = GET_GUID_HOB_DATA (GuidHob.Guid);
>

I'm very sorry, I forgot to CC you on this patch originally. Can you
please review it?

Thank you!
Laszlo
_______________________________________________
edk2-devel mailing list
edk2-devel@lists.01.org<mailto:edk2-devel@lists.01.org>
https://lists.01.org/mailman/listinfo/edk2-devel


^ permalink raw reply	[flat|nested] 98+ messages in thread

* Re: [PATCH 40/47] SecurityPkg/AuthVariableLib: rebase to ARRAY_SIZE()
  2016-10-26 19:04 ` [PATCH 40/47] SecurityPkg/AuthVariableLib: " Laszlo Ersek
@ 2016-10-27  9:07   ` Laszlo Ersek
  2016-10-27  9:09     ` Zeng, Star
  2016-10-28  8:36     ` Zhang, Chao B
  0 siblings, 2 replies; 98+ messages in thread
From: Laszlo Ersek @ 2016-10-27  9:07 UTC (permalink / raw)
  To: Star Zeng, Chao Zhang; +Cc: edk2-devel-01

Star, Chao,

On 10/26/16 21:04, Laszlo Ersek wrote:
> Cc: Chao Zhang <chao.b.zhang@intel.com>
> Cc: Star Zeng <star.zeng@intel.com>
> Contributed-under: TianoCore Contribution Agreement 1.0
> Signed-off-by: Laszlo Ersek <lersek@redhat.com>
> ---
>  SecurityPkg/Library/AuthVariableLib/AuthVariableLib.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/SecurityPkg/Library/AuthVariableLib/AuthVariableLib.c b/SecurityPkg/Library/AuthVariableLib/AuthVariableLib.c
> index c4fbb649f1fd..792a1232aed9 100644
> --- a/SecurityPkg/Library/AuthVariableLib/AuthVariableLib.c
> +++ b/SecurityPkg/Library/AuthVariableLib/AuthVariableLib.c
> @@ -421,7 +421,7 @@ AuthVariableLibInitialize (
>    AuthVarLibContextOut->StructVersion = AUTH_VAR_LIB_CONTEXT_OUT_STRUCT_VERSION;
>    AuthVarLibContextOut->StructSize = sizeof (AUTH_VAR_LIB_CONTEXT_OUT);
>    AuthVarLibContextOut->AuthVarEntry = mAuthVarEntry;
> -  AuthVarLibContextOut->AuthVarEntryCount = sizeof (mAuthVarEntry) / sizeof (mAuthVarEntry[0]);
> +  AuthVarLibContextOut->AuthVarEntryCount = ARRAY_SIZE (mAuthVarEntry);
>    mAuthVarAddressPointer[0] = (VOID **) &mPubKeyStore;
>    mAuthVarAddressPointer[1] = (VOID **) &mCertDbStore;
>    mAuthVarAddressPointer[2] = (VOID **) &mHashCtx;
> @@ -433,7 +433,7 @@ AuthVariableLibInitialize (
>    mAuthVarAddressPointer[8] = (VOID **) &(mAuthVarLibContextIn->CheckRemainingSpaceForConsistency),
>    mAuthVarAddressPointer[9] = (VOID **) &(mAuthVarLibContextIn->AtRuntime),
>    AuthVarLibContextOut->AddressPointer = mAuthVarAddressPointer;
> -  AuthVarLibContextOut->AddressPointerCount = sizeof (mAuthVarAddressPointer) / sizeof (mAuthVarAddressPointer[0]);
> +  AuthVarLibContextOut->AddressPointerCount = ARRAY_SIZE (mAuthVarAddressPointer);
>  
>    return Status;
>  }
> 

can one of you guys please review this patch?

Thanks!
Laszlo


^ permalink raw reply	[flat|nested] 98+ messages in thread

* Re: [PATCH 40/47] SecurityPkg/AuthVariableLib: rebase to ARRAY_SIZE()
  2016-10-27  9:07   ` Laszlo Ersek
@ 2016-10-27  9:09     ` Zeng, Star
  2016-10-27  9:12       ` Laszlo Ersek
  2016-10-28  8:36     ` Zhang, Chao B
  1 sibling, 1 reply; 98+ messages in thread
From: Zeng, Star @ 2016-10-27  9:09 UTC (permalink / raw)
  To: Laszlo Ersek, Zhang, Chao B; +Cc: edk2-devel-01, Zeng, Star

Oh, it is Reviewed-by: Star Zeng <star.zeng@intel.com>. :)

Thanks,
Star
-----Original Message-----
From: edk2-devel [mailto:edk2-devel-bounces@lists.01.org] On Behalf Of Laszlo Ersek
Sent: Thursday, October 27, 2016 5:08 PM
To: Zeng, Star <star.zeng@intel.com>; Zhang, Chao B <chao.b.zhang@intel.com>
Cc: edk2-devel-01 <edk2-devel@ml01.01.org>
Subject: Re: [edk2] [PATCH 40/47] SecurityPkg/AuthVariableLib: rebase to ARRAY_SIZE()

Star, Chao,

On 10/26/16 21:04, Laszlo Ersek wrote:
> Cc: Chao Zhang <chao.b.zhang@intel.com>
> Cc: Star Zeng <star.zeng@intel.com>
> Contributed-under: TianoCore Contribution Agreement 1.0
> Signed-off-by: Laszlo Ersek <lersek@redhat.com>
> ---
>  SecurityPkg/Library/AuthVariableLib/AuthVariableLib.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/SecurityPkg/Library/AuthVariableLib/AuthVariableLib.c 
> b/SecurityPkg/Library/AuthVariableLib/AuthVariableLib.c
> index c4fbb649f1fd..792a1232aed9 100644
> --- a/SecurityPkg/Library/AuthVariableLib/AuthVariableLib.c
> +++ b/SecurityPkg/Library/AuthVariableLib/AuthVariableLib.c
> @@ -421,7 +421,7 @@ AuthVariableLibInitialize (
>    AuthVarLibContextOut->StructVersion = AUTH_VAR_LIB_CONTEXT_OUT_STRUCT_VERSION;
>    AuthVarLibContextOut->StructSize = sizeof (AUTH_VAR_LIB_CONTEXT_OUT);
>    AuthVarLibContextOut->AuthVarEntry = mAuthVarEntry;
> -  AuthVarLibContextOut->AuthVarEntryCount = sizeof (mAuthVarEntry) / 
> sizeof (mAuthVarEntry[0]);
> +  AuthVarLibContextOut->AuthVarEntryCount = ARRAY_SIZE 
> + (mAuthVarEntry);
>    mAuthVarAddressPointer[0] = (VOID **) &mPubKeyStore;
>    mAuthVarAddressPointer[1] = (VOID **) &mCertDbStore;
>    mAuthVarAddressPointer[2] = (VOID **) &mHashCtx; @@ -433,7 +433,7 
> @@ AuthVariableLibInitialize (
>    mAuthVarAddressPointer[8] = (VOID **) &(mAuthVarLibContextIn->CheckRemainingSpaceForConsistency),
>    mAuthVarAddressPointer[9] = (VOID **) &(mAuthVarLibContextIn->AtRuntime),
>    AuthVarLibContextOut->AddressPointer = mAuthVarAddressPointer;
> -  AuthVarLibContextOut->AddressPointerCount = sizeof 
> (mAuthVarAddressPointer) / sizeof (mAuthVarAddressPointer[0]);
> +  AuthVarLibContextOut->AddressPointerCount = ARRAY_SIZE 
> + (mAuthVarAddressPointer);
>  
>    return Status;
>  }
> 

can one of you guys please review this patch?

Thanks!
Laszlo
_______________________________________________
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


^ permalink raw reply	[flat|nested] 98+ messages in thread

* Re: [PATCH 11/47] DuetPkg/DuetBdsLib: rebase to ARRAY_SIZE()
  2016-10-27  9:04     ` Ni, Ruiyu
@ 2016-10-27  9:12       ` Laszlo Ersek
  0 siblings, 0 replies; 98+ messages in thread
From: Laszlo Ersek @ 2016-10-27  9:12 UTC (permalink / raw)
  To: Ni, Ruiyu, edk2-devel-01

On 10/27/16 11:04, Ni, Ruiyu wrote:
> Reviewed-by: Ruiyu Ni <ruiyu.ni@intel.com>

Thanks!
Laszlo

> Regards,
> Ray
> 
> From: edk2-devel [mailto:edk2-devel-bounces@lists.01.org] On Behalf Of Laszlo Ersek
> Sent: Thursday, October 27, 2016 4:17 PM
> To: edk2-devel-01 <edk2-devel@ml01.01.org>; Ni, Ruiyu <ruiyu.ni@intel.com>
> Subject: Re: [edk2] [PATCH 11/47] DuetPkg/DuetBdsLib: rebase to ARRAY_SIZE()
> 
> Ray,
> 
> On 10/26/16 21:04, Laszlo Ersek wrote:
>> Contributed-under: TianoCore Contribution Agreement 1.0
>> Signed-off-by: Laszlo Ersek <lersek@redhat.com<mailto:lersek@redhat.com>>
>> ---
>>  DuetPkg/Library/DuetBdsLib/BdsPlatform.c | 2 +-
>>  1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> diff --git a/DuetPkg/Library/DuetBdsLib/BdsPlatform.c b/DuetPkg/Library/DuetBdsLib/BdsPlatform.c
>> index 1875dc963680..a4b2aa947322 100644
>> --- a/DuetPkg/Library/DuetBdsLib/BdsPlatform.c
>> +++ b/DuetPkg/Library/DuetBdsLib/BdsPlatform.c
>> @@ -64,7 +64,7 @@ Returns:
>>    //
>>    // Iteratively add ACPI Table, SMBIOS Table, MPS Table to EFI System Table
>>    //
>> -  for (Index = 0; Index < sizeof (gTableGuidArray) / sizeof (*gTableGuidArray); ++Index) {
>> +  for (Index = 0; Index < ARRAY_SIZE (gTableGuidArray); ++Index) {
>>      GuidHob.Raw = GetNextGuidHob (gTableGuidArray[Index], HobStart.Raw);
>>      if (GuidHob.Raw != NULL) {
>>        Table = GET_GUID_HOB_DATA (GuidHob.Guid);
>>
> 
> I'm very sorry, I forgot to CC you on this patch originally. Can you
> please review it?
> 
> Thank you!
> Laszlo
> _______________________________________________
> edk2-devel mailing list
> edk2-devel@lists.01.org<mailto:edk2-devel@lists.01.org>
> https://lists.01.org/mailman/listinfo/edk2-devel
> _______________________________________________
> edk2-devel mailing list
> edk2-devel@lists.01.org
> https://lists.01.org/mailman/listinfo/edk2-devel
> 



^ permalink raw reply	[flat|nested] 98+ messages in thread

* Re: [PATCH 40/47] SecurityPkg/AuthVariableLib: rebase to ARRAY_SIZE()
  2016-10-27  9:09     ` Zeng, Star
@ 2016-10-27  9:12       ` Laszlo Ersek
  0 siblings, 0 replies; 98+ messages in thread
From: Laszlo Ersek @ 2016-10-27  9:12 UTC (permalink / raw)
  To: Zeng, Star, Zhang, Chao B; +Cc: edk2-devel-01

On 10/27/16 11:09, Zeng, Star wrote:
> Oh, it is Reviewed-by: Star Zeng <star.zeng@intel.com>. :)

Great, thanks!
Laszlo

> Thanks,
> Star
> -----Original Message-----
> From: edk2-devel [mailto:edk2-devel-bounces@lists.01.org] On Behalf Of Laszlo Ersek
> Sent: Thursday, October 27, 2016 5:08 PM
> To: Zeng, Star <star.zeng@intel.com>; Zhang, Chao B <chao.b.zhang@intel.com>
> Cc: edk2-devel-01 <edk2-devel@ml01.01.org>
> Subject: Re: [edk2] [PATCH 40/47] SecurityPkg/AuthVariableLib: rebase to ARRAY_SIZE()
> 
> Star, Chao,
> 
> On 10/26/16 21:04, Laszlo Ersek wrote:
>> Cc: Chao Zhang <chao.b.zhang@intel.com>
>> Cc: Star Zeng <star.zeng@intel.com>
>> Contributed-under: TianoCore Contribution Agreement 1.0
>> Signed-off-by: Laszlo Ersek <lersek@redhat.com>
>> ---
>>  SecurityPkg/Library/AuthVariableLib/AuthVariableLib.c | 4 ++--
>>  1 file changed, 2 insertions(+), 2 deletions(-)
>>
>> diff --git a/SecurityPkg/Library/AuthVariableLib/AuthVariableLib.c 
>> b/SecurityPkg/Library/AuthVariableLib/AuthVariableLib.c
>> index c4fbb649f1fd..792a1232aed9 100644
>> --- a/SecurityPkg/Library/AuthVariableLib/AuthVariableLib.c
>> +++ b/SecurityPkg/Library/AuthVariableLib/AuthVariableLib.c
>> @@ -421,7 +421,7 @@ AuthVariableLibInitialize (
>>    AuthVarLibContextOut->StructVersion = AUTH_VAR_LIB_CONTEXT_OUT_STRUCT_VERSION;
>>    AuthVarLibContextOut->StructSize = sizeof (AUTH_VAR_LIB_CONTEXT_OUT);
>>    AuthVarLibContextOut->AuthVarEntry = mAuthVarEntry;
>> -  AuthVarLibContextOut->AuthVarEntryCount = sizeof (mAuthVarEntry) / 
>> sizeof (mAuthVarEntry[0]);
>> +  AuthVarLibContextOut->AuthVarEntryCount = ARRAY_SIZE 
>> + (mAuthVarEntry);
>>    mAuthVarAddressPointer[0] = (VOID **) &mPubKeyStore;
>>    mAuthVarAddressPointer[1] = (VOID **) &mCertDbStore;
>>    mAuthVarAddressPointer[2] = (VOID **) &mHashCtx; @@ -433,7 +433,7 
>> @@ AuthVariableLibInitialize (
>>    mAuthVarAddressPointer[8] = (VOID **) &(mAuthVarLibContextIn->CheckRemainingSpaceForConsistency),
>>    mAuthVarAddressPointer[9] = (VOID **) &(mAuthVarLibContextIn->AtRuntime),
>>    AuthVarLibContextOut->AddressPointer = mAuthVarAddressPointer;
>> -  AuthVarLibContextOut->AddressPointerCount = sizeof 
>> (mAuthVarAddressPointer) / sizeof (mAuthVarAddressPointer[0]);
>> +  AuthVarLibContextOut->AddressPointerCount = ARRAY_SIZE 
>> + (mAuthVarAddressPointer);
>>  
>>    return Status;
>>  }
>>
> 
> can one of you guys please review this patch?
> 
> Thanks!
> Laszlo
> _______________________________________________
> edk2-devel mailing list
> edk2-devel@lists.01.org
> https://lists.01.org/mailman/listinfo/edk2-devel
> _______________________________________________
> edk2-devel mailing list
> edk2-devel@lists.01.org
> https://lists.01.org/mailman/listinfo/edk2-devel
> 



^ permalink raw reply	[flat|nested] 98+ messages in thread

* Re: [PATCH 00/47] edk2: centralize and adopt ARRAY_SIZE()
  2016-10-26 19:04 [PATCH 00/47] edk2: centralize and adopt ARRAY_SIZE() Laszlo Ersek
                   ` (50 preceding siblings ...)
  2016-10-27  6:05 ` Jordan Justen
@ 2016-10-27  9:27 ` Laszlo Ersek
  51 siblings, 0 replies; 98+ messages in thread
From: Laszlo Ersek @ 2016-10-27  9:27 UTC (permalink / raw)
  To: edk2-devel-01, Gary Lin
  Cc: Ruiyu Ni, Tim He, Feng Tian, Michael D Kinney, Eric Dong,
	Cecil Sheng, Ard Biesheuvel, Jordan Justen, Liming Gao, Dandan Bi,
	Jiaxin Wu, Star Zeng, Daryl McDaniel, Jaben Carsey, Siyuan Fu,
	Jeff Fan, Chao Zhang, David Wei

On 10/26/16 21:04, Laszlo Ersek wrote:
> I'm sure most of us have wished at some point that ARRAY_SIZE()
> had existed in a central header file, like it does in many other
> open source projects. This series implements that.
> 
> Patches 01-04 round up the modules that #define ARRAY_SIZE() just
> for themselves, and wrap their definitions in #ifndef ARRAY_SIZE.
> 
> Patch 05 defines ARRAY_SIZE() in "MdePkg/Include/Base.h". This
> flips the previously modified modules to MdePkg's macro definition.
> 
> Patches 06-09 modify the same set of modules as patches 01-04 do; this
> time the (now unused) module-local ARRAY_SIZE() macro definitions are
> eliminated.
> 
> The rest of the patches (10-47) migrate the edk2 tree to ARRAY_SIZE(),
> covering the most obvious open-coded ARRAY_SIZE() expressions. These
> expressions were located and converted with the following shell
> pipeline:
> 
>   git ls-files \
>   | xargs --no-run-if-empty -- \
>       sed --regexp-extended --in-place \
>         --expression='s,sizeof \(([a-zA-Z0-9_]+)\) / sizeof \((\*\1|\1\[0\])\),ARRAY_SIZE (\1),g' \
>         --
> 
> This pipeline lists all tracked files with "git". The pathnames are then
> composed with "xargs" into maximal length "sed" command lines, and those
> "sed" commands are run.
> 
> Here the "sed" stream editor filters and modifies all the listed files
> in place. The extended regular expression replaces the following two
> patterns:
> 
>   sizeof (ArrayName) / sizeof (*ArrayName)
>   sizeof (ArrayName) / sizeof (ArrayName[0])
> 
> with
> 
>   ARRAY_SIZE (ArrayName)
> 
> The regexp uses a backreference in the match, ensuring that the sizeof
> operator in the dividend and the sizeof operator in the divisor both
> refer to the same ArrayName. If there are multiple occurrences on the
> same line, the sed command replaces all of them.
> 
> I collected the changes into patches manually, and I reviewed them all.
> 
> I test-built all of the modified packages, repeating the command
> 
>   build -a X64 -t GCC48 -b DEBUG -p FooPkg/FooPkg.dsc
> 
> as many times as necessary. Two packages were impossible to build like
> this: Nt32Pkg and Vlv2TbltDevicePkg, so I couldn't build-test them.
> 
> I did some light-weight testing with OVMF: boot with Secure Boot
> enabled, S3 suspend/resume with and without SMM. I also booted
> ArmVirtQemu once.
> 
> Repository: https://github.com/lersek/edk2.git
> Branch:     array_size
> 
> Cc: Ard Biesheuvel <ard.biesheuvel@linaro.org>
> Cc: Cecil Sheng <cecil.sheng@hpe.com>
> Cc: Chao Zhang <chao.b.zhang@intel.com>
> Cc: Dandan Bi <dandan.bi@intel.com>
> Cc: Daryl McDaniel <edk2-lists@mc2research.org>
> Cc: David Wei <david.wei@intel.com>
> Cc: Eric Dong <eric.dong@intel.com>
> Cc: Feng Tian <feng.tian@intel.com>
> Cc: Gary Lin <glin@suse.com>
> Cc: Jaben Carsey <jaben.carsey@intel.com>
> Cc: Jeff Fan <jeff.fan@intel.com>
> Cc: Jiaxin Wu <jiaxin.wu@intel.com>
> Cc: Jordan Justen <jordan.l.justen@intel.com>
> Cc: Liming Gao <liming.gao@intel.com>
> Cc: Michael D Kinney <michael.d.kinney@intel.com>
> Cc: Ruiyu Ni <ruiyu.ni@intel.com>
> Cc: Siyuan Fu <siyuan.fu@intel.com>
> Cc: Star Zeng <star.zeng@intel.com>
> Cc: Tim He <tim.he@intel.com>
> 
> Thanks
> Laszlo
> 
> Laszlo Ersek (47):
>   MdeModulePkg/RegularExpressionDxe: guard the definition of ARRAY_SIZE
>   NetworkPkg/IpsecConfig: guard the definition of ARRAY_SIZE
>   OvmfPkg/PlatformBootManagerLib: guard the definition of ARRAY_SIZE
>   OvmfPkg/XenBusDxe: guard the definition of ARRAY_SIZE
>   MdePkg/Include/Base.h: introduce the ARRAY_SIZE() function-like macro
>   MdeModulePkg/RegularExpressionDxe: remove module-local ARRAY_SIZE
>     macro
>   NetworkPkg/IpsecConfig: remove module-local ARRAY_SIZE macro
>   OvmfPkg/PlatformBootManagerLib: remove module-local ARRAY_SIZE macro
>   OvmfPkg/XenBusDxe: remove module-local ARRAY_SIZE macro
>   ArmVirtPkg/NorFlashQemuLib: rebase to ARRAY_SIZE()
>   DuetPkg/DuetBdsLib: rebase to ARRAY_SIZE()
>   EdkCompatibilityPkg/FrameworkHiiOnUefiHiiThunk: rebase to ARRAY_SIZE()
>   EdkCompatibilityPkg/Sample/Tools: rebase to ARRAY_SIZE()
>   FatPkg/EnhancedFatDxe: rebase to ARRAY_SIZE()
>   IntelFrameworkModulePkg/LegacyBootManagerLib: rebase to ARRAY_SIZE()
>   IntelFrameworkModulePkg/BdsDxe: rebase to ARRAY_SIZE()
>   MdeModulePkg/MemoryProfileInfo: rebase to ARRAY_SIZE()
>   MdeModulePkg/PciBusDxe: rebase to ARRAY_SIZE()
>   MdeModulePkg/PciHostBridgeDxe: rebase to ARRAY_SIZE()
>   MdeModulePkg/UsbBusDxe: rebase to ARRAY_SIZE()
>   MdeModulePkg/Core/Dxe: rebase to ARRAY_SIZE()
>   MdeModulePkg/Core/PiSmmCore: rebase to ARRAY_SIZE()
>   MdeModulePkg/BootMaintenanceManagerUiLib: rebase to ARRAY_SIZE()
>   MdeModulePkg/BootManagerUiLib: rebase to ARRAY_SIZE()
>   MdeModulePkg/UefiBootManagerLib: rebase to ARRAY_SIZE()
>   MdeModulePkg/VarCheckHiiLib: rebase to ARRAY_SIZE()
>   MdeModulePkg/Logo: rebase to ARRAY_SIZE()
>   MdeModulePkg/BdsDxe: rebase to ARRAY_SIZE()
>   MdeModulePkg/DisplayEngineDxe: rebase to ARRAY_SIZE()
>   MdeModulePkg/EbcDxe: rebase to ARRAY_SIZE()
>   MdeModulePkg/Tcp4Dxe: rebase to ARRAY_SIZE()
>   MdeModulePkg/Variable/RuntimeDxe: rebase to ARRAY_SIZE()
>   NetworkPkg/IScsiDxe: rebase to ARRAY_SIZE()
>   NetworkPkg/TcpDxe: rebase to ARRAY_SIZE()
>   Nt32Pkg/WinNtSerialIoDxe: rebase to ARRAY_SIZE()
>   OptionRomPkg/AtapiPassThruDxe: rebase to ARRAY_SIZE()
>   OvmfPkg/QemuBootOrderLib: rebase to ARRAY_SIZE()
>   OvmfPkg/QemuVideoDxe: rebase to ARRAY_SIZE()
>   PerformancePkg/Dp_App: rebase to ARRAY_SIZE()
>   SecurityPkg/AuthVariableLib: rebase to ARRAY_SIZE()
>   ShellPkg/UefiDpLib: rebase to ARRAY_SIZE()
>   ShellPkg/UefiShellLevel2CommandsLib: rebase to ARRAY_SIZE()
>   Vlv2TbltDevicePkg/FirmwareUpdate: rebase to ARRAY_SIZE()
>   Vlv2TbltDevicePkg/PlatformInitPei: rebase to ARRAY_SIZE()
>   Vlv2TbltDevicePkg/PlatformPei: rebase to ARRAY_SIZE()
>   Vlv2TbltDevicePkg/PlatformSetupDxe: rebase to ARRAY_SIZE()
>   Vlv2TbltDevicePkg/SmBiosMiscDxe: rebase to ARRAY_SIZE()
> 
>  ArmVirtPkg/Library/NorFlashQemuLib/NorFlashQemuLib.c                          |  2 +-
>  DuetPkg/Library/DuetBdsLib/BdsPlatform.c                                      |  2 +-
>  EdkCompatibilityPkg/Compatibility/FrameworkHiiOnUefiHiiThunk/OpcodeCreation.c |  2 +-
>  EdkCompatibilityPkg/Sample/Tools/Source/EfiRom/EfiRom.c                       |  4 ++--
>  EdkCompatibilityPkg/Sample/Tools/Source/HiiPack/IfrParse.c                    |  2 +-
>  FatPkg/EnhancedFatDxe/DirectoryManage.c                                       |  4 ++--
>  FatPkg/EnhancedFatDxe/FileName.c                                              |  4 ++--
>  FatPkg/EnhancedFatDxe/Hash.c                                                  |  4 ++--
>  IntelFrameworkModulePkg/Library/LegacyBootManagerLib/LegacyBm.c               |  2 +-
>  IntelFrameworkModulePkg/Universal/BdsDxe/BdsEntry.c                           |  2 +-
>  IntelFrameworkModulePkg/Universal/BdsDxe/BootMaint/BBSsupport.c               |  4 ++--
>  IntelFrameworkModulePkg/Universal/BdsDxe/BootMaint/BootMaint.c                |  8 ++++----
>  IntelFrameworkModulePkg/Universal/BdsDxe/BootMaint/BootOption.c               |  2 +-
>  IntelFrameworkModulePkg/Universal/BdsDxe/BootMaint/ConsoleOption.c            |  6 +++---
>  IntelFrameworkModulePkg/Universal/BdsDxe/BootMaint/UpdatePage.c               | 10 +++++-----
>  IntelFrameworkModulePkg/Universal/BdsDxe/BootMaint/Variable.c                 |  2 +-
>  IntelFrameworkModulePkg/Universal/BdsDxe/BootMngr/BootManager.c               |  2 +-
>  MdeModulePkg/Application/MemoryProfileInfo/MemoryProfileInfo.c                |  6 +++---
>  MdeModulePkg/Bus/Pci/PciBusDxe/PciLib.c                                       |  2 +-
>  MdeModulePkg/Bus/Pci/PciHostBridgeDxe/PciHostBridge.c                         |  2 +-
>  MdeModulePkg/Bus/Usb/UsbBusDxe/UsbHub.c                                       |  4 ++--
>  MdeModulePkg/Core/Dxe/Mem/Pool.c                                              |  2 +-
>  MdeModulePkg/Core/PiSmmCore/Pool.c                                            |  2 +-
>  MdeModulePkg/Core/PiSmmCore/SmramProfileRecord.c                              |  6 +++---
>  MdeModulePkg/Library/BootMaintenanceManagerUiLib/BootMaintenance.c            |  8 ++++----
>  MdeModulePkg/Library/BootMaintenanceManagerUiLib/ConsoleOption.c              |  8 ++++----
>  MdeModulePkg/Library/BootMaintenanceManagerUiLib/UpdatePage.c                 | 12 ++++++------
>  MdeModulePkg/Library/BootMaintenanceManagerUiLib/Variable.c                   |  2 +-
>  MdeModulePkg/Library/BootManagerUiLib/BootManager.c                           |  6 +++---
>  MdeModulePkg/Library/UefiBootManagerLib/BmBootDescription.c                   |  2 +-
>  MdeModulePkg/Library/UefiBootManagerLib/BmConsole.c                           |  2 +-
>  MdeModulePkg/Library/UefiBootManagerLib/BmHotkey.c                            |  2 +-
>  MdeModulePkg/Library/UefiBootManagerLib/BmLoadOption.c                        |  4 ++--
>  MdeModulePkg/Library/VarCheckHiiLib/VarCheckHiiGen.c                          |  4 ++--
>  MdeModulePkg/Library/VarCheckHiiLib/VarCheckHiiLibNullClass.c                 |  2 +-
>  MdeModulePkg/Logo/Logo.c                                                      |  2 +-
>  MdeModulePkg/Universal/BdsDxe/BdsEntry.c                                      |  2 +-
>  MdeModulePkg/Universal/DisplayEngineDxe/FormDisplay.c                         |  4 ++--
>  MdeModulePkg/Universal/DisplayEngineDxe/InputHandler.c                        |  6 +++---
>  MdeModulePkg/Universal/EbcDxe/EbcExecute.c                                    |  2 +-
>  MdeModulePkg/Universal/Network/Tcp4Dxe/Tcp4Output.c                           |  2 +-
>  MdeModulePkg/Universal/RegularExpressionDxe/RegularExpressionDxe.h            |  2 --
>  MdeModulePkg/Universal/Variable/RuntimeDxe/Variable.c                         |  2 +-
>  MdePkg/Include/Base.h                                                         | 13 +++++++++++++
>  NetworkPkg/Application/IpsecConfig/IpSecConfig.h                              |  2 --
>  NetworkPkg/IScsiDxe/IScsiConfig.c                                             |  4 ++--
>  NetworkPkg/IScsiDxe/IScsiDriver.c                                             |  2 +-
>  NetworkPkg/IScsiDxe/IScsiMisc.c                                               |  6 +++---
>  NetworkPkg/TcpDxe/TcpOutput.c                                                 |  2 +-
>  Nt32Pkg/WinNtSerialIoDxe/WinNtSerialIo.c                                      |  2 +-
>  OptionRomPkg/AtapiPassThruDxe/AtapiPassThru.c                                 |  4 ++--
>  OvmfPkg/Library/PlatformBootManagerLib/BdsPlatform.c                          |  5 -----
>  OvmfPkg/Library/QemuBootOrderLib/QemuBootOrderLib.c                           | 12 ++++++------
>  OvmfPkg/QemuVideoDxe/Initialize.c                                             |  4 ++--
>  OvmfPkg/XenBusDxe/XenStore.c                                                  |  1 -
>  PerformancePkg/Dp_App/Dp.c                                                    |  2 +-
>  PerformancePkg/Dp_App/DpTrace.c                                               | 10 +++++-----
>  SecurityPkg/Library/AuthVariableLib/AuthVariableLib.c                         |  4 ++--
>  ShellPkg/Library/UefiDpLib/DpTrace.c                                          | 10 +++++-----
>  ShellPkg/Library/UefiShellLevel2CommandsLib/TimeDate.c                        |  2 +-
>  Vlv2TbltDevicePkg/Application/FirmwareUpdate/FirmwareUpdate.c                 |  2 +-
>  Vlv2TbltDevicePkg/PlatformInitPei/FlashMap.c                                  |  2 +-
>  Vlv2TbltDevicePkg/PlatformPei/BootMode.c                                      |  6 +++---
>  Vlv2TbltDevicePkg/PlatformSetupDxe/SetupInfoRecords.c                         |  2 +-
>  Vlv2TbltDevicePkg/SmBiosMiscDxe/MiscOemType0x94Function.c                     |  2 +-
>  65 files changed, 131 insertions(+), 128 deletions(-)
> 

Thanks everyone for the quick reviews; series pushed as
2e182e30e571..83e875a21fba.

Gary, please feel free to go ahead with the manual conversions, wherever
appropriate :)

Thanks!
Laszlo


^ permalink raw reply	[flat|nested] 98+ messages in thread

* Re: [PATCH 40/47] SecurityPkg/AuthVariableLib: rebase to ARRAY_SIZE()
  2016-10-27  9:07   ` Laszlo Ersek
  2016-10-27  9:09     ` Zeng, Star
@ 2016-10-28  8:36     ` Zhang, Chao B
  2016-10-28 10:20       ` Laszlo Ersek
  1 sibling, 1 reply; 98+ messages in thread
From: Zhang, Chao B @ 2016-10-28  8:36 UTC (permalink / raw)
  To: Laszlo Ersek, Zeng, Star; +Cc: edk2-devel-01

Reviewed-by: Chao Zhang <chao.b.zhang@intel.com>





Thanks & Best regards
Chao Zhang

From: Laszlo Ersek [mailto:lersek@redhat.com]
Sent: Thursday, October 27, 2016 5:08 PM
To: Zeng, Star; Zhang, Chao B
Cc: edk2-devel-01
Subject: Re: [edk2] [PATCH 40/47] SecurityPkg/AuthVariableLib: rebase to ARRAY_SIZE()

Star, Chao,

On 10/26/16 21:04, Laszlo Ersek wrote:
> Cc: Chao Zhang <chao.b.zhang@intel.com<mailto:chao.b.zhang@intel.com>>
> Cc: Star Zeng <star.zeng@intel.com<mailto:star.zeng@intel.com>>
> Contributed-under: TianoCore Contribution Agreement 1.0
> Signed-off-by: Laszlo Ersek <lersek@redhat.com<mailto:lersek@redhat.com>>
> ---
>  SecurityPkg/Library/AuthVariableLib/AuthVariableLib.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/SecurityPkg/Library/AuthVariableLib/AuthVariableLib.c b/SecurityPkg/Library/AuthVariableLib/AuthVariableLib.c
> index c4fbb649f1fd..792a1232aed9 100644
> --- a/SecurityPkg/Library/AuthVariableLib/AuthVariableLib.c
> +++ b/SecurityPkg/Library/AuthVariableLib/AuthVariableLib.c
> @@ -421,7 +421,7 @@ AuthVariableLibInitialize (
>    AuthVarLibContextOut->StructVersion = AUTH_VAR_LIB_CONTEXT_OUT_STRUCT_VERSION;
>    AuthVarLibContextOut->StructSize = sizeof (AUTH_VAR_LIB_CONTEXT_OUT);
>    AuthVarLibContextOut->AuthVarEntry = mAuthVarEntry;
> -  AuthVarLibContextOut->AuthVarEntryCount = sizeof (mAuthVarEntry) / sizeof (mAuthVarEntry[0]);
> +  AuthVarLibContextOut->AuthVarEntryCount = ARRAY_SIZE (mAuthVarEntry);
>    mAuthVarAddressPointer[0] = (VOID **) &mPubKeyStore;
>    mAuthVarAddressPointer[1] = (VOID **) &mCertDbStore;
>    mAuthVarAddressPointer[2] = (VOID **) &mHashCtx;
> @@ -433,7 +433,7 @@ AuthVariableLibInitialize (
>    mAuthVarAddressPointer[8] = (VOID **) &(mAuthVarLibContextIn->CheckRemainingSpaceForConsistency),
>    mAuthVarAddressPointer[9] = (VOID **) &(mAuthVarLibContextIn->AtRuntime),
>    AuthVarLibContextOut->AddressPointer = mAuthVarAddressPointer;
> -  AuthVarLibContextOut->AddressPointerCount = sizeof (mAuthVarAddressPointer) / sizeof (mAuthVarAddressPointer[0]);
> +  AuthVarLibContextOut->AddressPointerCount = ARRAY_SIZE (mAuthVarAddressPointer);
>
>    return Status;
>  }
>

can one of you guys please review this patch?

Thanks!
Laszlo


^ permalink raw reply	[flat|nested] 98+ messages in thread

* Re: [PATCH 40/47] SecurityPkg/AuthVariableLib: rebase to ARRAY_SIZE()
  2016-10-28  8:36     ` Zhang, Chao B
@ 2016-10-28 10:20       ` Laszlo Ersek
  0 siblings, 0 replies; 98+ messages in thread
From: Laszlo Ersek @ 2016-10-28 10:20 UTC (permalink / raw)
  To: Zhang, Chao B, Zeng, Star; +Cc: edk2-devel-01

On 10/28/16 10:36, Zhang, Chao B wrote:
> Reviewed-by: Chao Zhang <chao.b.zhang@intel.com>

Thank you. I committed the series yesterday, with Star's and Jordan's
R-bs for this patch. I hope that's okay.

Thanks!
Laszlo

> From: Laszlo Ersek [mailto:lersek@redhat.com]
> Sent: Thursday, October 27, 2016 5:08 PM
> To: Zeng, Star; Zhang, Chao B
> Cc: edk2-devel-01
> Subject: Re: [edk2] [PATCH 40/47] SecurityPkg/AuthVariableLib: rebase to ARRAY_SIZE()
> 
> Star, Chao,
> 
> On 10/26/16 21:04, Laszlo Ersek wrote:
>> Cc: Chao Zhang <chao.b.zhang@intel.com<mailto:chao.b.zhang@intel.com>>
>> Cc: Star Zeng <star.zeng@intel.com<mailto:star.zeng@intel.com>>
>> Contributed-under: TianoCore Contribution Agreement 1.0
>> Signed-off-by: Laszlo Ersek <lersek@redhat.com<mailto:lersek@redhat.com>>
>> ---
>>  SecurityPkg/Library/AuthVariableLib/AuthVariableLib.c | 4 ++--
>>  1 file changed, 2 insertions(+), 2 deletions(-)
>>
>> diff --git a/SecurityPkg/Library/AuthVariableLib/AuthVariableLib.c b/SecurityPkg/Library/AuthVariableLib/AuthVariableLib.c
>> index c4fbb649f1fd..792a1232aed9 100644
>> --- a/SecurityPkg/Library/AuthVariableLib/AuthVariableLib.c
>> +++ b/SecurityPkg/Library/AuthVariableLib/AuthVariableLib.c
>> @@ -421,7 +421,7 @@ AuthVariableLibInitialize (
>>    AuthVarLibContextOut->StructVersion = AUTH_VAR_LIB_CONTEXT_OUT_STRUCT_VERSION;
>>    AuthVarLibContextOut->StructSize = sizeof (AUTH_VAR_LIB_CONTEXT_OUT);
>>    AuthVarLibContextOut->AuthVarEntry = mAuthVarEntry;
>> -  AuthVarLibContextOut->AuthVarEntryCount = sizeof (mAuthVarEntry) / sizeof (mAuthVarEntry[0]);
>> +  AuthVarLibContextOut->AuthVarEntryCount = ARRAY_SIZE (mAuthVarEntry);
>>    mAuthVarAddressPointer[0] = (VOID **) &mPubKeyStore;
>>    mAuthVarAddressPointer[1] = (VOID **) &mCertDbStore;
>>    mAuthVarAddressPointer[2] = (VOID **) &mHashCtx;
>> @@ -433,7 +433,7 @@ AuthVariableLibInitialize (
>>    mAuthVarAddressPointer[8] = (VOID **) &(mAuthVarLibContextIn->CheckRemainingSpaceForConsistency),
>>    mAuthVarAddressPointer[9] = (VOID **) &(mAuthVarLibContextIn->AtRuntime),
>>    AuthVarLibContextOut->AddressPointer = mAuthVarAddressPointer;
>> -  AuthVarLibContextOut->AddressPointerCount = sizeof (mAuthVarAddressPointer) / sizeof (mAuthVarAddressPointer[0]);
>> +  AuthVarLibContextOut->AddressPointerCount = ARRAY_SIZE (mAuthVarAddressPointer);
>>
>>    return Status;
>>  }
>>
> 
> can one of you guys please review this patch?
> 
> Thanks!
> Laszlo
> _______________________________________________
> edk2-devel mailing list
> edk2-devel@lists.01.org
> https://lists.01.org/mailman/listinfo/edk2-devel
> 



^ permalink raw reply	[flat|nested] 98+ messages in thread

end of thread, other threads:[~2016-10-28 10:20 UTC | newest]

Thread overview: 98+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-10-26 19:04 [PATCH 00/47] edk2: centralize and adopt ARRAY_SIZE() Laszlo Ersek
2016-10-26 19:04 ` [PATCH 01/47] MdeModulePkg/RegularExpressionDxe: guard the definition of ARRAY_SIZE Laszlo Ersek
2016-10-26 19:04 ` [PATCH 02/47] NetworkPkg/IpsecConfig: " Laszlo Ersek
2016-10-27  1:59   ` Fu, Siyuan
2016-10-27  2:30   ` Wu, Jiaxin
2016-10-26 19:04 ` [PATCH 03/47] OvmfPkg/PlatformBootManagerLib: " Laszlo Ersek
2016-10-26 19:04 ` [PATCH 04/47] OvmfPkg/XenBusDxe: " Laszlo Ersek
2016-10-27  3:15   ` Gary Lin
2016-10-26 19:04 ` [PATCH 05/47] MdePkg/Include/Base.h: introduce the ARRAY_SIZE() function-like macro Laszlo Ersek
2016-10-26 22:13   ` Kinney, Michael D
2016-10-26 22:25     ` Laszlo Ersek
2016-10-27  2:21       ` Kinney, Michael D
2016-10-26 19:04 ` [PATCH 06/47] MdeModulePkg/RegularExpressionDxe: remove module-local ARRAY_SIZE macro Laszlo Ersek
2016-10-26 19:04 ` [PATCH 07/47] NetworkPkg/IpsecConfig: " Laszlo Ersek
2016-10-27  1:59   ` Fu, Siyuan
2016-10-27  2:31   ` Wu, Jiaxin
2016-10-26 19:04 ` [PATCH 08/47] OvmfPkg/PlatformBootManagerLib: " Laszlo Ersek
2016-10-26 19:04 ` [PATCH 09/47] OvmfPkg/XenBusDxe: " Laszlo Ersek
2016-10-27  3:16   ` Gary Lin
2016-10-26 19:04 ` [PATCH 10/47] ArmVirtPkg/NorFlashQemuLib: rebase to ARRAY_SIZE() Laszlo Ersek
2016-10-27  7:30   ` Ard Biesheuvel
2016-10-26 19:04 ` [PATCH 11/47] DuetPkg/DuetBdsLib: " Laszlo Ersek
2016-10-27  8:16   ` Laszlo Ersek
2016-10-27  9:04     ` Ni, Ruiyu
2016-10-27  9:12       ` Laszlo Ersek
2016-10-26 19:04 ` [PATCH 12/47] EdkCompatibilityPkg/FrameworkHiiOnUefiHiiThunk: " Laszlo Ersek
2016-10-27  1:20   ` Gao, Liming
2016-10-26 19:04 ` [PATCH 13/47] EdkCompatibilityPkg/Sample/Tools: " Laszlo Ersek
2016-10-27  1:20   ` Gao, Liming
2016-10-26 19:04 ` [PATCH 14/47] FatPkg/EnhancedFatDxe: " Laszlo Ersek
2016-10-27  1:53   ` Ni, Ruiyu
2016-10-26 19:04 ` [PATCH 15/47] IntelFrameworkModulePkg/LegacyBootManagerLib: " Laszlo Ersek
2016-10-27  3:09   ` Fan, Jeff
2016-10-26 19:04 ` [PATCH 16/47] IntelFrameworkModulePkg/BdsDxe: " Laszlo Ersek
2016-10-27  3:12   ` Fan, Jeff
2016-10-26 19:04 ` [PATCH 17/47] MdeModulePkg/MemoryProfileInfo: " Laszlo Ersek
2016-10-26 19:04 ` [PATCH 18/47] MdeModulePkg/PciBusDxe: " Laszlo Ersek
2016-10-27  1:53   ` Ni, Ruiyu
2016-10-26 19:04 ` [PATCH 19/47] MdeModulePkg/PciHostBridgeDxe: " Laszlo Ersek
2016-10-27  1:49   ` Ni, Ruiyu
2016-10-26 19:04 ` [PATCH 20/47] MdeModulePkg/UsbBusDxe: " Laszlo Ersek
2016-10-26 19:04 ` [PATCH 21/47] MdeModulePkg/Core/Dxe: " Laszlo Ersek
2016-10-26 19:04 ` [PATCH 22/47] MdeModulePkg/Core/PiSmmCore: " Laszlo Ersek
2016-10-27  2:20   ` Kinney, Michael D
2016-10-26 19:04 ` [PATCH 23/47] MdeModulePkg/BootMaintenanceManagerUiLib: " Laszlo Ersek
2016-10-26 19:04 ` [PATCH 24/47] MdeModulePkg/BootManagerUiLib: " Laszlo Ersek
2016-10-26 19:04 ` [PATCH 25/47] MdeModulePkg/UefiBootManagerLib: " Laszlo Ersek
2016-10-27  1:50   ` Ni, Ruiyu
2016-10-26 19:04 ` [PATCH 26/47] MdeModulePkg/VarCheckHiiLib: " Laszlo Ersek
2016-10-26 19:04 ` [PATCH 27/47] MdeModulePkg/Logo: " Laszlo Ersek
2016-10-27  1:53   ` Ni, Ruiyu
2016-10-26 19:04 ` [PATCH 28/47] MdeModulePkg/BdsDxe: " Laszlo Ersek
2016-10-27  1:50   ` Ni, Ruiyu
2016-10-27  1:50   ` Ni, Ruiyu
2016-10-26 19:04 ` [PATCH 29/47] MdeModulePkg/DisplayEngineDxe: " Laszlo Ersek
2016-10-26 19:04 ` [PATCH 30/47] MdeModulePkg/EbcDxe: " Laszlo Ersek
2016-10-26 19:04 ` [PATCH 31/47] MdeModulePkg/Tcp4Dxe: " Laszlo Ersek
2016-10-26 19:04 ` [PATCH 32/47] MdeModulePkg/Variable/RuntimeDxe: " Laszlo Ersek
2016-10-26 19:04 ` [PATCH 33/47] NetworkPkg/IScsiDxe: " Laszlo Ersek
2016-10-27  1:59   ` Fu, Siyuan
2016-10-26 19:04 ` [PATCH 34/47] NetworkPkg/TcpDxe: " Laszlo Ersek
2016-10-27  2:00   ` Fu, Siyuan
2016-10-27  2:31   ` Wu, Jiaxin
2016-10-26 19:04 ` [PATCH 35/47] Nt32Pkg/WinNtSerialIoDxe: " Laszlo Ersek
2016-10-27  1:49   ` Ni, Ruiyu
2016-10-26 19:04 ` [PATCH 36/47] OptionRomPkg/AtapiPassThruDxe: " Laszlo Ersek
2016-10-27  1:47   ` Ni, Ruiyu
2016-10-26 19:04 ` [PATCH 37/47] OvmfPkg/QemuBootOrderLib: " Laszlo Ersek
2016-10-26 19:04 ` [PATCH 38/47] OvmfPkg/QemuVideoDxe: " Laszlo Ersek
2016-10-26 19:04 ` [PATCH 39/47] PerformancePkg/Dp_App: " Laszlo Ersek
2016-10-26 19:04 ` [PATCH 40/47] SecurityPkg/AuthVariableLib: " Laszlo Ersek
2016-10-27  9:07   ` Laszlo Ersek
2016-10-27  9:09     ` Zeng, Star
2016-10-27  9:12       ` Laszlo Ersek
2016-10-28  8:36     ` Zhang, Chao B
2016-10-28 10:20       ` Laszlo Ersek
2016-10-26 19:04 ` [PATCH 41/47] ShellPkg/UefiDpLib: " Laszlo Ersek
2016-10-27  1:47   ` Ni, Ruiyu
2016-10-26 19:04 ` [PATCH 42/47] ShellPkg/UefiShellLevel2CommandsLib: " Laszlo Ersek
2016-10-27  1:47   ` Ni, Ruiyu
2016-10-26 19:05 ` [PATCH 43/47] Vlv2TbltDevicePkg/FirmwareUpdate: " Laszlo Ersek
2016-10-27  7:08   ` Guo, Mang
2016-10-26 19:05 ` [PATCH 44/47] Vlv2TbltDevicePkg/PlatformInitPei: " Laszlo Ersek
2016-10-27  7:10   ` Guo, Mang
2016-10-26 19:05 ` [PATCH 45/47] Vlv2TbltDevicePkg/PlatformPei: " Laszlo Ersek
2016-10-27  7:12   ` Guo, Mang
2016-10-26 19:05 ` [PATCH 46/47] Vlv2TbltDevicePkg/PlatformSetupDxe: " Laszlo Ersek
2016-10-27  7:14   ` Guo, Mang
2016-10-26 19:05 ` [PATCH 47/47] Vlv2TbltDevicePkg/SmBiosMiscDxe: " Laszlo Ersek
2016-10-27  7:14   ` Guo, Mang
2016-10-26 21:48 ` [PATCH 00/47] edk2: centralize and adopt ARRAY_SIZE() Carsey, Jaben
2016-10-27  1:17 ` Tian, Feng
2016-10-27  2:37   ` Zeng, Star
2016-10-27  4:43 ` Gary Lin
2016-10-27  7:52   ` Laszlo Ersek
2016-10-27  6:05 ` Jordan Justen
2016-10-27  8:49   ` Laszlo Ersek
2016-10-27  9:27 ` Laszlo Ersek

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox