]> git.proxmox.com Git - mirror_edk2.git/commitdiff
remove ASSERT.
authorjcarsey <jcarsey@6f19259b-4bc3-4df7-8a09-765794883524>
Fri, 25 Mar 2011 21:06:23 +0000 (21:06 +0000)
committerjcarsey <jcarsey@6f19259b-4bc3-4df7-8a09-765794883524>
Fri, 25 Mar 2011 21:06:23 +0000 (21:06 +0000)
zero memory allocations.
add support for virtual devices without driver binding.

add #define protection for the header.

git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@11431 6f19259b-4bc3-4df7-8a09-765794883524

ShellPkg/Library/UefiHandleParsingLib/UefiHandleParsingLib.c
ShellPkg/Library/UefiHandleParsingLib/UefiHandleParsingLib.h

index 6b59bfd6ab31da00e3616c275c923a5d1060c69c..012ea39a9ae20aa1de0dbae4dc097cb20d5eab44 100644 (file)
@@ -1,7 +1,7 @@
 /** @file\r
   Provides interface to advanced shell functionality for parsing both handle and protocol database.\r
 \r
-  Copyright (c) 2010, Intel Corporation. All rights reserved.<BR>\r
+  Copyright (c) 2010 - 2011, 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
@@ -265,7 +265,7 @@ DriverEfiVersionProtocolDumpInformation(
 \r
   ASSERT_EFI_ERROR(Status);\r
 \r
-  RetVal = AllocatePool(VersionStringSize);\r
+  RetVal = AllocateZeroPool(VersionStringSize);\r
   ASSERT(RetVal != NULL);\r
   UnicodeSPrint(RetVal, VersionStringSize, L"0x%08x", DriverEfiVersion->FirmwareVersion);\r
   return (RetVal);\r
@@ -306,7 +306,7 @@ DevicePathProtocolDumpInformation(
       gBS->CloseProtocol(TheHandle, &gEfiDevicePathProtocolGuid, gImageHandle, NULL);\r
     }\r
   }\r
-  if (Verbose && Temp != NULL && StrLen(Temp) > 30) {\r
+  if (!Verbose && Temp != NULL && StrLen(Temp) > 30) {\r
     Temp2 = NULL;\r
     Temp2 = StrnCatGrow(&Temp2, NULL, Temp+(StrLen(Temp) - 30), 30);\r
     FreePool(Temp);\r
@@ -680,7 +680,7 @@ InternalShellInitHandleList(
     return (Status);\r
   }\r
   for (mHandleList.NextIndex = 1 ; mHandleList.NextIndex <= HandleCount ; mHandleList.NextIndex++){\r
-    ListWalker = AllocatePool(sizeof(HANDLE_LIST));\r
+    ListWalker = AllocateZeroPool(sizeof(HANDLE_LIST));\r
     ASSERT(ListWalker != NULL);\r
     ListWalker->TheHandle = HandleBuffer[mHandleList.NextIndex-1];\r
     ListWalker->TheIndex  = mHandleList.NextIndex;\r
@@ -708,7 +708,9 @@ ConvertHandleToHandleIndex(
   )\r
 {\r
   HANDLE_LIST *ListWalker;\r
-  ASSERT(TheHandle!=NULL);\r
+  if (TheHandle == NULL) {\r
+    return 0;\r
+  }\r
 \r
   InternalShellInitHandleList();\r
 \r
@@ -720,7 +722,7 @@ ConvertHandleToHandleIndex(
       return (ListWalker->TheIndex);\r
     }\r
   }\r
-  ListWalker = AllocatePool(sizeof(HANDLE_LIST));\r
+  ListWalker = AllocateZeroPool(sizeof(HANDLE_LIST));\r
   ASSERT(ListWalker != NULL);\r
   ListWalker->TheHandle = TheHandle;\r
   ListWalker->TheIndex  = mHandleList.NextIndex++;\r
@@ -1038,7 +1040,7 @@ ParseHandleDatabaseByRelationship (
         //\r
         // Allocate a handle buffer for the number of handles that matched the attributes in Mask\r
         //\r
-        *MatchingHandleBuffer = AllocatePool ((*MatchingHandleCount +1)* sizeof (EFI_HANDLE));\r
+        *MatchingHandleBuffer = AllocateZeroPool ((*MatchingHandleCount +1)* sizeof (EFI_HANDLE));\r
         ASSERT(*MatchingHandleBuffer != NULL);\r
 \r
         for (HandleIndex = 0,*MatchingHandleCount = 0\r
@@ -1095,14 +1097,14 @@ ParseHandleDatabaseForChildControllers(
   )\r
 {\r
   EFI_STATUS  Status;\r
-  UINTN       HandleIndex;\r
+//  UINTN       HandleIndex;\r
   UINTN       DriverBindingHandleCount;\r
   EFI_HANDLE  *DriverBindingHandleBuffer;\r
   UINTN       DriverBindingHandleIndex;\r
   UINTN       ChildControllerHandleCount;\r
   EFI_HANDLE  *ChildControllerHandleBuffer;\r
   UINTN       ChildControllerHandleIndex;\r
-  BOOLEAN     Found;\r
+//  BOOLEAN     Found;\r
   EFI_HANDLE  *HandleBufferForReturn;\r
 \r
   if (MatchingHandleCount == NULL) {\r
@@ -1143,17 +1145,18 @@ ParseHandleDatabaseForChildControllers(
          ChildControllerHandleIndex < ChildControllerHandleCount;\r
          ChildControllerHandleIndex++\r
        ) {\r
-      Found = FALSE;\r
-      for (HandleIndex = 0; HandleBufferForReturn[HandleIndex] != NULL; HandleIndex++) {\r
-        if (HandleBufferForReturn[HandleIndex] == ChildControllerHandleBuffer[ChildControllerHandleIndex]) {\r
-          Found = TRUE;\r
-          break;\r
-        }\r
-      }\r
-\r
-      if (!Found) {\r
-        HandleBufferForReturn[(*MatchingHandleCount)++] = ChildControllerHandleBuffer[ChildControllerHandleIndex];\r
-      }\r
+//      Found = FALSE;\r
+      HandleBufferForReturn[(*MatchingHandleCount)++] = ChildControllerHandleBuffer[ChildControllerHandleIndex];\r
+//      for (HandleIndex = 0; HandleBufferForReturn[HandleIndex] != NULL; HandleIndex++) {\r
+//        if (HandleBufferForReturn[HandleIndex] == ChildControllerHandleBuffer[ChildControllerHandleIndex]) {\r
+//          Found = TRUE;\r
+//          break;\r
+//        }\r
+//      }\r
+\r
+//      if (Found) {\r
+//        HandleBufferForReturn[(*MatchingHandleCount)++] = ChildControllerHandleBuffer[ChildControllerHandleIndex];\r
+//      }\r
     }\r
 \r
     FreePool (ChildControllerHandleBuffer);\r
@@ -1217,7 +1220,7 @@ BuffernCatGrow (
 \r
   if (LocalDestinationSize == 0) {\r
     // allcoate\r
-    *DestinationBuffer = AllocatePool(LocalDestinationFinalSize);\r
+    *DestinationBuffer = AllocateZeroPool(LocalDestinationFinalSize);\r
   } else {\r
     // reallocate\r
     *DestinationBuffer = ReallocatePool(LocalDestinationSize, LocalDestinationFinalSize, *DestinationBuffer);\r
@@ -1333,7 +1336,7 @@ GetHandleListByProtocol (
   if (ProtocolGuid == NULL) {\r
     Status = gBS->LocateHandle(AllHandles, NULL, NULL, &Size, HandleList);\r
     if (Status == EFI_BUFFER_TOO_SMALL) {\r
-      HandleList = AllocatePool(Size + sizeof(EFI_HANDLE));\r
+      HandleList = AllocateZeroPool(Size + sizeof(EFI_HANDLE));\r
       if (HandleList == NULL) {\r
         return (NULL);\r
       }\r
@@ -1343,7 +1346,7 @@ GetHandleListByProtocol (
   } else {\r
     Status = gBS->LocateHandle(ByProtocol, (EFI_GUID*)ProtocolGuid, NULL, &Size, HandleList);\r
     if (Status == EFI_BUFFER_TOO_SMALL) {\r
-      HandleList = AllocatePool(Size + sizeof(EFI_HANDLE));\r
+      HandleList = AllocateZeroPool(Size + sizeof(EFI_HANDLE));\r
       if (HandleList == NULL) {\r
         return (NULL);\r
       }\r
index 3cf9320c117e1b1c69ceb2828e1e5e14bf22760e..d519c1d400fc3956a79c2a975e3a7ecc2b0eead4 100644 (file)
@@ -1,7 +1,7 @@
 /** @file\r
   Provides interface to advanced shell functionality for parsing both handle and protocol database.\r
 \r
-  Copyright (c) 2010, Intel Corporation. All rights reserved.<BR>\r
+  Copyright (c) 2011, 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
@@ -12,6 +12,9 @@
 \r
 **/\r
 \r
+#if !defined (_UEFI_HANDLE_PARSING_LIB_INTERNAL_H_)\r
+#define _UEFI_HANDLE_PARSING_LIB_INTERNAL_H_\r
+\r
 #include <Uefi.h>\r
 \r
 #include <Guid/FileInfo.h>\r
@@ -139,3 +142,5 @@ typedef struct {
   DUMP_PROTOCOL_INFO            DumpInfo;\r
 } PROTOCOL_INFO_BLOCK;\r
 \r
+#endif\r
+\r