Re: [edk2] [PATCH v2 1/2] ShellPkg/UefiDpLib: Refine the code of locating all handles in DpTrace.c.

2016-02-17 Thread Zeng, Star

On 2016/2/15 17:49, Zeng, Star wrote:

On 2016/2/15 17:07, Cinnamon Shia wrote:

Replace gBS->LocateHandle with gBS->LocateHandleBuffer

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Cinnamon Shia 
---
  ShellPkg/Library/UefiDpLib/DpTrace.c | 40

  1 file changed, 9 insertions(+), 31 deletions(-)


Reviewed-by: Star Zeng 


Committed at 64c51ed181545f2c9914ad49c8dcbabe2f9a32e2.





diff --git a/ShellPkg/Library/UefiDpLib/DpTrace.c
b/ShellPkg/Library/UefiDpLib/DpTrace.c
index d17d514..22b83d0 100644
--- a/ShellPkg/Library/UefiDpLib/DpTrace.c
+++ b/ShellPkg/Library/UefiDpLib/DpTrace.c
@@ -2,7 +2,7 @@
Trace reporting for the Dp utility.

Copyright (c) 2009 - 2013, Intel Corporation. All rights reserved.
-  (C) Copyright 2015 Hewlett Packard Enterprise Development LP
+  (C) Copyright 2015-2016 Hewlett Packard Enterprise Development LP
This program and the accompanying materials
are licensed and made available under the terms and conditions of
the BSD License
which accompanies this distribution.  The full text of the license
may be found at
@@ -153,8 +153,7 @@ DumpAllTrace(
UINTN TIndex;

EFI_HANDLE*HandleBuffer;
-  UINTN Size;
-  EFI_HANDLETempHandle;
+  UINTN HandleCount;
EFI_STATUSStatus;
EFI_STRINGStringPtrUnknown;

@@ -166,17 +165,7 @@ DumpAllTrace(

// Get Handle information
//
-  Size = 0;
-  HandleBuffer = 
-  Status  = gBS->LocateHandle (AllHandles, NULL, NULL, ,
);
-  if (Status == EFI_BUFFER_TOO_SMALL) {
-HandleBuffer = AllocatePool (Size);
-ASSERT (HandleBuffer != NULL);
-if (HandleBuffer == NULL) {
-  return;
-}
-Status  = gBS->LocateHandle (AllHandles, NULL, NULL, ,
HandleBuffer);
-  }
+  Status  = gBS->LocateHandleBuffer (AllHandles, NULL, NULL,
, );
if (EFI_ERROR (Status)) {
  ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN
(STR_DP_HANDLES_ERROR), gDpHiiHandle, Status);
}
@@ -232,7 +221,7 @@ DumpAllTrace(
AsciiStrToUnicodeStr (Measurement.Token, mUnicodeToken);
if (Measurement.Handle != NULL) {
  // See if the Handle is in the HandleBuffer
-for (TIndex = 0; TIndex < (Size / sizeof(HandleBuffer[0]));
TIndex++) {
+for (TIndex = 0; TIndex < HandleCount; TIndex++) {
if (Measurement.Handle == HandleBuffer[TIndex]) {
  DpGetNameFromHandle (HandleBuffer[TIndex]);
  break;
@@ -270,7 +259,7 @@ DumpAllTrace(
}
  }
}
-  if (HandleBuffer != ) {
+  if (HandleBuffer != NULL) {
  FreePool (HandleBuffer);
}
SHELL_FREE_NON_NULL (IncFlag);
@@ -536,8 +525,7 @@ ProcessHandles(
UINTN Index;
UINTN LogEntryKey;
UINTN Count;
-  UINTN Size;
-  EFI_HANDLETempHandle;
+  UINTN HandleCount;
EFI_STATUSStatus;
EFI_STRINGStringPtrUnknown;

@@ -548,17 +536,7 @@ ProcessHandles(
FreePool (StringPtr);
FreePool (StringPtrUnknown);

-  Size = 0;
-  HandleBuffer = 
-  Status  = gBS->LocateHandle (AllHandles, NULL, NULL, ,
);
-  if (Status == EFI_BUFFER_TOO_SMALL) {
-HandleBuffer = AllocatePool (Size);
-ASSERT (HandleBuffer != NULL);
-if (HandleBuffer == NULL) {
-  return Status;
-}
-Status  = gBS->LocateHandle (AllHandles, NULL, NULL, ,
HandleBuffer);
-  }
+  Status = gBS->LocateHandleBuffer (AllHandles, NULL, NULL,
, );
if (EFI_ERROR (Status)) {
  ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN
(STR_DP_HANDLES_ERROR), gDpHiiHandle, Status);
}
@@ -598,7 +576,7 @@ ProcessHandles(
mGaugeString[0] = 0;// Empty driver name by default
AsciiStrToUnicodeStr (Measurement.Token, mUnicodeToken);
// See if the Handle is in the HandleBuffer
-  for (Index = 0; Index < (Size / sizeof(HandleBuffer[0]));
Index++) {
+  for (Index = 0; Index < HandleCount; Index++) {
  if (Measurement.Handle == HandleBuffer[Index]) {
DpGetNameFromHandle (HandleBuffer[Index]); // Name is put
into mGaugeString
break;
@@ -630,7 +608,7 @@ ProcessHandles(
}
  }
}
-  if (HandleBuffer != ) {
+  if (HandleBuffer != NULL) {
  FreePool (HandleBuffer);
}
return Status;



___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


Re: [edk2] [PATCH v2 1/2] ShellPkg/UefiDpLib: Refine the code of locating all handles in DpTrace.c.

2016-02-16 Thread El-Haj-Mahmoud, Samer
Series Reviewed -By: Samer El-Haj-Mahmoud 



-Original Message-
From: Shia, Cinnamon 
Sent: Monday, February 15, 2016 3:07 AM
To: edk2-devel@lists.01.org
Cc: El-Haj-Mahmoud, Samer ; Shia, Cinnamon 

Subject: [PATCH v2 1/2] ShellPkg/UefiDpLib: Refine the code of locating all 
handles in DpTrace.c.

Replace gBS->LocateHandle with gBS->LocateHandleBuffer

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Cinnamon Shia 
---
 ShellPkg/Library/UefiDpLib/DpTrace.c | 40 
 1 file changed, 9 insertions(+), 31 deletions(-)

diff --git a/ShellPkg/Library/UefiDpLib/DpTrace.c 
b/ShellPkg/Library/UefiDpLib/DpTrace.c
index d17d514..22b83d0 100644
--- a/ShellPkg/Library/UefiDpLib/DpTrace.c
+++ b/ShellPkg/Library/UefiDpLib/DpTrace.c
@@ -2,7 +2,7 @@
   Trace reporting for the Dp utility.
 
   Copyright (c) 2009 - 2013, Intel Corporation. All rights reserved.
-  (C) Copyright 2015 Hewlett Packard Enterprise Development LP
+  (C) Copyright 2015-2016 Hewlett Packard Enterprise Development LP
   This program and the accompanying materials
   are licensed and made available under the terms and conditions of the BSD 
License
   which accompanies this distribution.  The full text of the license may be 
found at @@ -153,8 +153,7 @@ DumpAllTrace(
   UINTN TIndex;
 
   EFI_HANDLE*HandleBuffer;
-  UINTN Size;
-  EFI_HANDLETempHandle;
+  UINTN HandleCount;
   EFI_STATUSStatus;
   EFI_STRINGStringPtrUnknown;
 
@@ -166,17 +165,7 @@ DumpAllTrace(
 
   // Get Handle information
   //
-  Size = 0;
-  HandleBuffer = 
-  Status  = gBS->LocateHandle (AllHandles, NULL, NULL, , );
-  if (Status == EFI_BUFFER_TOO_SMALL) {
-HandleBuffer = AllocatePool (Size);
-ASSERT (HandleBuffer != NULL);
-if (HandleBuffer == NULL) {
-  return;
-}
-Status  = gBS->LocateHandle (AllHandles, NULL, NULL, , HandleBuffer);
-  }
+  Status  = gBS->LocateHandleBuffer (AllHandles, NULL, NULL, 
+ , );
   if (EFI_ERROR (Status)) {
 ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_HANDLES_ERROR), 
gDpHiiHandle, Status);
   }
@@ -232,7 +221,7 @@ DumpAllTrace(
   AsciiStrToUnicodeStr (Measurement.Token, mUnicodeToken);
   if (Measurement.Handle != NULL) {
 // See if the Handle is in the HandleBuffer
-for (TIndex = 0; TIndex < (Size / sizeof(HandleBuffer[0])); TIndex++) {
+for (TIndex = 0; TIndex < HandleCount; TIndex++) {
   if (Measurement.Handle == HandleBuffer[TIndex]) {
 DpGetNameFromHandle (HandleBuffer[TIndex]);
 break;
@@ -270,7 +259,7 @@ DumpAllTrace(
   }
 }
   }
-  if (HandleBuffer != ) {
+  if (HandleBuffer != NULL) {
 FreePool (HandleBuffer);
   }
   SHELL_FREE_NON_NULL (IncFlag);
@@ -536,8 +525,7 @@ ProcessHandles(
   UINTN Index;
   UINTN LogEntryKey;
   UINTN Count;
-  UINTN Size;
-  EFI_HANDLETempHandle;
+  UINTN HandleCount;
   EFI_STATUSStatus;
   EFI_STRINGStringPtrUnknown;
 
@@ -548,17 +536,7 @@ ProcessHandles(
   FreePool (StringPtr);
   FreePool (StringPtrUnknown);
 
-  Size = 0;
-  HandleBuffer = 
-  Status  = gBS->LocateHandle (AllHandles, NULL, NULL, , );
-  if (Status == EFI_BUFFER_TOO_SMALL) {
-HandleBuffer = AllocatePool (Size);
-ASSERT (HandleBuffer != NULL);
-if (HandleBuffer == NULL) {
-  return Status;
-}
-Status  = gBS->LocateHandle (AllHandles, NULL, NULL, , HandleBuffer);
-  }
+  Status = gBS->LocateHandleBuffer (AllHandles, NULL, NULL, 
+ , );
   if (EFI_ERROR (Status)) {
 ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_HANDLES_ERROR), 
gDpHiiHandle, Status);
   }
@@ -598,7 +576,7 @@ ProcessHandles(
   mGaugeString[0] = 0;// Empty driver name by default
   AsciiStrToUnicodeStr (Measurement.Token, mUnicodeToken);
   // See if the Handle is in the HandleBuffer
-  for (Index = 0; Index < (Size / sizeof(HandleBuffer[0])); Index++) {
+  for (Index = 0; Index < HandleCount; Index++) {
 if (Measurement.Handle == HandleBuffer[Index]) {
   DpGetNameFromHandle (HandleBuffer[Index]); // Name is put into 
mGaugeString
   break;
@@ -630,7 +608,7 @@ ProcessHandles(
   }
 }
   }
-  if (HandleBuffer != ) {
+  if (HandleBuffer != NULL) {
 FreePool (HandleBuffer);
   }
   return Status;
--
2.7.0.windows.2

___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel