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
)\r
{\r
UINTN Index;\r
+ UINTN Uint;\r
\r
if (!CompareGuid (Guid, &gEfiGlobalVariableGuid) ||\r
(StrSize (Name) != sizeof (L"Key####")) ||\r
\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
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
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
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