Fix some issues reported by source static analysis tools.

git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@8785 6f19259b-4bc3-4df7-8a09-765794883524
This commit is contained in:
klu2 2009-07-07 10:17:16 +00:00
parent ee09c93f45
commit b7b0dca207
4 changed files with 32 additions and 36 deletions

View File

@ -702,19 +702,17 @@ ApplyChangeHandler (
break; break;
case FORM_CON_IN_ID: case FORM_CON_IN_ID:
for (Index = 0; for (Index = 0; Index < ConsoleInpMenu.MenuNumber; Index++) {
((Index < ConsoleInpMenu.MenuNumber) && (Index < (sizeof (CurrentFakeNVMap->ConsoleCheck) / sizeof (UINT8))));
Index++) {
NewMenuEntry = BOpt_GetMenuEntry (&ConsoleInpMenu, Index); NewMenuEntry = BOpt_GetMenuEntry (&ConsoleInpMenu, Index);
NewConsoleContext = (BM_CONSOLE_CONTEXT *) NewMenuEntry->VariableContext; NewConsoleContext = (BM_CONSOLE_CONTEXT *) NewMenuEntry->VariableContext;
ASSERT (Index < MAX_MENU_NUMBER);
NewConsoleContext->IsActive = CurrentFakeNVMap->ConsoleCheck[Index]; NewConsoleContext->IsActive = CurrentFakeNVMap->ConsoleCheck[Index];
} }
for (Index = 0; for (Index = 0; Index < TerminalMenu.MenuNumber; Index++) {
((Index < TerminalMenu.MenuNumber) && (Index < (sizeof (CurrentFakeNVMap->ConsoleCheck) / sizeof (UINT8) - ConsoleInpMenu.MenuNumber)));
Index++) {
NewMenuEntry = BOpt_GetMenuEntry (&TerminalMenu, Index); NewMenuEntry = BOpt_GetMenuEntry (&TerminalMenu, Index);
NewTerminalContext = (BM_TERMINAL_CONTEXT *) NewMenuEntry->VariableContext; NewTerminalContext = (BM_TERMINAL_CONTEXT *) NewMenuEntry->VariableContext;
ASSERT (Index + ConsoleInpMenu.MenuNumber < MAX_MENU_NUMBER);
NewTerminalContext->IsConIn = CurrentFakeNVMap->ConsoleCheck[Index + ConsoleInpMenu.MenuNumber]; NewTerminalContext->IsConIn = CurrentFakeNVMap->ConsoleCheck[Index + ConsoleInpMenu.MenuNumber];
} }
@ -722,19 +720,17 @@ ApplyChangeHandler (
break; break;
case FORM_CON_OUT_ID: case FORM_CON_OUT_ID:
for (Index = 0; for (Index = 0; Index < ConsoleOutMenu.MenuNumber; Index++) {
((Index < ConsoleOutMenu.MenuNumber) && (Index < (sizeof (CurrentFakeNVMap->ConsoleCheck) / sizeof (UINT8))));
Index++) {
NewMenuEntry = BOpt_GetMenuEntry (&ConsoleOutMenu, Index); NewMenuEntry = BOpt_GetMenuEntry (&ConsoleOutMenu, Index);
NewConsoleContext = (BM_CONSOLE_CONTEXT *) NewMenuEntry->VariableContext; NewConsoleContext = (BM_CONSOLE_CONTEXT *) NewMenuEntry->VariableContext;
ASSERT (Index < MAX_MENU_NUMBER);
NewConsoleContext->IsActive = CurrentFakeNVMap->ConsoleCheck[Index]; NewConsoleContext->IsActive = CurrentFakeNVMap->ConsoleCheck[Index];
} }
for (Index = 0; for (Index = 0; Index < TerminalMenu.MenuNumber; Index++) {
((Index < TerminalMenu.MenuNumber) && (Index < (sizeof (CurrentFakeNVMap->ConsoleCheck) / sizeof (UINT8) - ConsoleOutMenu.MenuNumber)));
Index++) {
NewMenuEntry = BOpt_GetMenuEntry (&TerminalMenu, Index); NewMenuEntry = BOpt_GetMenuEntry (&TerminalMenu, Index);
NewTerminalContext = (BM_TERMINAL_CONTEXT *) NewMenuEntry->VariableContext; NewTerminalContext = (BM_TERMINAL_CONTEXT *) NewMenuEntry->VariableContext;
ASSERT (Index + ConsoleOutMenu.MenuNumber < MAX_MENU_NUMBER);
NewTerminalContext->IsConOut = CurrentFakeNVMap->ConsoleCheck[Index + ConsoleOutMenu.MenuNumber]; NewTerminalContext->IsConOut = CurrentFakeNVMap->ConsoleCheck[Index + ConsoleOutMenu.MenuNumber];
} }
@ -742,20 +738,17 @@ ApplyChangeHandler (
break; break;
case FORM_CON_ERR_ID: case FORM_CON_ERR_ID:
ASSERT ((ConsoleErrMenu.MenuNumber + TerminalMenu.MenuNumber) <= (sizeof (CurrentFakeNVMap->ConsoleCheck) / sizeof (UINT8))); for (Index = 0; Index < ConsoleErrMenu.MenuNumber; Index++) {
for (Index = 0;
((Index < ConsoleErrMenu.MenuNumber) && (Index < (sizeof (CurrentFakeNVMap->ConsoleCheck) / sizeof (UINT8))));
Index++) {
NewMenuEntry = BOpt_GetMenuEntry (&ConsoleErrMenu, Index); NewMenuEntry = BOpt_GetMenuEntry (&ConsoleErrMenu, Index);
NewConsoleContext = (BM_CONSOLE_CONTEXT *) NewMenuEntry->VariableContext; NewConsoleContext = (BM_CONSOLE_CONTEXT *) NewMenuEntry->VariableContext;
ASSERT (Index < MAX_MENU_NUMBER);
NewConsoleContext->IsActive = CurrentFakeNVMap->ConsoleCheck[Index]; NewConsoleContext->IsActive = CurrentFakeNVMap->ConsoleCheck[Index];
} }
for (Index = 0; for (Index = 0; Index < TerminalMenu.MenuNumber; Index++) {
((Index < TerminalMenu.MenuNumber) && (Index < (sizeof (CurrentFakeNVMap->ConsoleCheck) / sizeof (UINT8) - ConsoleErrMenu.MenuNumber)));
Index++) {
NewMenuEntry = BOpt_GetMenuEntry (&TerminalMenu, Index); NewMenuEntry = BOpt_GetMenuEntry (&TerminalMenu, Index);
NewTerminalContext = (BM_TERMINAL_CONTEXT *) NewMenuEntry->VariableContext; NewTerminalContext = (BM_TERMINAL_CONTEXT *) NewMenuEntry->VariableContext;
ASSERT (Index + ConsoleErrMenu.MenuNumber < MAX_MENU_NUMBER);
NewTerminalContext->IsStdErr = CurrentFakeNVMap->ConsoleCheck[Index + ConsoleErrMenu.MenuNumber]; NewTerminalContext->IsStdErr = CurrentFakeNVMap->ConsoleCheck[Index + ConsoleErrMenu.MenuNumber];
} }

View File

@ -86,6 +86,7 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
// End Label // End Label
// //
#define LABEL_END 0xffff #define LABEL_END 0xffff
#define MAX_MENU_NUMBER 100
/// ///
/// This is the structure that will be used to store the /// This is the structure that will be used to store the
@ -124,8 +125,8 @@ typedef struct {
// //
// Driver Option Add Handle page storage // Driver Option Add Handle page storage
// //
UINT16 DriverAddHandleDesc[100]; UINT16 DriverAddHandleDesc[MAX_MENU_NUMBER];
UINT16 DriverAddHandleOptionalData[100]; UINT16 DriverAddHandleOptionalData[MAX_MENU_NUMBER];
UINT8 DriverAddActive; UINT8 DriverAddActive;
UINT8 DriverAddForceReconnect; UINT8 DriverAddForceReconnect;
@ -142,19 +143,19 @@ typedef struct {
// //
// At most 100 input/output/errorout device for console storage // At most 100 input/output/errorout device for console storage
// //
UINT8 ConsoleCheck[100]; UINT8 ConsoleCheck[MAX_MENU_NUMBER];
// //
// Boot or Driver Option Order storage // Boot or Driver Option Order storage
// //
UINT8 OptionOrder[100]; UINT8 OptionOrder[MAX_MENU_NUMBER];
UINT8 DriverOptionToBeDeleted[100]; UINT8 DriverOptionToBeDeleted[MAX_MENU_NUMBER];
// //
// Boot Option Delete storage // Boot Option Delete storage
// //
UINT8 BootOptionDel[100]; UINT8 BootOptionDel[MAX_MENU_NUMBER];
UINT8 DriverOptionDel[100]; UINT8 DriverOptionDel[MAX_MENU_NUMBER];
// //
// This is the Terminal Attributes value storage // This is the Terminal Attributes value storage
@ -168,11 +169,11 @@ typedef struct {
// //
// Legacy Device Order Selection Storage // Legacy Device Order Selection Storage
// //
UINT8 LegacyFD[100]; UINT8 LegacyFD[MAX_MENU_NUMBER];
UINT8 LegacyHD[100]; UINT8 LegacyHD[MAX_MENU_NUMBER];
UINT8 LegacyCD[100]; UINT8 LegacyCD[MAX_MENU_NUMBER];
UINT8 LegacyNET[100]; UINT8 LegacyNET[MAX_MENU_NUMBER];
UINT8 LegacyBEV[100]; UINT8 LegacyBEV[MAX_MENU_NUMBER];
// //
// We use DisableMap array to record the enable/disable state of each boot device // We use DisableMap array to record the enable/disable state of each boot device

View File

@ -490,6 +490,7 @@ UpdateConsolePage (
NewMenuEntry = BOpt_GetMenuEntry (&TerminalMenu, Index2); NewMenuEntry = BOpt_GetMenuEntry (&TerminalMenu, Index2);
NewTerminalContext = (BM_TERMINAL_CONTEXT *) NewMenuEntry->VariableContext; NewTerminalContext = (BM_TERMINAL_CONTEXT *) NewMenuEntry->VariableContext;
ASSERT (Index < MAX_MENU_NUMBER);
if (((NewTerminalContext->IsConIn != 0) && (UpdatePageId == FORM_CON_IN_ID)) || if (((NewTerminalContext->IsConIn != 0) && (UpdatePageId == FORM_CON_IN_ID)) ||
((NewTerminalContext->IsConOut != 0) && (UpdatePageId == FORM_CON_OUT_ID)) || ((NewTerminalContext->IsConOut != 0) && (UpdatePageId == FORM_CON_OUT_ID)) ||
((NewTerminalContext->IsStdErr != 0) && (UpdatePageId == FORM_CON_ERR_ID)) ((NewTerminalContext->IsStdErr != 0) && (UpdatePageId == FORM_CON_ERR_ID))
@ -755,6 +756,7 @@ UpdateConModePage (
UINTN Row; UINTN Row;
CHAR16 RowString[50]; CHAR16 RowString[50];
CHAR16 ModeString[50]; CHAR16 ModeString[50];
CHAR16 *pStr;
UINTN TempStringLen; UINTN TempStringLen;
UINTN MaxMode; UINTN MaxMode;
UINTN ValidMode; UINTN ValidMode;
@ -811,11 +813,11 @@ UpdateConModePage (
// Build mode string Column x Row // Build mode string Column x Row
// //
TempStringLen = UnicodeValueToString (ModeString, 0, Col, 0); TempStringLen = UnicodeValueToString (ModeString, 0, Col, 0);
ASSERT ((TempStringLen + StrLen (L" x ")) < (sizeof (ModeString) / sizeof (ModeString[0]))); pStr = &ModeString[0];
StrCat (ModeString, L" x "); StrnCat (pStr, L" x ", StrLen(L" x "));
TempStringLen = UnicodeValueToString (RowString, 0, Row, 0); TempStringLen = UnicodeValueToString (RowString, 0, Row, 0);
ASSERT ((StrLen (ModeString) + TempStringLen) < (sizeof (ModeString) / sizeof (ModeString[0]))); pStr = &ModeString[0];
StrCat (ModeString, RowString); StrnCat (pStr, RowString, StrLen(RowString));
ModeToken[Index] = HiiSetString (CallbackData->BmmHiiHandle, 0, ModeString, NULL); ModeToken[Index] = HiiSetString (CallbackData->BmmHiiHandle, 0, ModeString, NULL);

View File

@ -273,7 +273,6 @@ CallBootManager (
if (StrStr (Option->Description, DESCRIPTION_FLOPPY) != NULL) { if (StrStr (Option->Description, DESCRIPTION_FLOPPY) != NULL) {
BootStringNumber = Option->Description + StrLen (DESCRIPTION_FLOPPY) + 1; BootStringNumber = Option->Description + StrLen (DESCRIPTION_FLOPPY) + 1;
Option->Description = GetStringById (STRING_TOKEN (STR_DESCRIPTION_FLOPPY)); Option->Description = GetStringById (STRING_TOKEN (STR_DESCRIPTION_FLOPPY));
} else if (StrStr (Option->Description, DESCRIPTION_DVD) != NULL) { } else if (StrStr (Option->Description, DESCRIPTION_DVD) != NULL) {
BootStringNumber = Option->Description + StrLen (DESCRIPTION_DVD) + 1; BootStringNumber = Option->Description + StrLen (DESCRIPTION_DVD) + 1;
Option->Description = GetStringById (STRING_TOKEN (STR_DESCRIPTION_DVD)); Option->Description = GetStringById (STRING_TOKEN (STR_DESCRIPTION_DVD));
@ -299,6 +298,7 @@ CallBootManager (
Option->Description = GetStringById (STRING_TOKEN (STR_DESCRIPTION_NON_BLOCK)); Option->Description = GetStringById (STRING_TOKEN (STR_DESCRIPTION_NON_BLOCK));
} }
ASSERT (Option->Description != NULL);
if (StrnCmp (BootStringNumber, L"0", 1) != 0) { if (StrnCmp (BootStringNumber, L"0", 1) != 0) {
StrCat (Option->Description, L" "); StrCat (Option->Description, L" ");
StrCat (Option->Description, BootStringNumber); StrCat (Option->Description, BootStringNumber);