\r
(C) Copyright 2016 Hewlett Packard Enterprise Development LP<BR>\r
Copyright 2016 Dell Inc.\r
- Copyright (c) 2006 - 2017, Intel Corporation. All rights reserved.<BR>\r
+ Copyright (c) 2006 - 2018, 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
{\r
EFI_STATUS Status;\r
\r
- //\r
- // UEFI 2.0 shell interfaces (used preferentially)\r
- //\r
- Status = gBS->OpenProtocol(\r
- ImageHandle,\r
- &gEfiShellProtocolGuid,\r
- (VOID **)&gEfiShellProtocol,\r
- ImageHandle,\r
- NULL,\r
- EFI_OPEN_PROTOCOL_GET_PROTOCOL\r
- );\r
- if (EFI_ERROR(Status)) {\r
+ if (gEfiShellProtocol == NULL) {\r
//\r
- // Search for the shell protocol\r
+ // UEFI 2.0 shell interfaces (used preferentially)\r
//\r
- Status = gBS->LocateProtocol(\r
+ Status = gBS->OpenProtocol (\r
+ ImageHandle,\r
&gEfiShellProtocolGuid,\r
+ (VOID **)&gEfiShellProtocol,\r
+ ImageHandle,\r
NULL,\r
- (VOID **)&gEfiShellProtocol\r
- );\r
- if (EFI_ERROR(Status)) {\r
- gEfiShellProtocol = NULL;\r
+ EFI_OPEN_PROTOCOL_GET_PROTOCOL\r
+ );\r
+ if (EFI_ERROR (Status)) {\r
+ //\r
+ // Search for the shell protocol\r
+ //\r
+ Status = gBS->LocateProtocol (\r
+ &gEfiShellProtocolGuid,\r
+ NULL,\r
+ (VOID **)&gEfiShellProtocol\r
+ );\r
+ if (EFI_ERROR (Status)) {\r
+ gEfiShellProtocol = NULL;\r
+ }\r
}\r
}\r
- Status = gBS->OpenProtocol(\r
- ImageHandle,\r
- &gEfiShellParametersProtocolGuid,\r
- (VOID **)&gEfiShellParametersProtocol,\r
- ImageHandle,\r
- NULL,\r
- EFI_OPEN_PROTOCOL_GET_PROTOCOL\r
- );\r
- if (EFI_ERROR(Status)) {\r
- gEfiShellParametersProtocol = NULL;\r
+\r
+ if (gEfiShellParametersProtocol == NULL) {\r
+ Status = gBS->OpenProtocol (\r
+ ImageHandle,\r
+ &gEfiShellParametersProtocolGuid,\r
+ (VOID **)&gEfiShellParametersProtocol,\r
+ ImageHandle,\r
+ NULL,\r
+ EFI_OPEN_PROTOCOL_GET_PROTOCOL\r
+ );\r
+ if (EFI_ERROR (Status)) {\r
+ gEfiShellParametersProtocol = NULL;\r
+ }\r
}\r
\r
if (gEfiShellProtocol == NULL) {\r
IN EFI_SYSTEM_TABLE *SystemTable\r
)\r
{\r
+ EFI_STATUS Status;\r
+\r
if (mEfiShellEnvironment2 != NULL) {\r
- gBS->CloseProtocol(mEfiShellEnvironment2Handle==NULL?ImageHandle:mEfiShellEnvironment2Handle,\r
+ Status = gBS->CloseProtocol(mEfiShellEnvironment2Handle==NULL?ImageHandle:mEfiShellEnvironment2Handle,\r
&gEfiShellEnvironment2Guid,\r
ImageHandle,\r
NULL);\r
- mEfiShellEnvironment2 = NULL;\r
+ if (!EFI_ERROR (Status)) {\r
+ mEfiShellEnvironment2 = NULL;\r
+ mEfiShellEnvironment2Handle = NULL;\r
+ }\r
}\r
if (mEfiShellInterface != NULL) {\r
- gBS->CloseProtocol(ImageHandle,\r
+ Status = gBS->CloseProtocol(ImageHandle,\r
&gEfiShellInterfaceGuid,\r
ImageHandle,\r
NULL);\r
- mEfiShellInterface = NULL;\r
+ if (!EFI_ERROR (Status)) {\r
+ mEfiShellInterface = NULL;\r
+ }\r
}\r
if (gEfiShellProtocol != NULL) {\r
- gBS->CloseProtocol(ImageHandle,\r
+ Status = gBS->CloseProtocol(ImageHandle,\r
&gEfiShellProtocolGuid,\r
ImageHandle,\r
NULL);\r
- gEfiShellProtocol = NULL;\r
+ if (!EFI_ERROR (Status)) {\r
+ gEfiShellProtocol = NULL;\r
+ }\r
}\r
if (gEfiShellParametersProtocol != NULL) {\r
- gBS->CloseProtocol(ImageHandle,\r
+ Status = gBS->CloseProtocol(ImageHandle,\r
&gEfiShellParametersProtocolGuid,\r
ImageHandle,\r
NULL);\r
- gEfiShellParametersProtocol = NULL;\r
+ if (!EFI_ERROR (Status)) {\r
+ gEfiShellParametersProtocol = NULL;\r
+ }\r
}\r
- mEfiShellEnvironment2Handle = NULL;\r
\r
return (EFI_SUCCESS);\r
}\r
)\r
{\r
BOOLEAN Hex;\r
+ BOOLEAN LeadingZero;\r
+\r
+ if (String == NULL) {\r
+ return FALSE;\r
+ }\r
\r
//\r
// chop off a single negative sign\r
//\r
- if (String != NULL && *String == L'-') {\r
+ if (*String == L'-') {\r
String++;\r
}\r
\r
- if (String == NULL) {\r
- return (FALSE);\r
+ if (*String == CHAR_NULL) {\r
+ return FALSE;\r
}\r
\r
//\r
// chop leading zeroes\r
//\r
- while(String != NULL && *String == L'0'){\r
+ LeadingZero = FALSE;\r
+ while(*String == L'0'){\r
String++;\r
+ LeadingZero = TRUE;\r
}\r
//\r
// allow '0x' or '0X', but not 'x' or 'X'\r
//\r
- if (String != NULL && (*String == L'x' || *String == L'X')) {\r
- if (*(String-1) != L'0') {\r
+ if (*String == L'x' || *String == L'X') {\r
+ if (!LeadingZero) {\r
//\r
// we got an x without a preceeding 0\r
//\r
//\r
// loop through the remaining characters and use the lib function\r
//\r
- for ( ; String != NULL && *String != CHAR_NULL && !(StopAtSpace && *String == L' ') ; String++){\r
+ for ( ; *String != CHAR_NULL && !(StopAtSpace && *String == L' ') ; String++){\r
if (TimeNumbers && (String[0] == L':')) {\r
continue;\r
}\r