]> git.proxmox.com Git - mirror_edk2.git/blobdiff - MdeModulePkg/Library/UefiBootManagerLib/BmHotkey.c
MdeModulePkg/UefiBootManagerLib: rebase to ARRAY_SIZE()
[mirror_edk2.git] / MdeModulePkg / Library / UefiBootManagerLib / BmHotkey.c
index 4cc4fb4554154361c3de2abac9c065e080c14a6e..35131a94f61d8feb585929978f19839977951624 100644 (file)
@@ -2,6 +2,7 @@
   Hotkey library functions.\r
 \r
 Copyright (c) 2011 - 2016, Intel Corporation. All rights reserved.<BR>\r
+(C) Copyright 2016 Hewlett Packard Enterprise Development LP<BR>\r
 This program and the accompanying materials\r
 are licensed and made available under the terms and conditions of the BSD License\r
 which accompanies this distribution.  The full text of the license may be found at\r
@@ -458,6 +459,9 @@ BmGetActiveConsoleIn (
   EFI_STATUS                            Status;\r
   EFI_HANDLE                            *Handles;\r
 \r
+  Handles = NULL;\r
+  *Count  = 0;\r
+\r
   if (gST->ConsoleInHandle != NULL) {\r
     Status = gBS->OpenProtocol (\r
                     gST->ConsoleInHandle,\r
@@ -468,8 +472,10 @@ BmGetActiveConsoleIn (
                     EFI_OPEN_PROTOCOL_TEST_PROTOCOL\r
                     );\r
     if (!EFI_ERROR (Status)) {\r
-      Handles = AllocateCopyPool (sizeof (EFI_HANDLE *), &gST->ConsoleInHandle);\r
-      *Count  = 1;\r
+      Handles = AllocateCopyPool (sizeof (EFI_HANDLE), &gST->ConsoleInHandle);\r
+      if (Handles != NULL) {\r
+        *Count = 1;\r
+      }\r
     }\r
   } else {\r
     Status = gBS->LocateHandleBuffer (\r
@@ -480,10 +486,6 @@ BmGetActiveConsoleIn (
                     &Handles\r
                     );\r
   }\r
-  if (EFI_ERROR (Status)) {\r
-    Handles = NULL;\r
-    *Count  = 0;\r
-  }\r
 \r
   return Handles;\r
 }\r
@@ -678,7 +680,7 @@ BmProcessKeyOption (
 \r
   KeyShiftStateCount = 0;\r
   BmGenerateKeyShiftState (0, KeyOption, EFI_SHIFT_STATE_VALID, KeyShiftStates, &KeyShiftStateCount);\r
-  ASSERT (KeyShiftStateCount <= sizeof (KeyShiftStates) / sizeof (KeyShiftStates[0]));\r
+  ASSERT (KeyShiftStateCount <= ARRAY_SIZE (KeyShiftStates));\r
 \r
   EfiAcquireLock (&mBmHotkeyLock);\r
 \r