X-Git-Url: https://git.proxmox.com/?p=mirror_edk2.git;a=blobdiff_plain;f=ShellPkg%2FLibrary%2FUefiHandleParsingLib%2FUefiHandleParsingLib.c;h=1049dea0c009bdb628e0032f890f0d6ba03a9d20;hp=e11a3ccceab369bdc59a994f133b6d8316000bb0;hb=d4ec9a5725d67bb1770008513f4c6f1dce2c9b43;hpb=b6c54204617c37e305c4389ece4f7af116485f92
diff --git a/ShellPkg/Library/UefiHandleParsingLib/UefiHandleParsingLib.c b/ShellPkg/Library/UefiHandleParsingLib/UefiHandleParsingLib.c
index e11a3cccea..1049dea0c0 100644
--- a/ShellPkg/Library/UefiHandleParsingLib/UefiHandleParsingLib.c
+++ b/ShellPkg/Library/UefiHandleParsingLib/UefiHandleParsingLib.c
@@ -1,7 +1,7 @@
/** @file
Provides interface to advanced shell functionality for parsing both handle and protocol database.
- Copyright (c) 2010 - 2016, Intel Corporation. All rights reserved.
+ Copyright (c) 2010 - 2017, Intel Corporation. All rights reserved.
(C) Copyright 2013-2015 Hewlett-Packard Development Company, L.P.
(C) Copyright 2015-2016 Hewlett Packard Enterprise Development LP
This program and the accompanying materials
@@ -19,8 +19,8 @@
EFI_HANDLE mHandleParsingHiiHandle = NULL;
HANDLE_INDEX_LIST mHandleList = {{{NULL,NULL},0,0},0};
-GUID_INFO_BLOCK *GuidList;
-UINTN GuidListCount;
+GUID_INFO_BLOCK *mGuidList;
+UINTN mGuidListCount;
/**
Function to translate the EFI_MEMORY_TYPE into a string.
@@ -29,7 +29,6 @@ UINTN GuidListCount;
@retval A string representation of the type allocated from BS Pool.
**/
CHAR16*
-EFIAPI
ConvertMemoryType (
IN CONST EFI_MEMORY_TYPE Memory
)
@@ -66,7 +65,6 @@ ConvertMemoryType (
@retval A string representation of the type allocated from BS Pool.
**/
CHAR16*
-EFIAPI
ConvertPixelFormat (
IN CONST EFI_GRAPHICS_PIXEL_FORMAT Fmt
)
@@ -100,8 +98,8 @@ HandleParsingLibConstructor (
IN EFI_SYSTEM_TABLE *SystemTable
)
{
- GuidListCount = 0;
- GuidList = NULL;
+ mGuidListCount = 0;
+ mGuidList = NULL;
//
// Do nothing with mHandleParsingHiiHandle. Initialize HII as needed.
@@ -139,11 +137,11 @@ HandleParsingLibDestructor (
{
UINTN LoopCount;
- for (LoopCount = 0; GuidList != NULL && LoopCount < GuidListCount; LoopCount++) {
- SHELL_FREE_NON_NULL(GuidList[LoopCount].GuidId);
+ for (LoopCount = 0; mGuidList != NULL && LoopCount < mGuidListCount; LoopCount++) {
+ SHELL_FREE_NON_NULL(mGuidList[LoopCount].GuidId);
}
- SHELL_FREE_NON_NULL(GuidList);
+ SHELL_FREE_NON_NULL(mGuidList);
if (mHandleParsingHiiHandle != NULL) {
HiiRemovePackages(mHandleParsingHiiHandle);
}
@@ -1831,7 +1829,6 @@ STATIC CONST GUID_INFO_BLOCK mGuidStringList[] = {
@return The node.
**/
CONST GUID_INFO_BLOCK *
-EFIAPI
InternalShellGetNodeFromGuid(
IN CONST EFI_GUID* Guid
)
@@ -1841,7 +1838,7 @@ InternalShellGetNodeFromGuid(
ASSERT(Guid != NULL);
- for (LoopCount = 0, ListWalker = GuidList; GuidList != NULL && LoopCount < GuidListCount; LoopCount++, ListWalker++) {
+ for (LoopCount = 0, ListWalker = mGuidList; mGuidList != NULL && LoopCount < mGuidListCount; LoopCount++, ListWalker++) {
if (CompareGuid(ListWalker->GuidId, Guid)) {
return (ListWalker);
}
@@ -1875,7 +1872,6 @@ Function to add a new GUID/Name mapping.
@retval EFI_INVALID_PARAMETER Guid NameId was invalid
**/
EFI_STATUS
-EFIAPI
InsertNewGuidNameMapping(
IN CONST EFI_GUID *Guid,
IN CONST EFI_STRING_ID NameID,
@@ -1885,18 +1881,18 @@ InsertNewGuidNameMapping(
ASSERT(Guid != NULL);
ASSERT(NameID != 0);
- GuidList = ReallocatePool(GuidListCount * sizeof(GUID_INFO_BLOCK), GuidListCount+1 * sizeof(GUID_INFO_BLOCK), GuidList);
- if (GuidList == NULL) {
- GuidListCount = 0;
+ mGuidList = ReallocatePool(mGuidListCount * sizeof(GUID_INFO_BLOCK), mGuidListCount+1 * sizeof(GUID_INFO_BLOCK), mGuidList);
+ if (mGuidList == NULL) {
+ mGuidListCount = 0;
return (EFI_OUT_OF_RESOURCES);
}
- GuidListCount++;
+ mGuidListCount++;
- GuidList[GuidListCount - 1].GuidId = AllocateCopyPool(sizeof(EFI_GUID), Guid);
- GuidList[GuidListCount - 1].StringId = NameID;
- GuidList[GuidListCount - 1].DumpInfo = DumpFunc;
+ mGuidList[mGuidListCount - 1].GuidId = AllocateCopyPool(sizeof(EFI_GUID), Guid);
+ mGuidList[mGuidListCount - 1].StringId = NameID;
+ mGuidList[mGuidListCount - 1].DumpInfo = DumpFunc;
- if (GuidList[GuidListCount - 1].GuidId == NULL) {
+ if (mGuidList[mGuidListCount - 1].GuidId == NULL) {
return (EFI_OUT_OF_RESOURCES);
}
@@ -2065,7 +2061,7 @@ GetGuidFromStringName(
}
}
- for (LoopCount = 0, ListWalker = GuidList; GuidList != NULL && LoopCount < GuidListCount; LoopCount++, ListWalker++) {
+ for (LoopCount = 0, ListWalker = mGuidList; mGuidList != NULL && LoopCount < mGuidListCount; LoopCount++, ListWalker++) {
String = HiiGetString(mHandleParsingHiiHandle, ListWalker->StringId, Lang);
if (Name != NULL && String != NULL && StringNoCaseCompare (&Name, &String) == 0) {
*Guid = ListWalker->GuidId;
@@ -2190,7 +2186,6 @@ GetStringNameFromHandle(
@retval EFI_SUCCESS The operation was successful.
**/
EFI_STATUS
-EFIAPI
InternalShellInitHandleList(
VOID
)
@@ -2802,11 +2797,18 @@ ParseHandleDatabaseForChildControllers(
FreePool (DriverBindingHandleBuffer);
+ if (MatchingHandleBuffer == NULL || *MatchingHandleCount == 0) {
+ //
+ // The caller is not interested in the actual handles, or we've found none.
+ //
+ FreePool (HandleBufferForReturn);
+ HandleBufferForReturn = NULL;
+ }
+
if (MatchingHandleBuffer != NULL) {
*MatchingHandleBuffer = HandleBufferForReturn;
- } else {
- FreePool(HandleBufferForReturn);
}
+
ASSERT ((MatchingHandleBuffer == NULL) ||
(*MatchingHandleCount == 0 && *MatchingHandleBuffer == NULL) ||
(*MatchingHandleCount != 0 && *MatchingHandleBuffer != NULL));
@@ -2830,7 +2832,6 @@ ParseHandleDatabaseForChildControllers(
@return A pointer to (*DestinationBuffer).
**/
VOID*
-EFIAPI
BuffernCatGrow (
IN OUT VOID **DestinationBuffer,
IN OUT UINTN *DestinationSize,