]> git.proxmox.com Git - mirror_edk2.git/commitdiff
MdeModulePkg/CapsuleApp: Use StrToGuid in BaseLib
authorRuiyu Ni <ruiyu.ni@intel.com>
Tue, 21 Feb 2017 09:04:29 +0000 (17:04 +0800)
committerRuiyu Ni <ruiyu.ni@intel.com>
Tue, 28 Feb 2017 03:30:33 +0000 (11:30 +0800)
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Ruiyu Ni <ruiyu.ni@intel.com>
Reviewed-by: Jiewen Yao <jiewen.yao@intel.com>
MdeModulePkg/Application/CapsuleApp/AppSupport.c
MdeModulePkg/Application/CapsuleApp/CapsuleApp.c

index edc5f29c47395e96063822b293d3b48a90c55b44..e39ab2037865215d8b226ce78357142fcd4e9cdc 100644 (file)
@@ -1,7 +1,7 @@
 /** @file\r
   A shell application that triggers capsule update process.\r
 \r
-  Copyright (c) 2016, Intel Corporation. All rights reserved.<BR>\r
+  Copyright (c) 2016 - 2017, Intel Corporation. All rights reserved.<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
@@ -63,144 +63,6 @@ GetArg (
   return EFI_SUCCESS;\r
 }\r
 \r
-/**\r
-  Converts a list of string to a specified buffer.\r
-\r
-  @param[out] Buf             The output buffer that contains the string.\r
-  @param[in]  BufferLength    The length of the buffer\r
-  @param[in]  Str             The input string that contains the hex number\r
-\r
-  @retval EFI_SUCCESS    The string was successfully converted to the buffer.\r
-\r
-**/\r
-EFI_STATUS\r
-InternalStrToBuf (\r
-  OUT UINT8    *Buf,\r
-  IN  UINTN    BufferLength,\r
-  IN  CHAR16   *Str\r
-  )\r
-{\r
-  UINTN       Index;\r
-  UINTN       StrLength;\r
-  UINT8       Digit;\r
-  UINT8       Byte;\r
-\r
-  Digit = 0;\r
-\r
-  //\r
-  // Two hex char make up one byte\r
-  //\r
-  StrLength = BufferLength * sizeof (CHAR16);\r
-\r
-  for(Index = 0; Index < StrLength; Index++, Str++) {\r
-\r
-    if ((*Str >= L'a') && (*Str <= L'f')) {\r
-      Digit = (UINT8) (*Str - L'a' + 0x0A);\r
-    } else if ((*Str >= L'A') && (*Str <= L'F')) {\r
-      Digit = (UINT8) (*Str - L'A' + 0x0A);\r
-    } else if ((*Str >= L'0') && (*Str <= L'9')) {\r
-      Digit = (UINT8) (*Str - L'0');\r
-    } else {\r
-      return EFI_INVALID_PARAMETER;\r
-    }\r
-\r
-    //\r
-    // For odd characters, write the upper nibble for each buffer byte,\r
-    // and for even characters, the lower nibble.\r
-    //\r
-    if ((Index & 1) == 0) {\r
-      Byte = (UINT8) (Digit << 4);\r
-    } else {\r
-      Byte = Buf[Index / 2];\r
-      Byte &= 0xF0;\r
-      Byte = (UINT8) (Byte | Digit);\r
-    }\r
-\r
-    Buf[Index / 2] = Byte;\r
-  }\r
-\r
-  return EFI_SUCCESS;\r
-}\r
-\r
-/**\r
-  Converts a string to GUID value.\r
-  Guid Format is xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx\r
-\r
-  @param[in]  Str              The registry format GUID string that contains the GUID value.\r
-  @param[out] Guid             A pointer to the converted GUID value.\r
-\r
-  @retval EFI_SUCCESS     The GUID string was successfully converted to the GUID value.\r
-  @retval EFI_UNSUPPORTED The input string is not in registry format.\r
-  @return others          Some error occurred when converting part of GUID value.\r
-\r
-**/\r
-EFI_STATUS\r
-InternalStrToGuid (\r
-  IN  CHAR16   *Str,\r
-  OUT EFI_GUID *Guid\r
-  )\r
-{\r
-  //\r
-  // Get the first UINT32 data\r
-  //\r
-  Guid->Data1 = (UINT32) StrHexToUint64  (Str);\r
-  while (!IS_HYPHEN (*Str) && !IS_NULL (*Str)) {\r
-    Str ++;\r
-  }\r
-\r
-  if (IS_HYPHEN (*Str)) {\r
-    Str++;\r
-  } else {\r
-    return EFI_UNSUPPORTED;\r
-  }\r
-\r
-  //\r
-  // Get the second UINT16 data\r
-  //\r
-  Guid->Data2 = (UINT16) StrHexToUint64  (Str);\r
-  while (!IS_HYPHEN (*Str) && !IS_NULL (*Str)) {\r
-    Str ++;\r
-  }\r
-\r
-  if (IS_HYPHEN (*Str)) {\r
-    Str++;\r
-  } else {\r
-    return EFI_UNSUPPORTED;\r
-  }\r
-\r
-  //\r
-  // Get the third UINT16 data\r
-  //\r
-  Guid->Data3 = (UINT16) StrHexToUint64  (Str);\r
-  while (!IS_HYPHEN (*Str) && !IS_NULL (*Str)) {\r
-    Str ++;\r
-  }\r
-\r
-  if (IS_HYPHEN (*Str)) {\r
-    Str++;\r
-  } else {\r
-    return EFI_UNSUPPORTED;\r
-  }\r
-\r
-  //\r
-  // Get the following 8 bytes data\r
-  //\r
-  InternalStrToBuf (&Guid->Data4[0], 2, Str);\r
-  //\r
-  // Skip 2 byte hex chars\r
-  //\r
-  Str += 2 * 2;\r
-\r
-  if (IS_HYPHEN (*Str)) {\r
-    Str++;\r
-  } else {\r
-    return EFI_UNSUPPORTED;\r
-  }\r
-  InternalStrToBuf (&Guid->Data4[2], 6, Str);\r
-\r
-  return EFI_SUCCESS;\r
-}\r
-\r
 /**\r
   Return File System Volume containing this shell application.\r
 \r
index 5b8c14792884d1d8d0c2058784858b3d2470022d..84ed4d738bc4ba777124643168d93b2d2744ad67 100644 (file)
@@ -1,7 +1,7 @@
 /** @file\r
   A shell application that triggers capsule update process.\r
 \r
-  Copyright (c) 2016, Intel Corporation. All rights reserved.<BR>\r
+  Copyright (c) 2016 - 2017, Intel Corporation. All rights reserved.<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
@@ -142,24 +142,6 @@ WriteFileFromBuffer (
   IN  VOID                                 *Buffer\r
   );\r
 \r
-/**\r
-  Converts a string to GUID value.\r
-  Guid Format is xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx\r
-\r
-  @param[in]  Str              The registry format GUID string that contains the GUID value.\r
-  @param[out] Guid             A pointer to the converted GUID value.\r
-\r
-  @retval EFI_SUCCESS     The GUID string was successfully converted to the GUID value.\r
-  @retval EFI_UNSUPPORTED The input string is not in registry format.\r
-  @return others          Some error occurred when converting part of GUID value.\r
-\r
-**/\r
-EFI_STATUS\r
-InternalStrToGuid (\r
-  IN  CHAR16   *Str,\r
-  OUT EFI_GUID *Guid\r
-  );\r
-\r
 /**\r
 \r
   This function parse application ARG.\r
@@ -731,6 +713,7 @@ UefiMain (
   )\r
 {\r
   EFI_STATUS                    Status;\r
+  RETURN_STATUS                 RStatus;\r
   UINTN                         FileSize[MAX_CAPSULE_NUM];\r
   VOID                          *CapsuleBuffer[MAX_CAPSULE_NUM];\r
   EFI_CAPSULE_BLOCK_DESCRIPTOR  *BlockDescriptors;\r
@@ -782,10 +765,10 @@ UefiMain (
         //\r
         // FMP->GetImage()\r
         //\r
-        Status = InternalStrToGuid(Argv[3], &ImageTypeId);\r
-        if (EFI_ERROR(Status)) {\r
+        RStatus = StrToGuid (Argv[3], &ImageTypeId);\r
+        if (RETURN_ERROR (RStatus) || (Argv[3][GUID_STRING_LENGTH] != L'\0')) {\r
           Print (L"Invalid ImageTypeId - %s\n", Argv[3]);\r
-          return Status;\r
+          return EFI_INVALID_PARAMETER;\r
         }\r
         ImageIndex = StrDecimalToUintn(Argv[4]);\r
         if (StrCmp(Argv[5], L"-O") == 0) {\r