summaryrefslogtreecommitdiff
path: root/MdeModulePkg/Universal/Disk/PartitionDxe
diff options
context:
space:
mode:
authorqianouyang <qianouyang@6f19259b-4bc3-4df7-8a09-765794883524>2011-05-06 07:15:41 +0000
committerqianouyang <qianouyang@6f19259b-4bc3-4df7-8a09-765794883524>2011-05-06 07:15:41 +0000
commitd0844d133bf1b76abfbc83387758fdd01360334b (patch)
tree94185f7359ea077939c486ad48ded5c13ec7666f /MdeModulePkg/Universal/Disk/PartitionDxe
parent58f8069039c9e664cd1826d4ac84e73a755b034b (diff)
downloadedk2-d0844d133bf1b76abfbc83387758fdd01360334b.zip
edk2-d0844d133bf1b76abfbc83387758fdd01360334b.tar.gz
edk2-d0844d133bf1b76abfbc83387758fdd01360334b.tar.bz2
Add Pointer check for NULL before referring it and remove unnecessary pointer check in AtaAtapiPassThru and Partition Drivers.
git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@11627 6f19259b-4bc3-4df7-8a09-765794883524
Diffstat (limited to 'MdeModulePkg/Universal/Disk/PartitionDxe')
-rw-r--r--MdeModulePkg/Universal/Disk/PartitionDxe/Partition.c77
1 files changed, 29 insertions, 48 deletions
diff --git a/MdeModulePkg/Universal/Disk/PartitionDxe/Partition.c b/MdeModulePkg/Universal/Disk/PartitionDxe/Partition.c
index 7d194da..9de8312 100644
--- a/MdeModulePkg/Universal/Disk/PartitionDxe/Partition.c
+++ b/MdeModulePkg/Universal/Disk/PartitionDxe/Partition.c
@@ -457,13 +457,8 @@ PartitionDriverBindingStop (
EFI_OPEN_PROTOCOL_GET_PROTOCOL
);
- if (BlockIo != NULL) {
- Private = PARTITION_DEVICE_FROM_BLOCK_IO_THIS (BlockIo);
- } else if (BlockIo2 != NULL) {
- Private = PARTITION_DEVICE_FROM_BLOCK_IO2_THIS (BlockIo2);
- } else {
- ASSERT (FALSE);
- }
+
+ Private = PARTITION_DEVICE_FROM_BLOCK_IO_THIS (BlockIo);
Status = gBS->CloseProtocol (
ControllerHandle,
@@ -1008,19 +1003,22 @@ PartitionInstallChildHandle (
Private->ParentBlockIo2 = ParentBlockIo2;
Private->DiskIo = ParentDiskIo;
- if (Private->ParentBlockIo != NULL) {
- Private->BlockIo.Revision = ParentBlockIo->Revision;
-
- Private->BlockIo.Media = &Private->Media;
- CopyMem (Private->BlockIo.Media, ParentBlockIo->Media, sizeof (EFI_BLOCK_IO_MEDIA));
-
+ //
+ // Set the BlockIO into Private Data.
+ //
+ Private->BlockIo.Revision = ParentBlockIo->Revision;
+
+ Private->BlockIo.Media = &Private->Media;
+ CopyMem (Private->BlockIo.Media, ParentBlockIo->Media, sizeof (EFI_BLOCK_IO_MEDIA));
- Private->BlockIo.Reset = PartitionReset;
- Private->BlockIo.ReadBlocks = PartitionReadBlocks;
- Private->BlockIo.WriteBlocks = PartitionWriteBlocks;
- Private->BlockIo.FlushBlocks = PartitionFlushBlocks;
- }
+ Private->BlockIo.Reset = PartitionReset;
+ Private->BlockIo.ReadBlocks = PartitionReadBlocks;
+ Private->BlockIo.WriteBlocks = PartitionWriteBlocks;
+ Private->BlockIo.FlushBlocks = PartitionFlushBlocks;
+ //
+ // Set the BlockIO2 into Private Data.
+ //
if (Private->ParentBlockIo2 != NULL) {
Private->BlockIo2.Media = &Private->Media2;
CopyMem (Private->BlockIo2.Media, ParentBlockIo2->Media, sizeof (EFI_BLOCK_IO_MEDIA));
@@ -1036,7 +1034,7 @@ PartitionInstallChildHandle (
Private->Media.LastBlock = DivU64x32 (
MultU64x32 (
End - Start + 1,
- (ParentBlockIo != NULL) ? ParentBlockIo->Media->BlockSize : ParentBlockIo2->Media->BlockSize
+ ParentBlockIo->Media->BlockSize
),
BlockSize
) - 1;
@@ -1085,8 +1083,7 @@ PartitionInstallChildHandle (
// here.
//
Private->Handle = NULL;
- if ((Private->ParentBlockIo != NULL) &&
- (Private->ParentBlockIo2 != NULL) &&
+ if ((Private->ParentBlockIo2 != NULL) &&
(Private->ParentBlockIo2->Media->BlockSize == BlockSize)
) {
Status = gBS->InstallMultipleProtocolInterfaces (
@@ -1101,33 +1098,17 @@ PartitionInstallChildHandle (
NULL,
NULL
);
- } else {
- if (Private->ParentBlockIo != NULL) {
- Status = gBS->InstallMultipleProtocolInterfaces (
- &Private->Handle,
- &gEfiDevicePathProtocolGuid,
- Private->DevicePath,
- &gEfiBlockIoProtocolGuid,
- &Private->BlockIo,
- Private->EspGuid,
- NULL,
- NULL
- );
- }
- if (Private->ParentBlockIo2 != NULL &&
- Private->ParentBlockIo2->Media->BlockSize == BlockSize
- ) {
- Status = gBS->InstallMultipleProtocolInterfaces (
- &Private->Handle,
- &gEfiDevicePathProtocolGuid,
- Private->DevicePath,
- &gEfiBlockIo2ProtocolGuid,
- &Private->BlockIo2,
- Private->EspGuid,
- NULL,
- NULL
- );
- }
+ } else {
+ Status = gBS->InstallMultipleProtocolInterfaces (
+ &Private->Handle,
+ &gEfiDevicePathProtocolGuid,
+ Private->DevicePath,
+ &gEfiBlockIoProtocolGuid,
+ &Private->BlockIo,
+ Private->EspGuid,
+ NULL,
+ NULL
+ );
}
if (!EFI_ERROR (Status)) {