]> git.proxmox.com Git - mirror_edk2.git/blobdiff - ShellPkg/Library/UefiShellLevel1CommandsLib/For.c
Refine code to make it more safely.
[mirror_edk2.git] / ShellPkg / Library / UefiShellLevel1CommandsLib / For.c
index 85b85d8dcfa7bcb48a49969296c2c867d6acf86e..4fdbdd051d4c48b439b1b74c4c8b8fe37c79d1cb 100644 (file)
@@ -1,7 +1,7 @@
 /** @file\r
   Main file for endfor and for shell level 1 functions.\r
 \r
-  Copyright (c) 2009 - 2012, Intel Corporation. All rights reserved.<BR>\r
+  Copyright (c) 2009 - 2014, Intel Corporation. All rights reserved.<BR>\r
   This program and the accompanying materials\r
   are licensed and made available under the terms and conditions of the BSD License\r
   which accompanies this distribution.  The full text of the license may be found at\r
@@ -333,7 +333,7 @@ ShellCommandRunFor (
   CurrentScriptFile = ShellCommandGetCurrentScriptFile();\r
   ASSERT(CurrentScriptFile != NULL);\r
 \r
-  if (CurrentScriptFile->CurrentCommand->Data == NULL) {\r
+  if ((CurrentScriptFile->CurrentCommand != NULL) && (CurrentScriptFile->CurrentCommand->Data == NULL)) {\r
     FirstPass = TRUE;\r
 \r
     //\r
@@ -348,8 +348,7 @@ ShellCommandRunFor (
         gShellLevel1HiiHandle, \r
         L"EndFor", \r
         L"For", \r
-        CurrentScriptFile->CurrentCommand!=NULL\r
-          ?CurrentScriptFile->CurrentCommand->Line:0);\r
+        CurrentScriptFile->CurrentCommand->Line);\r
       return (SHELL_DEVICE_ERROR);\r
     }\r
 \r
@@ -459,9 +458,7 @@ ShellCommandRunFor (
             STRING_TOKEN (STR_GEN_PROBLEM_SCRIPT), \r
             gShellLevel1HiiHandle, \r
             ArgSet, \r
-            CurrentScriptFile!=NULL \r
-              && CurrentScriptFile->CurrentCommand!=NULL\r
-              ? CurrentScriptFile->CurrentCommand->Line:0);\r
+            CurrentScriptFile->CurrentCommand->Line);\r
           ShellStatus = SHELL_INVALID_PARAMETER;\r
         } else {\r
           TempSpot = StrStr(ArgSetWalker, L")");\r
@@ -483,9 +480,7 @@ ShellCommandRunFor (
               NULL, \r
               STRING_TOKEN (STR_GEN_PROBLEM_SCRIPT), \r
               gShellLevel1HiiHandle, \r
-              CurrentScriptFile!=NULL \r
-                && CurrentScriptFile->CurrentCommand!=NULL\r
-                ? CurrentScriptFile->CurrentCommand->Line:0);\r
+              CurrentScriptFile->CurrentCommand->Line);\r
             ShellStatus = SHELL_INVALID_PARAMETER;\r
           } else {\r
             *TempSpot = CHAR_NULL;\r
@@ -501,9 +496,7 @@ ShellCommandRunFor (
                 STRING_TOKEN (STR_GEN_PROBLEM_SCRIPT), \r
                 gShellLevel1HiiHandle, \r
                 ArgSet, \r
-                CurrentScriptFile!=NULL \r
-                  && CurrentScriptFile->CurrentCommand!=NULL\r
-                  ? CurrentScriptFile->CurrentCommand->Line:0);\r
+                CurrentScriptFile->CurrentCommand->Line);\r
               ShellStatus = SHELL_INVALID_PARAMETER;\r
             } else {\r
               if (ArgSetWalker[0] == L'-') {\r
@@ -523,9 +516,7 @@ ShellCommandRunFor (
                   STRING_TOKEN (STR_GEN_PROBLEM_SCRIPT), \r
                   gShellLevel1HiiHandle, \r
                   ArgSet, \r
-                  CurrentScriptFile!=NULL \r
-                    && CurrentScriptFile->CurrentCommand!=NULL\r
-                    ? CurrentScriptFile->CurrentCommand->Line:0);\r
+                  CurrentScriptFile->CurrentCommand->Line);\r
                 ShellStatus = SHELL_INVALID_PARAMETER;\r
               } else {\r
                 if (ArgSetWalker[0] == L'-') {\r
@@ -552,9 +543,7 @@ ShellCommandRunFor (
                       STRING_TOKEN (STR_GEN_PROBLEM_SCRIPT), \r
                       gShellLevel1HiiHandle, \r
                       ArgSet, \r
-                      CurrentScriptFile!=NULL \r
-                        && CurrentScriptFile->CurrentCommand!=NULL\r
-                        ? CurrentScriptFile->CurrentCommand->Line:0);\r
+                      CurrentScriptFile->CurrentCommand->Line);\r
                     ShellStatus = SHELL_INVALID_PARAMETER;\r
                   } else {\r
                     if (*ArgSetWalker == L')') {\r
@@ -574,9 +563,7 @@ ShellCommandRunFor (
                           STRING_TOKEN (STR_GEN_PROBLEM_SCRIPT), \r
                           gShellLevel1HiiHandle, \r
                           ArgSet, \r
-                          CurrentScriptFile!=NULL \r
-                            && CurrentScriptFile->CurrentCommand!=NULL\r
-                            ? CurrentScriptFile->CurrentCommand->Line:0);\r
+                          CurrentScriptFile->CurrentCommand->Line);\r
                         ShellStatus = SHELL_INVALID_PARAMETER;\r
                       }\r
                     }\r