* [PATCH] ShellPkg/pci: Report error when invalid value is specified for "-ec" @ 2017-02-10 8:23 Ruiyu Ni 2017-02-10 17:06 ` Carsey, Jaben 0 siblings, 1 reply; 4+ messages in thread From: Ruiyu Ni @ 2017-02-10 8:23 UTC (permalink / raw) To: edk2-devel; +Cc: Jaben Carsey Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Ruiyu Ni <ruiyu.ni@intel.com> Cc: Jaben Carsey <jaben.carsey@intel.com> --- ShellPkg/Library/UefiShellDebug1CommandsLib/Pci.c | 21 +++++++++++++++------ .../UefiShellDebug1CommandsLib.uni | 2 +- 2 files changed, 16 insertions(+), 7 deletions(-) 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 = 0; Device = 0; Func = 0; + EnhancedDump = 0xFFFF; if (ShellCommandLineGetFlag(Package, L"-i")) { ExplainData = TRUE; } @@ -2807,6 +2808,20 @@ ShellCommandRunPci ( } } + Temp = ShellCommandLineGetValue (Package, L"-ec"); + if (Temp != NULL) { + // + // Input converted to hexadecimal number. + // + if (!EFI_ERROR (ShellConvertStringToUint64 (Temp, &RetVal, TRUE, TRUE))) { + EnhancedDump = (UINT16) RetVal; + } else { + ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_GEN_PARAM_INV_HEX), gShellDebug1HiiHandle, L"pci", Temp); + ShellStatus = SHELL_INVALID_PARAMETER; + goto Done; + } + } + // // Find the protocol interface who's in charge of current segment, and 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 = 0xFFFF; - if (ShellCommandLineGetFlag(Package, L"-ec")) { - Temp = ShellCommandLineGetValue(Package, L"-ec"); - ASSERT (Temp != NULL); - EnhancedDump = (UINT16) ShellHexStrToUintn (Temp); - } Status = PciExplainData (&ConfigSpace, Address, IoDev, EnhancedDump); } } diff --git a/ShellPkg/Library/UefiShellDebug1CommandsLib/UefiShellDebug1CommandsLib.uni b/ShellPkg/Library/UefiShellDebug1CommandsLib/UefiShellDebug1CommandsLib.uni index 8ea4215..7c0ca98 100644 --- a/ShellPkg/Library/UefiShellDebug1CommandsLib/UefiShellDebug1CommandsLib.uni +++ b/ShellPkg/Library/UefiShellDebug1CommandsLib/UefiShellDebug1CommandsLib.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 ^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH] ShellPkg/pci: Report error when invalid value is specified for "-ec" 2017-02-10 8:23 [PATCH] ShellPkg/pci: Report error when invalid value is specified for "-ec" Ruiyu Ni @ 2017-02-10 17:06 ` Carsey, Jaben 2017-02-11 4:35 ` Ni, Ruiyu 0 siblings, 1 reply; 4+ messages in thread From: Carsey, Jaben @ 2017-02-10 17:06 UTC (permalink / raw) To: Ni, Ruiyu, edk2-devel@lists.01.org; +Cc: Carsey, Jaben Reviewed-by: Jaben Carsey <jaben.carsey@intel.com> 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 <jaben.carsey@intel.com> > Subject: [PATCH] ShellPkg/pci: Report error when invalid value is specified > for "-ec" > Importance: High > > Contributed-under: TianoCore Contribution Agreement 1.0 > Signed-off-by: Ruiyu Ni <ruiyu.ni@intel.com> > Cc: Jaben Carsey <jaben.carsey@intel.com> > --- > ShellPkg/Library/UefiShellDebug1CommandsLib/Pci.c | 21 > +++++++++++++++------ > .../UefiShellDebug1CommandsLib.uni | 2 +- > 2 files changed, 16 insertions(+), 7 deletions(-) > > 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 = 0; > Device = 0; > Func = 0; > + EnhancedDump = 0xFFFF; > if (ShellCommandLineGetFlag(Package, L"-i")) { > ExplainData = TRUE; > } > @@ -2807,6 +2808,20 @@ ShellCommandRunPci ( > } > } > > + Temp = ShellCommandLineGetValue (Package, L"-ec"); > + if (Temp != NULL) { > + // > + // Input converted to hexadecimal number. > + // > + if (!EFI_ERROR (ShellConvertStringToUint64 (Temp, &RetVal, TRUE, > TRUE))) { > + EnhancedDump = (UINT16) RetVal; > + } else { > + ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN > (STR_GEN_PARAM_INV_HEX), gShellDebug1HiiHandle, L"pci", Temp); > + ShellStatus = SHELL_INVALID_PARAMETER; > + goto Done; > + } > + } > + > // > // Find the protocol interface who's in charge of current segment, and 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 = 0xFFFF; > - if (ShellCommandLineGetFlag(Package, L"-ec")) { > - Temp = ShellCommandLineGetValue(Package, L"-ec"); > - ASSERT (Temp != NULL); > - EnhancedDump = (UINT16) ShellHexStrToUintn (Temp); > - } > Status = PciExplainData (&ConfigSpace, Address, IoDev, EnhancedDump); > } > } > 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 ^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] ShellPkg/pci: Report error when invalid value is specified for "-ec" 2017-02-10 17:06 ` Carsey, Jaben @ 2017-02-11 4:35 ` Ni, Ruiyu 2017-02-13 16:20 ` Carsey, Jaben 0 siblings, 1 reply; 4+ messages in thread From: Ni, Ruiyu @ 2017-02-11 4:35 UTC (permalink / raw) To: Carsey, Jaben, edk2-devel@lists.01.org Jaben, "-ec" should be followed by a ID. The patch fixes when "-ec" is followed by string other than ID, no error is reported. Regards, Ray >-----Original Message----- >From: Carsey, Jaben >Sent: Saturday, February 11, 2017 1:06 AM >To: Ni, Ruiyu <ruiyu.ni@intel.com>; edk2-devel@lists.01.org >Cc: Carsey, Jaben <jaben.carsey@intel.com> >Subject: RE: [PATCH] ShellPkg/pci: Report error when invalid value is specified for "-ec" > >Reviewed-by: Jaben Carsey <jaben.carsey@intel.com> > >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 <jaben.carsey@intel.com> >> Subject: [PATCH] ShellPkg/pci: Report error when invalid value is specified >> for "-ec" >> Importance: High >> >> Contributed-under: TianoCore Contribution Agreement 1.0 >> Signed-off-by: Ruiyu Ni <ruiyu.ni@intel.com> >> Cc: Jaben Carsey <jaben.carsey@intel.com> >> --- >> ShellPkg/Library/UefiShellDebug1CommandsLib/Pci.c | 21 >> +++++++++++++++------ >> .../UefiShellDebug1CommandsLib.uni | 2 +- >> 2 files changed, 16 insertions(+), 7 deletions(-) >> >> 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 = 0; >> Device = 0; >> Func = 0; >> + EnhancedDump = 0xFFFF; >> if (ShellCommandLineGetFlag(Package, L"-i")) { >> ExplainData = TRUE; >> } >> @@ -2807,6 +2808,20 @@ ShellCommandRunPci ( >> } >> } >> >> + Temp = ShellCommandLineGetValue (Package, L"-ec"); >> + if (Temp != NULL) { >> + // >> + // Input converted to hexadecimal number. >> + // >> + if (!EFI_ERROR (ShellConvertStringToUint64 (Temp, &RetVal, TRUE, >> TRUE))) { >> + EnhancedDump = (UINT16) RetVal; >> + } else { >> + ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN >> (STR_GEN_PARAM_INV_HEX), gShellDebug1HiiHandle, L"pci", Temp); >> + ShellStatus = SHELL_INVALID_PARAMETER; >> + goto Done; >> + } >> + } >> + >> // >> // Find the protocol interface who's in charge of current segment, and 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 = 0xFFFF; >> - if (ShellCommandLineGetFlag(Package, L"-ec")) { >> - Temp = ShellCommandLineGetValue(Package, L"-ec"); >> - ASSERT (Temp != NULL); >> - EnhancedDump = (UINT16) ShellHexStrToUintn (Temp); >> - } >> Status = PciExplainData (&ConfigSpace, Address, IoDev, EnhancedDump); >> } >> } >> 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 ^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] ShellPkg/pci: Report error when invalid value is specified for "-ec" 2017-02-11 4:35 ` Ni, Ruiyu @ 2017-02-13 16:20 ` Carsey, Jaben 0 siblings, 0 replies; 4+ messages in thread From: Carsey, Jaben @ 2017-02-13 16:20 UTC (permalink / raw) To: Ni, Ruiyu, edk2-devel@lists.01.org; +Cc: Carsey, Jaben Ok. That makes sense. > -----Original Message----- > From: Ni, Ruiyu > Sent: Friday, February 10, 2017 8:36 PM > To: Carsey, Jaben <jaben.carsey@intel.com>; edk2-devel@lists.01.org > Subject: RE: [PATCH] ShellPkg/pci: Report error when invalid value is > specified for "-ec" > Importance: High > > Jaben, > "-ec" should be followed by a ID. > > The patch fixes when "-ec" is followed by string other than ID, no error is > reported. > > Regards, > Ray > > >-----Original Message----- > >From: Carsey, Jaben > >Sent: Saturday, February 11, 2017 1:06 AM > >To: Ni, Ruiyu <ruiyu.ni@intel.com>; edk2-devel@lists.01.org > >Cc: Carsey, Jaben <jaben.carsey@intel.com> > >Subject: RE: [PATCH] ShellPkg/pci: Report error when invalid value is > specified for "-ec" > > > >Reviewed-by: Jaben Carsey <jaben.carsey@intel.com> > > > >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 <jaben.carsey@intel.com> > >> Subject: [PATCH] ShellPkg/pci: Report error when invalid value is specified > >> for "-ec" > >> Importance: High > >> > >> Contributed-under: TianoCore Contribution Agreement 1.0 > >> Signed-off-by: Ruiyu Ni <ruiyu.ni@intel.com> > >> Cc: Jaben Carsey <jaben.carsey@intel.com> > >> --- > >> ShellPkg/Library/UefiShellDebug1CommandsLib/Pci.c | 21 > >> +++++++++++++++------ > >> .../UefiShellDebug1CommandsLib.uni | 2 +- > >> 2 files changed, 16 insertions(+), 7 deletions(-) > >> > >> 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 = 0; > >> Device = 0; > >> Func = 0; > >> + EnhancedDump = 0xFFFF; > >> if (ShellCommandLineGetFlag(Package, L"-i")) { > >> ExplainData = TRUE; > >> } > >> @@ -2807,6 +2808,20 @@ ShellCommandRunPci ( > >> } > >> } > >> > >> + Temp = ShellCommandLineGetValue (Package, L"-ec"); > >> + if (Temp != NULL) { > >> + // > >> + // Input converted to hexadecimal number. > >> + // > >> + if (!EFI_ERROR (ShellConvertStringToUint64 (Temp, &RetVal, TRUE, > >> TRUE))) { > >> + EnhancedDump = (UINT16) RetVal; > >> + } else { > >> + ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN > >> (STR_GEN_PARAM_INV_HEX), gShellDebug1HiiHandle, L"pci", Temp); > >> + ShellStatus = SHELL_INVALID_PARAMETER; > >> + goto Done; > >> + } > >> + } > >> + > >> // > >> // Find the protocol interface who's in charge of current segment, and > 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 = 0xFFFF; > >> - if (ShellCommandLineGetFlag(Package, L"-ec")) { > >> - Temp = ShellCommandLineGetValue(Package, L"-ec"); > >> - ASSERT (Temp != NULL); > >> - EnhancedDump = (UINT16) ShellHexStrToUintn (Temp); > >> - } > >> Status = PciExplainData (&ConfigSpace, Address, IoDev, > EnhancedDump); > >> } > >> } > >> 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 ^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2017-02-13 16:20 UTC | newest] Thread overview: 4+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2017-02-10 8:23 [PATCH] ShellPkg/pci: Report error when invalid value is specified for "-ec" Ruiyu Ni 2017-02-10 17:06 ` Carsey, Jaben 2017-02-11 4:35 ` Ni, Ruiyu 2017-02-13 16:20 ` Carsey, Jaben
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox