]> git.proxmox.com Git - mirror_edk2.git/blobdiff - ShellPkg/Library/UefiShellLevel1CommandsLib/If.c
ShellPkg: Fixed build error 'variable set but not used'
[mirror_edk2.git] / ShellPkg / Library / UefiShellLevel1CommandsLib / If.c
index 1d83f8a24616c4756697c68e071962d96e02e2ed..54ed23b59b87614e9e39d5cd489193743d9ff7f0 100644 (file)
@@ -14,6 +14,7 @@
 \r
 #include "UefiShellLevel1CommandsLib.h"\r
 #include <Library/PrintLib.h>\r
+#include <Library/PathLib.h>\r
 \r
 typedef enum {\r
   EndTagOr,\r
@@ -39,8 +40,8 @@ typedef enum {
 /**\r
   Extract the next fragment, if there is one.\r
 \r
-  @param[in,out] Statement    The current remaining statement.\r
-  @param[in] Fragment         The current fragment.\r
+  @param[in, out] Statement    The current remaining statement.\r
+  @param[in] Fragment          The current fragment.\r
 \r
   @retval FALSE   There is not another fragment.\r
   @retval TRUE    There is another fragment.\r
@@ -95,6 +96,7 @@ IsValidProfile (
   CONST CHAR16  *TempLocation;\r
 \r
   ProfilesString = ShellGetEnvironmentVariable(L"profiles");\r
+  ASSERT(ProfilesString != NULL);\r
   TempLocation = StrStr(ProfilesString, String);\r
   if ((TempLocation != NULL) && (*(TempLocation-1) == L';') && (*(TempLocation+StrLen(String)) == L';')) {\r
     return (TRUE);\r
@@ -336,15 +338,15 @@ TestOperation (
 /**\r
   Process an if statement and determine if its is valid or not.\r
 \r
-  @param[in,out] PassingState     Opon entry, the current state.  Upon exit, \r
-                                  the new state.\r
-  @param[in] StartParameterNumber The number of the first parameter of\r
-                                  this statement.\r
-  @param[in] EndParameterNumber   The number of the final parameter of\r
-                                  this statement.\r
-  @param[in] OperatorToUse        The type of termination operator.\r
-  @param[in] CaseInsensitive      TRUE for case insensitive, FALSE otherwise.\r
-  @param[in] ForceStringCompare   TRUE for all string based, FALSE otherwise.\r
+  @param[in, out] PassingState     Opon entry, the current state.  Upon exit, \r
+                                   the new state.\r
+  @param[in] StartParameterNumber  The number of the first parameter of\r
+                                   this statement.\r
+  @param[in] EndParameterNumber    The number of the final parameter of\r
+                                   this statement.\r
+  @param[in] OperatorToUse         The type of termination operator.\r
+  @param[in] CaseInsensitive       TRUE for case insensitive, FALSE otherwise.\r
+  @param[in] ForceStringCompare    TRUE for all string based, FALSE otherwise.\r
 \r
   @retval EFI_INVALID_PARAMETER   A parameter was invalid.\r
   @retval EFI_SUCCESS             The operation was successful.                                  \r
@@ -660,12 +662,9 @@ BuildNextStatement (
   OUT END_TAG_TYPE  *EndTag\r
   )\r
 {\r
-  CHAR16    *Buffer;\r
-  UINTN     BufferSize;\r
-\r
   *EndTag = EndTagMax;\r
 \r
-  for(Buffer = NULL, BufferSize = 0\r
+  for(\r
     ; ParameterNumber < gEfiShellParametersProtocol->Argc\r
     ; ParameterNumber++\r
    ) {\r
@@ -737,6 +736,9 @@ MoveToTagSpecial (
     //\r
     CommandName   = NULL;\r
     CommandName   = StrnCatGrow(&CommandName, NULL, CommandNode->Cl, 0);\r
+    if (CommandName == NULL) {\r
+      continue;\r
+    }\r
     CommandWalker = CommandName;\r
     while (CommandWalker[0] == L' ') {\r
       CommandWalker++;\r