On 16 September 2015 at 07:51, Qiu Shumin <[email protected]> wrote:
> When execute a command with tailing blank spaces in ShellProtocol.Execute()
> Shell will fail. This patch move the TrimSpaces operation into
> ParseCommandLineToArgs function to fix the problem.
>
> Cc: Ruiyu Ni <[email protected]>
> Cc: Jaben Carsey <[email protected]>
> Contributed-under: TianoCore Contribution Agreement 1.0
> Signed-off-by: Yang Jadis <[email protected]>
> Signed-off-by: Qiu Shumin <[email protected]>
> ---
> ShellPkg/Application/Shell/ShellParametersProtocol.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/ShellPkg/Application/Shell/ShellParametersProtocol.c
> b/ShellPkg/Application/Shell/ShellParametersProtocol.c
> index bc19df7..b404987 100644
> --- a/ShellPkg/Application/Shell/ShellParametersProtocol.c
> +++ b/ShellPkg/Application/Shell/ShellParametersProtocol.c
> @@ -206,6 +206,7 @@ ParseCommandLineToArgs(
> return (EFI_SUCCESS);
> }
>
> + TrimSpaces(&(CHAR16*)CommandLine);
This change breaks the build on GCC with the following error message:
07:05:09
/home/buildslave/workspace/leg-virt-tianocore-edk2-upstream/edk2/ShellPkg/Application/Shell/ShellParametersProtocol.c:209:14:
error: lvalue required as unary '&' operand
07:05:09 TrimSpaces(&(CHAR16*)CommandLine);
The following does work on GCC:
TrimSpaces((CHAR16**)&CommandLine);
HOWEVER, you are casting away constness, so you are breaking the
contract with the callers of ParseCommandLineToArgs() that the first
argument will not be modified.
So I think you need to come up with a better solution.
Thanks,
Ard.
> Size = StrSize(CommandLine);
> TempParameter = AllocateZeroPool(Size);
> if (TempParameter == NULL) {
> @@ -359,7 +360,6 @@ CreatePopulateInstallShellParametersProtocol (
> //
> // Populate Argc and Argv
> //
> - TrimSpaces (&FullCommandLine);
> Status = ParseCommandLineToArgs(FullCommandLine,
> &(*NewShellParameters)->Argv,
> &(*NewShellParameters)->Argc);
> --
> 1.9.5.msysgit.1
>
> _______________________________________________
> edk2-devel mailing list
> [email protected]
> https://lists.01.org/mailman/listinfo/edk2-devel
_______________________________________________
edk2-devel mailing list
[email protected]
https://lists.01.org/mailman/listinfo/edk2-devel