From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga01.intel.com (mga01.intel.com [192.55.52.88]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id 5CFFD821BA for ; Tue, 28 Feb 2017 09:05:51 -0800 (PST) Received: from orsmga003.jf.intel.com ([10.7.209.27]) by fmsmga101.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 28 Feb 2017 09:05:38 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.35,220,1484035200"; d="scan'208";a="939049342" Received: from fmsmsx107.amr.corp.intel.com ([10.18.124.205]) by orsmga003.jf.intel.com with ESMTP; 28 Feb 2017 09:05:05 -0800 Received: from fmsmsx154.amr.corp.intel.com (10.18.116.70) by fmsmsx107.amr.corp.intel.com (10.18.124.205) with Microsoft SMTP Server (TLS) id 14.3.248.2; Tue, 28 Feb 2017 09:05:05 -0800 Received: from fmsmsx103.amr.corp.intel.com ([169.254.2.47]) by FMSMSX154.amr.corp.intel.com ([169.254.6.37]) with mapi id 14.03.0248.002; Tue, 28 Feb 2017 09:05:05 -0800 From: "Carsey, Jaben" To: "Ni, Ruiyu" , "edk2-devel@lists.01.org" CC: "Carsey, Jaben" Thread-Topic: [PATCH v2 09/11] ShellPkg/Debug1CommandLib: Use StrToGuid/StrHexToBytes in BaseLib Thread-Index: AQHSkMpRdFWDlvtraky9IfmmCZQPyaF+qAQg Date: Tue, 28 Feb 2017 17:05:05 +0000 Message-ID: References: <20170227072239.273228-1-ruiyu.ni@intel.com> <20170227072239.273228-10-ruiyu.ni@intel.com> In-Reply-To: <20170227072239.273228-10-ruiyu.ni@intel.com> Accept-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-titus-metadata-40: eyJDYXRlZ29yeUxhYmVscyI6IiIsIk1ldGFkYXRhIjp7Im5zIjoiaHR0cDpcL1wvd3d3LnRpdHVzLmNvbVwvbnNcL0ludGVsMyIsImlkIjoiZGQ3NTkyZWMtNzhkMy00NzNjLTk4YjMtODM4OThjYTA1OTdiIiwicHJvcHMiOlt7Im4iOiJDVFBDbGFzc2lmaWNhdGlvbiIsInZhbHMiOlt7InZhbHVlIjoiQ1RQX0lDIn1dfV19LCJTdWJqZWN0TGFiZWxzIjpbXSwiVE1DVmVyc2lvbiI6IjE1LjkuNi42IiwiVHJ1c3RlZExhYmVsSGFzaCI6IitOUXdNek9KaUx3eEJQekhTZTc1V0Z0VTNvUDcwVDUwR1wvbVJJRmd5SGo4PSJ9 x-ctpclassification: CTP_IC x-originating-ip: [10.1.200.108] MIME-Version: 1.0 Subject: Re: [PATCH v2 09/11] ShellPkg/Debug1CommandLib: Use StrToGuid/StrHexToBytes in BaseLib X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 28 Feb 2017 17:05:51 -0000 Content-Language: en-US Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Reviewed-by: Jaben Carsey > -----Original Message----- > From: Ni, Ruiyu > Sent: Sunday, February 26, 2017 11:23 PM > To: edk2-devel@lists.01.org > Cc: Carsey, Jaben > Subject: [PATCH v2 09/11] ShellPkg/Debug1CommandLib: Use > StrToGuid/StrHexToBytes in BaseLib > Importance: High >=20 > Contributed-under: TianoCore Contribution Agreement 1.0 > Signed-off-by: Ruiyu Ni > Cc: Jaben Carsey > --- > .../Library/UefiShellDebug1CommandsLib/DmpStore.c | 7 +- > .../Library/UefiShellDebug1CommandsLib/SetVar.c | 12 +-- > .../UefiShellDebug1CommandsLib.c | 119 +--------------= ------ > .../UefiShellDebug1CommandsLib.h | 32 +----- > 4 files changed, 11 insertions(+), 159 deletions(-) >=20 > diff --git a/ShellPkg/Library/UefiShellDebug1CommandsLib/DmpStore.c > b/ShellPkg/Library/UefiShellDebug1CommandsLib/DmpStore.c > index bb2c0b9..701ff75 100644 > --- a/ShellPkg/Library/UefiShellDebug1CommandsLib/DmpStore.c > +++ b/ShellPkg/Library/UefiShellDebug1CommandsLib/DmpStore.c > @@ -2,7 +2,7 @@ > Main file for DmpStore shell Debug1 function. >=20 > (C) Copyright 2013-2015 Hewlett-Packard Development Company, L.P.
> - Copyright (c) 2005 - 2016, Intel Corporation. All rights reserved.
> + Copyright (c) 2005 - 2017, Intel Corporation. All rights reserved.
> This program and the accompanying materials > are licensed and made available under the terms and conditions of the = BSD > License > which accompanies this distribution. The full text of the license may= be > found at > @@ -676,6 +676,7 @@ ShellCommandRunDmpStore ( > ) > { > EFI_STATUS Status; > + RETURN_STATUS RStatus; > LIST_ENTRY *Package; > CHAR16 *ProblemParam; > SHELL_STATUS ShellStatus; > @@ -728,8 +729,8 @@ ShellCommandRunDmpStore ( > if (!ShellCommandLineGetFlag(Package, L"-all")) { > GuidStr =3D ShellCommandLineGetValue(Package, L"-guid"); > if (GuidStr !=3D NULL) { > - Status =3D ConvertStringToGuid(GuidStr, &GuidData); > - if (EFI_ERROR(Status)) { > + RStatus =3D StrToGuid (GuidStr, &GuidData); > + if (RETURN_ERROR (RStatus) || (GuidStr[GUID_STRING_LENGTH] != =3D > L'\0')) { > ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_PARAM_IN= V), > gShellDebug1HiiHandle, L"dmpstore", GuidStr); > ShellStatus =3D SHELL_INVALID_PARAMETER; > } > diff --git a/ShellPkg/Library/UefiShellDebug1CommandsLib/SetVar.c > b/ShellPkg/Library/UefiShellDebug1CommandsLib/SetVar.c > index d98a346..c59032a 100644 > --- a/ShellPkg/Library/UefiShellDebug1CommandsLib/SetVar.c > +++ b/ShellPkg/Library/UefiShellDebug1CommandsLib/SetVar.c > @@ -2,7 +2,7 @@ > Main file for SetVar shell Debug1 function. >=20 > (C) Copyright 2015 Hewlett-Packard Development Company, L.P.
> - Copyright (c) 2010 - 2014, Intel Corporation. All rights reserved.
> + Copyright (c) 2010 - 2017, Intel Corporation. All rights reserved.
> This program and the accompanying materials > are licensed and made available under the terms and conditions of the = BSD > License > which accompanies this distribution. The full text of the license may= be > found at > @@ -65,6 +65,7 @@ ShellCommandRunSetVar ( > ) > { > EFI_STATUS Status; > + RETURN_STATUS RStatus; > LIST_ENTRY *Package; > CHAR16 *ProblemParam; > SHELL_STATUS ShellStatus; > @@ -120,8 +121,8 @@ ShellCommandRunSetVar ( > CopyGuid(&Guid, &gEfiGlobalVariableGuid); > } else { > StringGuid =3D ShellCommandLineGetValue(Package, L"-guid"); > - Status =3D ConvertStringToGuid(StringGuid, &Guid); > - if (EFI_ERROR(Status)) { > + RStatus =3D StrToGuid (StringGuid, &Guid); > + if (RETURN_ERROR (RStatus) || (StringGuid[GUID_STRING_LENGTH] != =3D > L'\0')) { > ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_PARAM_INV)= , > gShellDebug1HiiHandle, L"setvar", StringGuid); > ShellStatus =3D SHELL_INVALID_PARAMETER; > } > @@ -207,10 +208,7 @@ ShellCommandRunSetVar ( > if (Buffer =3D=3D NULL) { > Status =3D EFI_OUT_OF_RESOURCES; > } else { > - for (LoopVar =3D 0 ; LoopVar < (StrLen(Data) / 2) ; LoopVa= r++) { > - ((UINT8*)Buffer)[LoopVar] =3D > (UINT8)(HexCharToUintn(Data[LoopVar*2]) * 16); > - ((UINT8*)Buffer)[LoopVar] =3D (UINT8)(((UINT8*)Buffer)[L= oopVar] + > HexCharToUintn(Data[LoopVar*2+1])); > - } > + StrHexToBytes (Data, StrLen (Data), Buffer, StrLen (Data) = / 2); > Status =3D gRT->SetVariable((CHAR16*)VariableName, &Guid, > Attributes, StrLen(Data) / 2, Buffer); > } > if (EFI_ERROR(Status)) { > diff --git > a/ShellPkg/Library/UefiShellDebug1CommandsLib/UefiShellDebug1Comman > dsLib.c > b/ShellPkg/Library/UefiShellDebug1CommandsLib/UefiShellDebug1Comman > dsLib.c > index 6ebf002..8e2141b 100644 > --- > a/ShellPkg/Library/UefiShellDebug1CommandsLib/UefiShellDebug1Comman > dsLib.c > +++ > b/ShellPkg/Library/UefiShellDebug1CommandsLib/UefiShellDebug1Comman > dsLib.c > @@ -1,7 +1,7 @@ > /** @file > Main file for NULL named library for debug1 profile shell command > functions. >=20 > - Copyright (c) 2010 - 2011, Intel Corporation. All rights reserved.
> + Copyright (c) 2010 - 2017, Intel Corporation. All rights reserved.
> This program and the accompanying materials > are licensed and made available under the terms and conditions of the = BSD > License > which accompanies this distribution. The full text of the license may= be > found at > @@ -172,123 +172,6 @@ GetSystemConfigurationTable ( > } >=20 > /** > - Convert a Unicode character to numerical value. > - > - This internal function only deal with Unicode character > - which maps to a valid hexadecimal ASII character, i.e. > - L'0' to L'9', L'a' to L'f' or L'A' to L'F'. For other > - Unicode character, the value returned does not make sense. > - > - @param Char The character to convert. > - > - @return The numerical value converted. > - > -**/ > -UINTN > -HexCharToUintn ( > - IN CHAR16 Char > - ) > -{ > - if (Char >=3D L'0' && Char <=3D L'9') { > - return Char - L'0'; > - } > - > - return (UINTN) (10 + CharToUpper (Char) - L'A'); > -} > - > -/** > - Convert a string representation of a guid to a Guid value. > - > - @param[in] StringGuid The pointer to the string of a guid. > - @param[in, out] Guid The pointer to the GUID structure to populate= . > - > - @retval EFI_INVALID_PARAMETER A parameter was invalid. > - @retval EFI_SUCCESS The conversion was successful. > -**/ > -EFI_STATUS > -ConvertStringToGuid ( > - IN CONST CHAR16 *StringGuid, > - IN OUT EFI_GUID *Guid > - ) > -{ > - CHAR16 *TempCopy; > - CHAR16 *TempSpot; > - CHAR16 *Walker; > - UINT64 TempVal; > - EFI_STATUS Status; > - > - if (StringGuid =3D=3D NULL) { > - return (EFI_INVALID_PARAMETER); > - } else if (StrLen(StringGuid) !=3D 36) { > - return (EFI_INVALID_PARAMETER); > - } > - TempCopy =3D NULL; > - TempCopy =3D StrnCatGrow(&TempCopy, NULL, StringGuid, 0); > - if (TempCopy =3D=3D NULL) { > - return (EFI_OUT_OF_RESOURCES); > - } > - Walker =3D TempCopy; > - TempSpot =3D StrStr(Walker, L"-"); > - if (TempSpot !=3D NULL) { > - *TempSpot =3D CHAR_NULL; > - } > - Status =3D ShellConvertStringToUint64(Walker, &TempVal, TRUE, FALSE); > - if (EFI_ERROR(Status)) { > - FreePool(TempCopy); > - return (Status); > - } > - Guid->Data1 =3D (UINT32)TempVal; > - Walker +=3D 9; > - TempSpot =3D StrStr(Walker, L"-"); > - if (TempSpot !=3D NULL) { > - *TempSpot =3D CHAR_NULL; > - } > - Status =3D ShellConvertStringToUint64(Walker, &TempVal, TRUE, FALSE); > - if (EFI_ERROR(Status)) { > - FreePool(TempCopy); > - return (Status); > - } > - Guid->Data2 =3D (UINT16)TempVal; > - Walker +=3D 5; > - TempSpot =3D StrStr(Walker, L"-"); > - if (TempSpot !=3D NULL) { > - *TempSpot =3D CHAR_NULL; > - } > - Status =3D ShellConvertStringToUint64(Walker, &TempVal, TRUE, FALSE); > - if (EFI_ERROR(Status)) { > - FreePool(TempCopy); > - return (Status); > - } > - Guid->Data3 =3D (UINT16)TempVal; > - Walker +=3D 5; > - Guid->Data4[0] =3D (UINT8)(HexCharToUintn(Walker[0]) * 16); > - Guid->Data4[0] =3D (UINT8)(Guid->Data4[0]+ > (UINT8)HexCharToUintn(Walker[1])); > - Walker +=3D 2; > - Guid->Data4[1] =3D (UINT8)(HexCharToUintn(Walker[0]) * 16); > - Guid->Data4[1] =3D (UINT8)(Guid->Data4[1] + > (UINT8)HexCharToUintn(Walker[1])); > - Walker +=3D 3; > - Guid->Data4[2] =3D (UINT8)(HexCharToUintn(Walker[0]) * 16); > - Guid->Data4[2] =3D (UINT8)(Guid->Data4[2] + > (UINT8)HexCharToUintn(Walker[1])); > - Walker +=3D 2; > - Guid->Data4[3] =3D (UINT8)(HexCharToUintn(Walker[0]) * 16); > - Guid->Data4[3] =3D (UINT8)(Guid->Data4[3] + > (UINT8)HexCharToUintn(Walker[1])); > - Walker +=3D 2; > - Guid->Data4[4] =3D (UINT8)(HexCharToUintn(Walker[0]) * 16); > - Guid->Data4[4] =3D (UINT8)(Guid->Data4[4] + > (UINT8)HexCharToUintn(Walker[1])); > - Walker +=3D 2; > - Guid->Data4[5] =3D (UINT8)(HexCharToUintn(Walker[0]) * 16); > - Guid->Data4[5] =3D (UINT8)(Guid->Data4[5] + > (UINT8)HexCharToUintn(Walker[1])); > - Walker +=3D 2; > - Guid->Data4[6] =3D (UINT8)(HexCharToUintn(Walker[0]) * 16); > - Guid->Data4[6] =3D (UINT8)(Guid->Data4[6] + > (UINT8)HexCharToUintn(Walker[1])); > - Walker +=3D 2; > - Guid->Data4[7] =3D (UINT8)(HexCharToUintn(Walker[0]) * 16); > - Guid->Data4[7] =3D (UINT8)(Guid->Data4[7] + > (UINT8)HexCharToUintn(Walker[1])); > - FreePool(TempCopy); > - return (EFI_SUCCESS); > -} > - > -/** > Clear the line at the specified Row. >=20 > @param[in] Row The row number to be cleared ( start fro= m 1 ) > diff --git > a/ShellPkg/Library/UefiShellDebug1CommandsLib/UefiShellDebug1Comman > dsLib.h > b/ShellPkg/Library/UefiShellDebug1CommandsLib/UefiShellDebug1Comman > dsLib.h > index 52ea56a..80a8476 100644 > --- > a/ShellPkg/Library/UefiShellDebug1CommandsLib/UefiShellDebug1Comman > dsLib.h > +++ > b/ShellPkg/Library/UefiShellDebug1CommandsLib/UefiShellDebug1Comman > dsLib.h > @@ -1,7 +1,7 @@ > /** @file > Main file for NULL named library for Profile1 shell command functions. >=20 > - Copyright (c) 2010 - 2016, Intel Corporation. All rights reserved.
> + Copyright (c) 2010 - 2017, Intel Corporation. All rights reserved.
> This program and the accompanying materials > are licensed and made available under the terms and conditions of the = BSD > License > which accompanies this distribution. The full text of the license may= be > found at > @@ -77,36 +77,6 @@ GetSystemConfigurationTable ( > ); >=20 > /** > - Convert a string representation of a GUID to the GUID value. > - > - @param[in] StringGuid The pointer to the string containing a GUID > printed. > - @param[in, out] Guid The pointer to the buffer to get the GUID val= ue. > -**/ > -EFI_STATUS > -ConvertStringToGuid ( > - IN CONST CHAR16 *StringGuid, > - IN OUT EFI_GUID *Guid > - ); > - > -/** > - Convert a Unicode character to numerical value. > - > - This internal function only deal with Unicode character > - which maps to a valid hexadecimal ASII character, i.e. > - L'0' to L'9', L'a' to L'f' or L'A' to L'F'. For other > - Unicode character, the value returned does not make sense. > - > - @param Char The character to convert. > - > - @return The numerical value converted. > - > -**/ > -UINTN > -HexCharToUintn ( > - IN CHAR16 Char > - ); > - > -/** > Function for 'setsize' command. >=20 > @param[in] ImageHandle Handle to the Image (NULL if Internal). > -- > 2.9.0.windows.1