diff options
author | Ruiyu Ni <ruiyu.ni@intel.com> | 2016-07-22 10:09:53 +0800 |
---|---|---|
committer | Hao Wu <hao.a.wu@intel.com> | 2016-07-25 11:05:52 +0800 |
commit | b931eaab2c3244e249899ac5ac154ae3ccdc826a (patch) | |
tree | 8247a35fd9a36b9ea2bac04742e8bb1c1cee0e73 /ShellPkg/Library/UefiHandleParsingLib | |
parent | 4f4d9290931df6c7fc37bc186deedc298c349e52 (diff) | |
download | edk2-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)
Diffstat (limited to 'ShellPkg/Library/UefiHandleParsingLib')
-rw-r--r-- | ShellPkg/Library/UefiHandleParsingLib/UefiHandleParsingLib.c | 13 |
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);
}
|