]> git.proxmox.com Git - mirror_edk2.git/commitdiff
MdeModulePkg: Use BmCharToUint in BmIsKeyOptionVariable
authorRuiyu Ni <ruiyu.ni@intel.com>
Tue, 17 Nov 2015 10:08:40 +0000 (10:08 +0000)
committerniruiyu <niruiyu@Edk2>
Tue, 17 Nov 2015 10:08:40 +0000 (10:08 +0000)
The patch also moves the BmCharToUint to BmMisc.c because it
belongs to misc functions.

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Ruiyu Ni <ruiyu.ni@intel.com>
Reviewed-by: Sunny Wang <sunnywang@hpe.com>
git-svn-id: https://svn.code.sf.net/p/edk2/code/trunk/edk2@18855 6f19259b-4bc3-4df7-8a09-765794883524

MdeModulePkg/Library/UefiBootManagerLib/BmHotkey.c
MdeModulePkg/Library/UefiBootManagerLib/BmLoadOption.c
MdeModulePkg/Library/UefiBootManagerLib/BmMisc.c
MdeModulePkg/Library/UefiBootManagerLib/InternalBm.h

index 8d398fb4c68afa895f38f1ec47c39399c6e2121b..ff1cbe933ce1d8b921d7a983129ef0cda345e2d1 100644 (file)
@@ -88,6 +88,7 @@ BmIsKeyOptionVariable (
   )\r
 {\r
   UINTN         Index;\r
+  UINTN         Uint;\r
   \r
   if (!CompareGuid (Guid, &gEfiGlobalVariableGuid) ||\r
       (StrSize (Name) != sizeof (L"Key####")) ||\r
@@ -98,12 +99,11 @@ BmIsKeyOptionVariable (
 \r
   *OptionNumber = 0;\r
   for (Index = 3; Index < 7; Index++) {\r
-    if ((Name[Index] >= L'0') && (Name[Index] <= L'9')) {\r
-      *OptionNumber = *OptionNumber * 16 + Name[Index] - L'0';\r
-    } else if ((Name[Index] >= L'A') && (Name[Index] <= L'F')) {\r
-      *OptionNumber = *OptionNumber * 16 + Name[Index] - L'A' + 10;\r
-    } else {\r
+    Uint = BmCharToUint (Name[Index]);\r
+    if (Uint == -1) {\r
       return FALSE;\r
+    } else {\r
+      *OptionNumber = (UINT16) Uint + *OptionNumber * 0x10;\r
     }\r
   }\r
 \r
index 07e62496291418e5d732714cea3092f4620ef291..6fcd23b6aba337adb26922a0b3f606ddf88eef08 100644 (file)
@@ -586,29 +586,6 @@ EfiBootManagerDeleteLoadOptionVariable (
   return Status;\r
 }\r
 \r
-/**\r
-  Convert a single character to number.\r
-  It assumes the input Char is in the scope of L'0' ~ L'9' and L'A' ~ L'F'\r
-\r
-  @param    Char   The input char which need to convert to int.\r
-**/\r
-UINTN\r
-BmCharToUint (\r
-  IN CHAR16                           Char\r
-  )\r
-{\r
-  if ((Char >= L'0') && (Char <= L'9')) {\r
-    return (UINTN) (Char - L'0');\r
-  }\r
-\r
-  if ((Char >= L'A') && (Char <= L'F')) {\r
-    return (UINTN) (Char - L'A' + 0xA);\r
-  }\r
-\r
-  ASSERT (FALSE);\r
-  return (UINTN) -1;\r
-}\r
-\r
 /**\r
   Returns the size of a device path in bytes.\r
 \r
index 97d1a48cd5a24af336c09242f0e26bcd50e21611..cc2032cd8288d659437665f9fc19ce409bd0d848 100644 (file)
@@ -384,3 +384,29 @@ BmPrintDp (
     FreePool (Str);\r
   }\r
 }\r
+\r
+/**\r
+  Convert a single character to number.\r
+  It assumes the input Char is in the scope of L'0' ~ L'9' and L'A' ~ L'F'\r
+\r
+  @param    Char   The input char which need to convert to int.\r
+\r
+  @return  The converted 8-bit number or (UINTN) -1 if conversion failed.\r
+**/\r
+UINTN\r
+BmCharToUint (\r
+  IN CHAR16                           Char\r
+  )\r
+{\r
+  if ((Char >= L'0') && (Char <= L'9')) {\r
+    return (UINTN) (Char - L'0');\r
+  }\r
+\r
+  if ((Char >= L'A') && (Char <= L'F')) {\r
+    return (UINTN) (Char - L'A' + 0xA);\r
+  }\r
+\r
+  ASSERT (FALSE);\r
+  return (UINTN) -1;\r
+}\r
+\r
index 290ce3fc548149f5979d1fed1bfeb7530a47fdcc..862811e7b5c132ba254c8678960aa4fd75794838 100644 (file)
@@ -434,4 +434,17 @@ BmPrintDp (
   EFI_DEVICE_PATH_PROTOCOL            *DevicePath\r
   );\r
 \r
+/**\r
+  Convert a single character to number.\r
+  It assumes the input Char is in the scope of L'0' ~ L'9' and L'A' ~ L'F'\r
+\r
+  @param    Char   The input char which need to convert to int.\r
+\r
+  @return  The converted 8-bit number or (UINTN) -1 if conversion failed.\r
+**/\r
+UINTN\r
+BmCharToUint (\r
+  IN CHAR16                           Char\r
+  );\r
+\r
 #endif // _INTERNAL_BM_H_\r