From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga06.intel.com (mga06.intel.com [134.134.136.31]) (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 F0BE482024 for ; Fri, 10 Feb 2017 09:06:05 -0800 (PST) Received: from fmsmga006.fm.intel.com ([10.253.24.20]) by orsmga104.jf.intel.com with ESMTP; 10 Feb 2017 09:06:05 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.35,142,1484035200"; d="scan'208";a="64257719" Received: from fmsmsx104.amr.corp.intel.com ([10.18.124.202]) by fmsmga006.fm.intel.com with ESMTP; 10 Feb 2017 09:06:05 -0800 Received: from fmsmsx103.amr.corp.intel.com ([169.254.2.47]) by fmsmsx104.amr.corp.intel.com ([169.254.3.29]) with mapi id 14.03.0248.002; Fri, 10 Feb 2017 09:06:05 -0800 From: "Carsey, Jaben" To: "Ni, Ruiyu" , "edk2-devel@lists.01.org" CC: "Carsey, Jaben" Thread-Topic: [PATCH] ShellPkg/pci: Report error when invalid value is specified for "-ec" Thread-Index: AQHSg3cEhyufqIZziU+obD++4Q3cKKFieM4Q Date: Fri, 10 Feb 2017 17:06:04 +0000 Message-ID: References: <20170210082335.91020-1-ruiyu.ni@intel.com> In-Reply-To: <20170210082335.91020-1-ruiyu.ni@intel.com> Accept-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-titus-metadata-40: eyJDYXRlZ29yeUxhYmVscyI6IiIsIk1ldGFkYXRhIjp7Im5zIjoiaHR0cDpcL1wvd3d3LnRpdHVzLmNvbVwvbnNcL0ludGVsMyIsImlkIjoiYTM4N2ZiNjItODYyOS00ZGUzLWE0NGUtZjAyMDkwZjg2YzU3IiwicHJvcHMiOlt7Im4iOiJDVFBDbGFzc2lmaWNhdGlvbiIsInZhbHMiOlt7InZhbHVlIjoiQ1RQX0lDIn1dfV19LCJTdWJqZWN0TGFiZWxzIjpbXSwiVE1DVmVyc2lvbiI6IjE1LjkuNi42IiwiVHJ1c3RlZExhYmVsSGFzaCI6IkF0WG1MaFhYNFhnTWFBU2l3UU5Ca3dyZWZqTkxQKzFrU3lkSDJGalRtTEU9In0= x-ctpclassification: CTP_IC x-originating-ip: [10.1.200.107] MIME-Version: 1.0 Subject: Re: [PATCH] ShellPkg/pci: Report error when invalid value is specified for "-ec" 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: Fri, 10 Feb 2017 17:06:06 -0000 Content-Language: en-US Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Reviewed-by: Jaben Carsey Ray, What is the intended behavior if the user does -ec with no data after it? -Jaben > -----Original Message----- > From: Ni, Ruiyu > Sent: Friday, February 10, 2017 12:24 AM > To: edk2-devel@lists.01.org > Cc: Carsey, Jaben > Subject: [PATCH] ShellPkg/pci: Report error when invalid value is specifi= ed > for "-ec" > Importance: High >=20 > Contributed-under: TianoCore Contribution Agreement 1.0 > Signed-off-by: Ruiyu Ni > Cc: Jaben Carsey > --- > ShellPkg/Library/UefiShellDebug1CommandsLib/Pci.c | 21 > +++++++++++++++------ > .../UefiShellDebug1CommandsLib.uni | 2 +- > 2 files changed, 16 insertions(+), 7 deletions(-) >=20 > diff --git a/ShellPkg/Library/UefiShellDebug1CommandsLib/Pci.c > b/ShellPkg/Library/UefiShellDebug1CommandsLib/Pci.c > index fb7561f..37f15d6 100644 > --- a/ShellPkg/Library/UefiShellDebug1CommandsLib/Pci.c > +++ b/ShellPkg/Library/UefiShellDebug1CommandsLib/Pci.c > @@ -2726,6 +2726,7 @@ ShellCommandRunPci ( > Bus =3D 0; > Device =3D 0; > Func =3D 0; > + EnhancedDump =3D 0xFFFF; > if (ShellCommandLineGetFlag(Package, L"-i")) { > ExplainData =3D TRUE; > } > @@ -2807,6 +2808,20 @@ ShellCommandRunPci ( > } > } >=20 > + Temp =3D ShellCommandLineGetValue (Package, L"-ec"); > + if (Temp !=3D NULL) { > + // > + // Input converted to hexadecimal number. > + // > + if (!EFI_ERROR (ShellConvertStringToUint64 (Temp, &RetVal, TRUE, > TRUE))) { > + EnhancedDump =3D (UINT16) RetVal; > + } else { > + ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN > (STR_GEN_PARAM_INV_HEX), gShellDebug1HiiHandle, L"pci", Temp); > + ShellStatus =3D SHELL_INVALID_PARAMETER; > + goto Done; > + } > + } > + > // > // Find the protocol interface who's in charge of current segment, a= nd its > // bus range covers the current bus > @@ -2883,12 +2898,6 @@ ShellCommandRunPci ( > // If "-i" appears in command line, interpret data in configuration = space > // > if (ExplainData) { > - EnhancedDump =3D 0xFFFF; > - if (ShellCommandLineGetFlag(Package, L"-ec")) { > - Temp =3D ShellCommandLineGetValue(Package, L"-ec"); > - ASSERT (Temp !=3D NULL); > - EnhancedDump =3D (UINT16) ShellHexStrToUintn (Temp); > - } > Status =3D PciExplainData (&ConfigSpace, Address, IoDev, EnhancedD= ump); > } > } > diff --git > a/ShellPkg/Library/UefiShellDebug1CommandsLib/UefiShellDebug1Comman > dsLib.uni > b/ShellPkg/Library/UefiShellDebug1CommandsLib/UefiShellDebug1Comman > dsLib.uni > index 8ea4215..7c0ca98 100644 > --- > a/ShellPkg/Library/UefiShellDebug1CommandsLib/UefiShellDebug1Comman > dsLib.uni > +++ > b/ShellPkg/Library/UefiShellDebug1CommandsLib/UefiShellDebug1Comman > dsLib.uni > @@ -39,7 +39,7 @@ > #string STR_GEN_PCIRBIO_NF #language en-US "%H%s%N: Protocol - > PciRootBridgeIo not found.\r\n" > #string STR_GEN_PCIRBIO_ER #language en-US "%H%s%N: Problem > accessing the data using Protocol - PciRootBridgeIo\r\n" > #string STR_GEN_PARAM_INV #language en-US "%H%s%N: Invalid > argument - '%H%s%N'\r\n" > -#string STR_GEN_PARAM_INV_HEX #language en-US "%H%s%N: Invalid > parameter - '%H%s%N:'. Must be hexadecimal.\r\n" > +#string STR_GEN_PARAM_INV_HEX #language en-US "%H%s%N: Invalid > parameter - '%H%s%N'. Must be hexadecimal.\r\n" > #string STR_GEN_PARAM_CONFLICT #language en-US "%H%s%N: Flags > conflict with - '%H%s%N' and '%H%s%N'\r\n" > #string STR_GEN_OUT_MEM #language en-US "%H%s%N: Memory > allocation was not successful.\r\n" > #string STR_GEN_MAP_PROTOCOL #language en-US "%H%s%N: Mapped > device '%B%s%N' does not have protocol %B%s%N\r\n" > -- > 2.9.0.windows.1