summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRuiyu Ni <ruiyu.ni@intel.com>2016-07-22 10:09:53 +0800
committerHao Wu <hao.a.wu@intel.com>2016-07-25 11:05:52 +0800
commitb931eaab2c3244e249899ac5ac154ae3ccdc826a (patch)
tree8247a35fd9a36b9ea2bac04742e8bb1c1cee0e73
parent4f4d9290931df6c7fc37bc186deedc298c349e52 (diff)
downloadedk2-platforms-b931eaab2c3244e249899ac5ac154ae3ccdc826a.tar.xz
ShellPkg/UefiHandleParsingLib: Fix issue to pass static code checker
Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Ruiyu Ni <ruiyu.ni@intel.com> Reviewed-by: Jaben Carsey <jaben.carsey@intel.com> Reviewed-by: Hao A Wu <hao.a.wu@intel.com> (cherry picked from commit 94fcb76b61f180b1ebe2fa3b3b26138c733c4d45)
-rw-r--r--ShellPkg/Library/UefiHandleParsingLib/UefiHandleParsingLib.c13
1 files changed, 11 insertions, 2 deletions
diff --git a/ShellPkg/Library/UefiHandleParsingLib/UefiHandleParsingLib.c b/ShellPkg/Library/UefiHandleParsingLib/UefiHandleParsingLib.c
index c909395531..3fb55df8cc 100644
--- a/ShellPkg/Library/UefiHandleParsingLib/UefiHandleParsingLib.c
+++ b/ShellPkg/Library/UefiHandleParsingLib/UefiHandleParsingLib.c
@@ -2421,6 +2421,7 @@ ParseHandleDatabaseByRelationshipWithType (
*HandleType = AllocateZeroPool (*HandleCount * sizeof (UINTN));
if (*HandleType == NULL) {
SHELL_FREE_NON_NULL (*HandleBuffer);
+ *HandleCount = 0;
return EFI_OUT_OF_RESOURCES;
}
@@ -2678,7 +2679,9 @@ ParseHandleDatabaseByRelationship (
// Allocate a handle buffer for the number of handles that matched the attributes in Mask
//
*MatchingHandleBuffer = AllocateZeroPool ((*MatchingHandleCount +1)* sizeof (EFI_HANDLE));
- if (*MatchingHandleBuffer != NULL) {
+ if (*MatchingHandleBuffer == NULL) {
+ Status = EFI_OUT_OF_RESOURCES;
+ } else {
for (HandleIndex = 0, *MatchingHandleCount = 0
; HandleIndex < HandleCount
; HandleIndex++
@@ -2697,7 +2700,7 @@ ParseHandleDatabaseByRelationship (
(*MatchingHandleBuffer)[*MatchingHandleCount] = NULL;
Status = EFI_SUCCESS;
- } // *MatchingHandleBuffer != NULL (IF)
+ } // *MatchingHandleBuffer == NULL (ELSE)
} // MacthingHandleBuffer == NULL (ELSE)
} // *MatchingHandleCount == 0 (ELSE)
} // no error on ParseHandleDatabaseByRelationshipWithType
@@ -2710,6 +2713,9 @@ ParseHandleDatabaseByRelationship (
FreePool (HandleType);
}
+ ASSERT ((MatchingHandleBuffer == NULL) ||
+ (*MatchingHandleCount == 0 && *MatchingHandleBuffer == NULL) ||
+ (*MatchingHandleCount != 0 && *MatchingHandleBuffer != NULL));
return Status;
}
@@ -2801,6 +2807,9 @@ ParseHandleDatabaseForChildControllers(
} else {
FreePool(HandleBufferForReturn);
}
+ ASSERT ((MatchingHandleBuffer == NULL) ||
+ (*MatchingHandleCount == 0 && *MatchingHandleBuffer == NULL) ||
+ (*MatchingHandleCount != 0 && *MatchingHandleBuffer != NULL));
return (EFI_SUCCESS);
}