summaryrefslogtreecommitdiffstats
path: root/MdeModulePkg/Bus/Usb/UsbBusDxe/UsbEnumer.c
diff options
context:
space:
mode:
authoreric_tian <eric_tian@6f19259b-4bc3-4df7-8a09-765794883524>2009-02-12 06:23:15 +0000
committereric_tian <eric_tian@6f19259b-4bc3-4df7-8a09-765794883524>2009-02-12 06:23:15 +0000
commita1b749d074ef44e758458cf16e460dd74e3df123 (patch)
treee0654e3426693ad0e454acb4523f799f29fb99c1 /MdeModulePkg/Bus/Usb/UsbBusDxe/UsbEnumer.c
parentc55426ab649d280658753d36bcad712361d65ccd (diff)
downloadedk2-a1b749d074ef44e758458cf16e460dd74e3df123.tar.gz
edk2-a1b749d074ef44e758458cf16e460dd74e3df123.tar.bz2
edk2-a1b749d074ef44e758458cf16e460dd74e3df123.zip
add assert logic to avoid Klocwork fake report
git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@7511 6f19259b-4bc3-4df7-8a09-765794883524
Diffstat (limited to 'MdeModulePkg/Bus/Usb/UsbBusDxe/UsbEnumer.c')
-rw-r--r--MdeModulePkg/Bus/Usb/UsbBusDxe/UsbEnumer.c18
1 files changed, 12 insertions, 6 deletions
diff --git a/MdeModulePkg/Bus/Usb/UsbBusDxe/UsbEnumer.c b/MdeModulePkg/Bus/Usb/UsbBusDxe/UsbEnumer.c
index 4c2e5ffa65..0577167816 100644
--- a/MdeModulePkg/Bus/Usb/UsbBusDxe/UsbEnumer.c
+++ b/MdeModulePkg/Bus/Usb/UsbBusDxe/UsbEnumer.c
@@ -109,6 +109,7 @@ UsbCreateInterface (
UsbIf->Signature = USB_INTERFACE_SIGNATURE;
UsbIf->Device = Device;
UsbIf->IfDesc = IfDesc;
+ ASSERT (IfDesc->ActiveIndex < USB_MAX_INTERFACE_SETTING);
UsbIf->IfSetting = IfDesc->Settings[IfDesc->ActiveIndex];
CopyMem (
@@ -279,7 +280,7 @@ UsbConnectDriver (
//
if (UsbBusIsWantedUsbIO (UsbIf->Device->Bus, UsbIf)) {
OldTpl = UsbGetCurrentTpl ();
- DEBUG ((EFI_D_INFO, "UsbConnectDriver: TPL before connect is %d\n", (UINT32)OldTpl));
+ DEBUG ((EFI_D_INFO, "UsbConnectDriver: TPL before connect is %d, %p\n", (UINT32)OldTpl, UsbIf->Handle));
gBS->RestoreTPL (TPL_CALLBACK);
@@ -325,6 +326,7 @@ UsbSelectSetting (
Setting = NULL;
for (Index = 0; Index < IfDesc->NumOfSetting; Index++) {
+ ASSERT (Index < USB_MAX_INTERFACE_SETTING);
Setting = IfDesc->Settings[Index];
if (Setting->Desc.AlternateSetting == Alternate) {
@@ -420,6 +422,7 @@ UsbSelectConfig (
return EFI_OUT_OF_RESOURCES;
}
+ ASSERT (Index < USB_MAX_INTERFACE);
Device->Interfaces[Index] = UsbIf;
//
@@ -452,6 +455,7 @@ UsbDisconnectDriver (
)
{
EFI_TPL OldTpl;
+ EFI_STATUS Status;
//
// Release the hub if it's a hub controller, otherwise
@@ -469,14 +473,14 @@ UsbDisconnectDriver (
// or disconnect at CALLBACK.
//
OldTpl = UsbGetCurrentTpl ();
- DEBUG ((EFI_D_INFO, "UsbDisconnectDriver: old TPL is %d\n", (UINT32)OldTpl));
+ DEBUG ((EFI_D_INFO, "UsbDisconnectDriver: old TPL is %d, %p\n", (UINT32)OldTpl, UsbIf->Handle));
gBS->RestoreTPL (TPL_CALLBACK);
- gBS->DisconnectController (UsbIf->Handle, NULL, NULL);
+ Status = gBS->DisconnectController (UsbIf->Handle, NULL, NULL);
UsbIf->IsManaged = FALSE;
- DEBUG (( EFI_D_INFO, "UsbDisconnectDriver: TPL after disconnect is %d\n", (UINT32)UsbGetCurrentTpl()));
+ DEBUG (( EFI_D_INFO, "UsbDisconnectDriver: TPL after disconnect is %d, %d\n", (UINT32)UsbGetCurrentTpl(), Status));
ASSERT (UsbGetCurrentTpl () == TPL_CALLBACK);
gBS->RaiseTPL (OldTpl);
@@ -501,7 +505,8 @@ UsbRemoveConfig (
//
// Remove each interface of the device
//
- for (Index = 0; Index < Device->NumOfInterface; Index++) {
+ for (Index = 0; Index < Device->NumOfInterface; Index++) {
+ ASSERT (Index < USB_MAX_INTERFACE);
UsbIf = Device->Interfaces[Index];
if (UsbIf == NULL) {
@@ -561,6 +566,7 @@ UsbRemoveDevice (
DEBUG (( EFI_D_INFO, "UsbRemoveDevice: device %d removed\n", Device->Address));
+ ASSERT (Device->Address < USB_MAX_DEVICES);
Bus->Devices[Device->Address] = NULL;
UsbFreeDevice (Device);
@@ -900,7 +906,7 @@ UsbEnumeratePort (
Child = UsbFindChild (HubIf, Port);
if (Child != NULL) {
- DEBUG (( EFI_D_INFO, "UsbEnumeratePort: device at port %d removed from system\n", Port));
+ DEBUG (( EFI_D_INFO, "UsbEnumeratePort: device at port %d removed from root hub %p\n", Port, HubIf));
UsbRemoveDevice (Child);
}