diff options
author | Revathy V <revathyv@ami.com> | 2025-07-15 14:58:46 +0530 |
---|---|---|
committer | mergify[bot] <37929162+mergify[bot]@users.noreply.github.com> | 2025-07-24 07:57:29 +0000 |
commit | be6342d64fa0e13e7792f4dc4a6dfb45bab9cf9b (patch) | |
tree | 92acb37c695efd66a1d26a29905f0eb5b05defde /ShellPkg/Library/UefiShellCommandLib/UefiShellCommandLib.c | |
parent | 01295fd25b0465f6a82682e7adbfdbec70c4beb1 (diff) | |
download | edk2-be6342d64fa0e13e7792f4dc4a6dfb45bab9cf9b.zip edk2-be6342d64fa0e13e7792f4dc4a6dfb45bab9cf9b.tar.gz edk2-be6342d64fa0e13e7792f4dc4a6dfb45bab9cf9b.tar.bz2 |
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>
Diffstat (limited to 'ShellPkg/Library/UefiShellCommandLib/UefiShellCommandLib.c')
-rw-r--r-- | ShellPkg/Library/UefiShellCommandLib/UefiShellCommandLib.c | 54 |
1 files changed, 36 insertions, 18 deletions
diff --git a/ShellPkg/Library/UefiShellCommandLib/UefiShellCommandLib.c b/ShellPkg/Library/UefiShellCommandLib/UefiShellCommandLib.c index b0c77e4..44c2ed9 100644 --- a/ShellPkg/Library/UefiShellCommandLib/UefiShellCommandLib.c +++ b/ShellPkg/Library/UefiShellCommandLib/UefiShellCommandLib.c @@ -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,
|