diff options
author | Ruiyu Ni <ruiyu.ni@intel.com> | 2016-07-22 10:09:53 +0800 |
---|---|---|
committer | Ruiyu Ni <ruiyu.ni@intel.com> | 2016-07-25 10:20:13 +0800 |
commit | 94fcb76b61f180b1ebe2fa3b3b26138c733c4d45 (patch) | |
tree | 09ceb4ed4d6d4f9cb38181cffcf29ba744c424fd | |
parent | 51686a7a294191a5ea87dc89b3167b01297ee6b0 (diff) | |
download | edk2-platforms-94fcb76b61f180b1ebe2fa3b3b26138c733c4d45.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>
-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);
}
|