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
This commit is contained in:
eric_tian 2009-02-12 06:23:15 +00:00
parent c55426ab64
commit a1b749d074
3 changed files with 18 additions and 6 deletions

View File

@ -111,6 +111,7 @@ UsbIoControlTransfer (
// Clear TT buffer when CTRL/BULK split transaction failes
// Clear the TRANSLATOR TT buffer, not parent's buffer
//
ASSERT (Dev->Translator.TranslatorHubAddress < USB_MAX_DEVICES);
if (Dev->Translator.TranslatorHubAddress != 0) {
UsbHubCtrlClearTTBuffer (
Dev->Bus->Devices[Dev->Translator.TranslatorHubAddress],
@ -195,6 +196,7 @@ UsbIoControlTransfer (
Status = UsbSelectSetting (UsbIf->IfDesc, (UINT8) Request->Value);
if (!EFI_ERROR (Status)) {
ASSERT (UsbIf->IfDesc->ActiveIndex < USB_MAX_INTERFACE_SETTING);
UsbIf->IfSetting = UsbIf->IfDesc->Settings[UsbIf->IfDesc->ActiveIndex];
}
}
@ -282,6 +284,7 @@ UsbIoBulkTransfer (
// Clear TT buffer when CTRL/BULK split transaction failes.
// Clear the TRANSLATOR TT buffer, not parent's buffer
//
ASSERT (Dev->Translator.TranslatorHubAddress < USB_MAX_DEVICES);
if (Dev->Translator.TranslatorHubAddress != 0) {
UsbHubCtrlClearTTBuffer (
Dev->Bus->Devices[Dev->Translator.TranslatorHubAddress],
@ -751,6 +754,7 @@ UsbIoGetStringDescriptor (
Status = EFI_NOT_FOUND;
for (Index = 0; Index < Dev->TotalLangId; Index++) {
ASSERT (Index < USB_MAX_LANG_ID);
if (Dev->LangId[Index] == LangID) {
break;
}

View File

@ -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);
@ -502,6 +506,7 @@ UsbRemoveConfig (
// Remove each interface of the device
//
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);
}

View File

@ -928,6 +928,7 @@ MatchUsbClass (
}
IfDesc = UsbIf->IfDesc;
ASSERT (IfDesc->ActiveIndex < USB_MAX_INTERFACE_SETTING);
ActIfDesc = &(IfDesc->Settings[IfDesc->ActiveIndex]->Desc);
DevDesc = &(UsbIf->Device->DevDesc->Desc);
@ -1008,6 +1009,7 @@ MatchUsbWwid (
}
IfDesc = UsbIf->IfDesc;
ASSERT (IfDesc->ActiveIndex < USB_MAX_INTERFACE_SETTING);
ActIfDesc = &(IfDesc->Settings[IfDesc->ActiveIndex]->Desc);
DevDesc = &(UsbIf->Device->DevDesc->Desc);
StrDesc = UsbGetOneString (UsbIf->Device, DevDesc->StrSerialNumber, USB_US_LAND_ID);