mirror of
https://github.com/tianocore/edk2
synced 2026-08-27 00:23:19 -04:00
ShellPkg: Fixed Deadcode and Null field Coverity warnings.
Updated fixes for all Deadcode and Null field Coverity fixes in ShellPkg Signed-off-by: Revathy <revathyv@ami.com>
This commit is contained in:
parent
01295fd25b
commit
be6342d64f
4 changed files with 59 additions and 33 deletions
|
|
@ -285,19 +285,23 @@ SetEnvironmentVariableList (
|
|||
//
|
||||
// set all the variables from the list
|
||||
//
|
||||
for ( Node = (ENV_VAR_LIST *)GetFirstNode (ListHead)
|
||||
; !IsNull (ListHead, &Node->Link)
|
||||
; Node = (ENV_VAR_LIST *)GetNextNode (ListHead, &Node->Link)
|
||||
)
|
||||
{
|
||||
Size = StrSize (Node->Val) - sizeof (CHAR16);
|
||||
if (Node->Atts & EFI_VARIABLE_NON_VOLATILE) {
|
||||
Status = SHELL_SET_ENVIRONMENT_VARIABLE_NV (Node->Key, Size, Node->Val);
|
||||
} else {
|
||||
Status = SHELL_SET_ENVIRONMENT_VARIABLE_V (Node->Key, Size, Node->Val);
|
||||
}
|
||||
if ((ListHead != NULL) && !IsListEmpty (ListHead)) {
|
||||
for ( Node = (ENV_VAR_LIST *)GetFirstNode (ListHead)
|
||||
; !IsNull (ListHead, &Node->Link)
|
||||
; Node = (ENV_VAR_LIST *)GetNextNode (ListHead, &Node->Link)
|
||||
)
|
||||
{
|
||||
if ((Node->Key != NULL) && (Node->Val != NULL)) {
|
||||
Size = StrSize (Node->Val) - sizeof (CHAR16);
|
||||
if (Node->Atts & EFI_VARIABLE_NON_VOLATILE) {
|
||||
Status = SHELL_SET_ENVIRONMENT_VARIABLE_NV (Node->Key, Size, Node->Val);
|
||||
} else {
|
||||
Status = SHELL_SET_ENVIRONMENT_VARIABLE_V (Node->Key, Size, Node->Val);
|
||||
}
|
||||
|
||||
ASSERT_EFI_ERROR (Status);
|
||||
ASSERT_EFI_ERROR (Status);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
FreeEnvironmentVariableList (ListHead);
|
||||
|
|
@ -441,7 +445,7 @@ ShellFindEnvVarInList (
|
|||
; Node = (ENV_VAR_LIST *)GetNextNode (&gShellEnvVarList.Link, &Node->Link)
|
||||
)
|
||||
{
|
||||
if ((Node->Key != NULL) && (StrCmp (Key, Node->Key) == 0)) {
|
||||
if ((Node->Key != NULL) && (StrCmp (Key, Node->Key) == 0) && (Node->Val != NULL)) {
|
||||
*Value = AllocateCopyPool (StrSize (Node->Val), Node->Val);
|
||||
*ValueSize = StrSize (Node->Val);
|
||||
if (Atts != NULL) {
|
||||
|
|
|
|||
|
|
@ -2853,7 +2853,11 @@ EfiShellGetEnvEx (
|
|||
; Node = (ENV_VAR_LIST *)GetNextNode (&gShellEnvVarList.Link, &Node->Link)
|
||||
)
|
||||
{
|
||||
ASSERT (Node->Key != NULL);
|
||||
if (Node->Key == NULL) {
|
||||
ASSERT (FALSE);
|
||||
continue;
|
||||
}
|
||||
|
||||
Size += StrSize (Node->Key);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -398,7 +398,11 @@ ShellCommandIsCommandOnInternalList (
|
|||
; Node = (SHELL_COMMAND_INTERNAL_LIST_ENTRY *)GetNextNode (&mCommandList.Link, &Node->Link)
|
||||
)
|
||||
{
|
||||
ASSERT (Node->CommandString != NULL);
|
||||
if (Node->CommandString == NULL) {
|
||||
ASSERT (FALSE);
|
||||
continue;
|
||||
}
|
||||
|
||||
if (gUnicodeCollation->StriColl (
|
||||
gUnicodeCollation,
|
||||
(CHAR16 *)CommandString,
|
||||
|
|
@ -485,7 +489,11 @@ ShellCommandGetInternalCommandHelp (
|
|||
; Node = (SHELL_COMMAND_INTERNAL_LIST_ENTRY *)GetNextNode (&mCommandList.Link, &Node->Link)
|
||||
)
|
||||
{
|
||||
ASSERT (Node->CommandString != NULL);
|
||||
if (Node->CommandString == NULL) {
|
||||
ASSERT (FALSE);
|
||||
continue;
|
||||
}
|
||||
|
||||
if (gUnicodeCollation->StriColl (
|
||||
gUnicodeCollation,
|
||||
(CHAR16 *)CommandString,
|
||||
|
|
@ -672,23 +680,25 @@ ShellCommandRegisterCommandName (
|
|||
//
|
||||
// Get Lexical Comparison Value between PrevCommand and Command list entry
|
||||
//
|
||||
LexicalMatchValue = gUnicodeCollation->StriColl (
|
||||
gUnicodeCollation,
|
||||
PrevCommand->CommandString,
|
||||
Command->CommandString
|
||||
);
|
||||
if ((PrevCommand->CommandString != NULL) && (Command->CommandString != NULL)) {
|
||||
LexicalMatchValue = gUnicodeCollation->StriColl (
|
||||
gUnicodeCollation,
|
||||
PrevCommand->CommandString,
|
||||
Command->CommandString
|
||||
);
|
||||
|
||||
//
|
||||
// Swap PrevCommand and Command list entry if PrevCommand list entry
|
||||
// is alphabetically greater than Command list entry
|
||||
//
|
||||
if (LexicalMatchValue > 0) {
|
||||
Command = (SHELL_COMMAND_INTERNAL_LIST_ENTRY *)SwapListEntries (&PrevCommand->Link, &Command->Link);
|
||||
} else if (LexicalMatchValue < 0) {
|
||||
//
|
||||
// PrevCommand entry is lexically lower than Command entry
|
||||
// Swap PrevCommand and Command list entry if PrevCommand list entry
|
||||
// is alphabetically greater than Command list entry
|
||||
//
|
||||
break;
|
||||
if (LexicalMatchValue > 0) {
|
||||
Command = (SHELL_COMMAND_INTERNAL_LIST_ENTRY *)SwapListEntries (&PrevCommand->Link, &Command->Link);
|
||||
} else if (LexicalMatchValue < 0) {
|
||||
//
|
||||
// PrevCommand entry is lexically lower than Command entry
|
||||
//
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -758,7 +768,11 @@ ShellCommandRunCommandHandler (
|
|||
; Node = (SHELL_COMMAND_INTERNAL_LIST_ENTRY *)GetNextNode (&mCommandList.Link, &Node->Link)
|
||||
)
|
||||
{
|
||||
ASSERT (Node->CommandString != NULL);
|
||||
if (Node->CommandString == NULL) {
|
||||
ASSERT (FALSE);
|
||||
continue;
|
||||
}
|
||||
|
||||
if (gUnicodeCollation->StriColl (
|
||||
gUnicodeCollation,
|
||||
(CHAR16 *)CommandString,
|
||||
|
|
@ -831,7 +845,11 @@ ShellCommandGetManFileNameHandler (
|
|||
; Node = (SHELL_COMMAND_INTERNAL_LIST_ENTRY *)GetNextNode (&mCommandList.Link, &Node->Link)
|
||||
)
|
||||
{
|
||||
ASSERT (Node->CommandString != NULL);
|
||||
if (Node->CommandString == NULL) {
|
||||
ASSERT (FALSE);
|
||||
continue;
|
||||
}
|
||||
|
||||
if (gUnicodeCollation->StriColl (
|
||||
gUnicodeCollation,
|
||||
(CHAR16 *)CommandString,
|
||||
|
|
|
|||
|
|
@ -3011,7 +3011,7 @@ DisplayMmBankConnections (
|
|||
//
|
||||
// Divide it to high and low
|
||||
//
|
||||
High = (UINT8)(BankConnections & 0xF0);
|
||||
High = (UINT8)((BankConnections & 0xF0)>>4);
|
||||
Low = (UINT8)(BankConnections & 0x0F);
|
||||
if (High != 0xF) {
|
||||
if (Low != 0xF) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue