]> git.proxmox.com Git - mirror_edk2.git/commitdiff
Comment's added and fixed.
authorjcarsey <jcarsey@6f19259b-4bc3-4df7-8a09-765794883524>
Fri, 1 Apr 2011 22:16:01 +0000 (22:16 +0000)
committerjcarsey <jcarsey@6f19259b-4bc3-4df7-8a09-765794883524>
Fri, 1 Apr 2011 22:16:01 +0000 (22:16 +0000)
Pointer's checked for NULL before access and after memory allocations.

git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@11499 6f19259b-4bc3-4df7-8a09-765794883524

19 files changed:
ShellPkg/Application/Shell/FileHandleWrappers.c
ShellPkg/Application/Shell/ShellParametersProtocol.c
ShellPkg/Include/Library/ShellLib.h
ShellPkg/Include/ShellBase.h
ShellPkg/Library/UefiShellDebug1CommandsLib/Compress.c
ShellPkg/Library/UefiShellDebug1CommandsLib/Edit/FileBuffer.c
ShellPkg/Library/UefiShellDebug1CommandsLib/Edit/MainTextEditor.c
ShellPkg/Library/UefiShellDebug1CommandsLib/HexEdit/BufferImage.c
ShellPkg/Library/UefiShellDebug1CommandsLib/HexEdit/BufferImage.h
ShellPkg/Library/UefiShellDebug1CommandsLib/HexEdit/FileImage.c
ShellPkg/Library/UefiShellDebug1CommandsLib/HexEdit/HexEdit.c
ShellPkg/Library/UefiShellDebug1CommandsLib/HexEdit/MainHexEditor.c
ShellPkg/Library/UefiShellDebug1CommandsLib/SmbiosView/QueryTable.c
ShellPkg/Library/UefiShellLevel1CommandsLib/For.c
ShellPkg/Library/UefiShellLevel1CommandsLib/Goto.c
ShellPkg/Library/UefiShellLevel1CommandsLib/If.c
ShellPkg/Library/UefiShellLevel2CommandsLib/Map.c
ShellPkg/Library/UefiShellLevel2CommandsLib/Vol.c
ShellPkg/Library/UefiShellNetwork1CommandsLib/Ifconfig.c

index 38fdb8d848957b9067bbef535221b5c383b2a5dd..b2163bebb950cab8185bfe72f8cd7e8671807e5d 100644 (file)
@@ -1547,7 +1547,7 @@ FileInterfaceFileGetInfo(
 /**\r
   Set information about a file\r
 \r
-  @param  File            Protocol instance pointer.\r
+  @param  This            Protocol instance pointer.\r
   @param  InformationType Type of information in Buffer.\r
   @param  BufferSize      Size of buffer.\r
   @param  Buffer          The data to write.\r
index 76935333d6e373fd83fdf2e0b9f01856899efdc7..238ccd96811867382f868d07f254d228ab8b5ce9 100644 (file)
@@ -415,6 +415,14 @@ CleanUpShellParametersProtocol (
   return (Status);\r
 }\r
 \r
+/**\r
+  Determin if a file name represents a unicode file.\r
+\r
+  @param[in] FileName     Pointer to the filename to open.\r
+\r
+  @retval EFI_SUCCESS     The file is a unicode file.\r
+  @return An error upon failure.\r
+**/\r
 EFI_STATUS\r
 EFIAPI\r
 IsUnicodeFile(\r
index 6061262221c127e882ac6c101785db28a81f2b76..12cae5afebf5b77c32db8492d64259089aeb493d 100644 (file)
@@ -1191,7 +1191,7 @@ ShellPromptForResponse (
                   to prevent invalid answers to question.\r
   @param[in] HiiFormatStringId  The format string Id for getting from Hii.\r
   @param[in] HiiFormatHandle    The format string Handle for getting from Hii.\r
-  @param[out] Response          The pointer to Response, which will be populated upon return.\r
+  @param[in,out] Response       The pointer to Response, which will be populated upon return.\r
 \r
   @retval EFI_SUCCESS The operation was sucessful.\r
   @return other       The operation failed.\r
index bd0462c59c5c6c9b2252fe3604ef7aca2b07a2fb..73ef064207814028880c112ea4ad689f614cc1e0 100644 (file)
@@ -15,7 +15,7 @@
 #ifndef __SHELL_BASE__\r
 #define __SHELL_BASE__\r
 \r
-#define ABS(a) (a<0)?(-(a)):(a)\r
+#define ABS(a) ((a<0)?(-(a)):(a))\r
 \r
 typedef VOID *SHELL_FILE_HANDLE;\r
 \r
index afe3ec08582a489630c49bfbeb5aa7f9f8e19533..01321d1ed674d7451750afb0c0e1d3ceccc49085 100644 (file)
@@ -237,8 +237,7 @@ FreeMemory (
 }\r
 \r
 /**\r
-  Initialize String Info Log data structures\r
-\r
+  Initialize String Info Log data structures.\r
 **/\r
 VOID\r
 EFIAPI\r
@@ -1043,8 +1042,7 @@ WritePTLen (
 }\r
 \r
 /**\r
-  Outputs the code length array for Char&Length Set\r
-\r
+  Outputs the code length array for Char&Length Set.\r
 **/\r
 VOID\r
 EFIAPI\r
index fcd0de5cb5f67b14ca99a9dcf713d1d480d58059..82238479244a594070ec00b2137748e11f511c76 100644 (file)
@@ -357,7 +357,7 @@ FileBufferRestoreMousePosition (
         CurrentLine = FileBuffer.CurrentLine;\r
         Line        = MoveLine (FRow - FileBuffer.FilePosition.Row);\r
 \r
-        if (FColumn > Line->Size) {\r
+        if (Line == NULL || FColumn > Line->Size) {\r
           HasCharacter = FALSE;\r
         }\r
 \r
@@ -1367,7 +1367,7 @@ GetNewLine (
   Change a Unicode string to an ASCII string.\r
 \r
   @param[in] UStr     The Unicode string.\r
-  @param[in] Lenght   The maximum size of AStr.\r
+  @param[in] Length   The maximum size of AStr.\r
   @param[out] AStr    ASCII string to pass out.\r
 \r
   @return The actuall length.\r
@@ -1375,9 +1375,9 @@ GetNewLine (
 UINTN\r
 EFIAPI\r
 UnicodeToAscii (\r
-  IN CONST CHAR16  *UStr,\r
-  IN CONST UINTN   Length,\r
-  OUT CHAR8   *AStr\r
+  IN CONST CHAR16   *UStr,\r
+  IN CONST UINTN    Length,\r
+  OUT CHAR8         *AStr\r
   )\r
 {\r
   UINTN Index;\r
@@ -1621,7 +1621,7 @@ FileBufferSave (
   //\r
   // now everything is ready , you can set the new file name to filebuffer\r
   //\r
-  if (StrCmp (FileName, FileBuffer.FileName) != 0) {\r
+  if (FileName != NULL && FileBuffer.FileName != NULL && StrCmp (FileName, FileBuffer.FileName) != 0) {\r
     //\r
     // not the same\r
     //\r
index a82fdb9bb8d89cba51b1f6edb5164e2fef5f3a34..713332ea0d837e2b2258467718a74dea960d5ab1 100644 (file)
@@ -91,7 +91,7 @@ MainCommandSearch (
   VOID\r
   );\r
 \r
-/*\r
+/**\r
   search string in file buffer, and replace it with another str\r
 \r
   @retval EFI_SUCCESS             The operation was successful.\r
@@ -589,8 +589,8 @@ MainCommandSearch (
   return EFI_SUCCESS;\r
 }\r
 \r
-/*\r
-  search string in file buffer, and replace it with another str\r
+/**\r
+  Search string in file buffer, and replace it with another str.\r
 \r
   @retval EFI_SUCCESS             The operation was successful.\r
   @retval EFI_OUT_OF_RESOURCES    A memory allocation failed.\r
@@ -1589,7 +1589,6 @@ GetTextY (
   @retval EFI_SUCCESS       The operation was successful.\r
   @retval EFI_NOT_FOUND     There was no mouse support found.\r
 **/\r
-STATIC\r
 EFI_STATUS\r
 EFIAPI\r
 MainEditorHandleMouseInput (\r
index 675850cff4661c60f39326993650207e3c6a42aa..8aa75b419ade36d224bcd47bc58079051cb896c7 100644 (file)
@@ -78,22 +78,19 @@ EFI_STATUS
 HBufferImageInit (\r
   VOID\r
   )\r
-/*++\r
-\r
-Routine Description: \r
-\r
+/**
   Initialization function for HBufferImage\r
 \r
-Arguments:  \r
+  \r
 \r
   None\r
 \r
-Returns:  \r
\r
 \r
   EFI_SUCCESS\r
   EFI_LOAD_ERROR\r
 \r
---*/\r
+**/\r
 {\r
   EFI_STATUS  Status;\r
 \r
@@ -151,24 +148,21 @@ EFI_STATUS
 HBufferImageBackup (\r
   VOID\r
   )\r
-/*++\r
-\r
-Routine Description: \r
-\r
+/**
   Backup function for HBufferImage\r
   Only a few fields need to be backup. \r
   This is for making the file buffer refresh \r
   as few as possible.\r
 \r
-Arguments:  \r
+  \r
 \r
   None\r
 \r
-Returns:  \r
\r
 \r
   EFI_SUCCESS\r
 \r
---*/\r
+**/\r
 {\r
   HBufferImageBackupVar.MousePosition   = HBufferImage.MousePosition;\r
 \r
@@ -207,10 +201,7 @@ EFI_STATUS
 HBufferImageFreeLines (\r
   VOID\r
   )\r
-/*++\r
-\r
-Routine Description: \r
-\r
+/**
   Free all the lines in HBufferImage\r
     Fields affected:\r
     Lines\r
@@ -218,15 +209,15 @@ Routine Description:
     NumLines\r
     ListHead \r
 \r
-Arguments:  \r
+  \r
 \r
   None\r
 \r
-Returns:  \r
\r
 \r
   EFI_SUCCESS\r
 \r
---*/\r
+**/\r
 {\r
   HFreeLines (HBufferImage.ListHead, HBufferImage.Lines);\r
 \r
@@ -241,21 +232,18 @@ EFI_STATUS
 HBufferImageCleanup (\r
   VOID\r
   )\r
-/*++\r
-\r
-Routine Description: \r
-\r
+/**
   Cleanup function for HBufferImage\r
 \r
-Arguments:  \r
+  \r
 \r
   None\r
 \r
-Returns:  \r
\r
 \r
   EFI_SUCCESS\r
 \r
---*/\r
+**/\r
 {\r
   EFI_STATUS  Status;\r
 \r
@@ -284,13 +272,10 @@ HBufferImagePrintLine (
   IN HEFI_EDITOR_COLOR_UNION    New\r
 \r
   )\r
-/*++\r
-\r
-Routine Description: \r
-\r
+/**
   Print Line on Row\r
 \r
-Arguments:  \r
+  \r
 \r
   Line - Line to print\r
   Row  - Row on screen ( begin from 1 )\r
@@ -298,11 +283,11 @@ Arguments:
   Orig - Orig\r
   New  - Light display\r
 \r
-Returns:  \r
\r
 \r
   EFI_SUCCESS\r
 \r
---*/\r
+**/\r
 {\r
 \r
   UINTN   Index;\r
@@ -691,7 +676,7 @@ HBufferImageRestoreMousePosition (
         CurrentLine = HBufferImage.CurrentLine;\r
         Line        = HMoveLine (FRow - HBufferImage.BufferPosition.Row);\r
 \r
-        if (FColumn > Line->Size) {\r
+        if (Line == NULL || FColumn > Line->Size) {\r
           HasCharacter = FALSE;\r
         }\r
 \r
@@ -738,21 +723,18 @@ EFI_STATUS
 HBufferImageRestorePosition (\r
   VOID\r
   )\r
-/*++\r
-\r
-Routine Description: \r
-\r
+/**
   Set cursor position according to HBufferImage.DisplayPosition.\r
 \r
-Arguments:  \r
+  \r
 \r
   None\r
 \r
-Returns:  \r
\r
 \r
   EFI_SUCCESS\r
 \r
---*/\r
+**/\r
 {\r
   //\r
   // set cursor position\r
@@ -766,26 +748,17 @@ Returns:
   return EFI_SUCCESS;\r
 }\r
 \r
+/**
+  Refresh function for HBufferImage.\r
+\r
+  @retval EFI_SUCCESS     The operation was successful.\r
+  @retval EFI_LOAD_ERROR  A Load error occured.\r
+\r
+**/\r
 EFI_STATUS\r
 HBufferImageRefresh (\r
   VOID\r
   )\r
-/*++\r
-\r
-Routine Description: \r
-\r
-  Refresh function for HBufferImage\r
-\r
-Arguments:  \r
-\r
-  None\r
-\r
-Returns:  \r
-\r
-  EFI_SUCCESS\r
-  EFI_LOAD_ERROR \r
-\r
---*/\r
 {\r
   LIST_ENTRY          *Link;\r
   HEFI_EDITOR_LINE        *Line;\r
@@ -811,8 +784,8 @@ Returns:
     // no definite required refresh\r
     // and file position displayed on screen has not been changed\r
     //\r
-    if (HBufferImageNeedRefresh == FALSE &&\r
-        HBufferImageOnlyLineNeedRefresh == FALSE &&\r
+    if (!HBufferImageNeedRefresh &&\r
+        !HBufferImageOnlyLineNeedRefresh &&\r
         HBufferImageBackupVar.LowVisibleRow == HBufferImage.LowVisibleRow\r
         ) {\r
       HBufferImageRestoreMousePosition ();\r
@@ -826,7 +799,7 @@ Returns:
   //\r
   // only need to refresh current line\r
   //\r
-  if (HBufferImageOnlyLineNeedRefresh == TRUE && HBufferImageBackupVar.LowVisibleRow == HBufferImage.LowVisibleRow) {\r
+  if (HBufferImageOnlyLineNeedRefresh && HBufferImageBackupVar.LowVisibleRow == HBufferImage.LowVisibleRow) {\r
 \r
     HBufferImagePrintLine (\r
       HBufferImage.CurrentLine,\r
@@ -935,7 +908,22 @@ Returns:
   return EFI_SUCCESS;\r
 }\r
 \r
+/**\r
+  Read an image into a buffer friom a source.\r
+\r
+  @param[in] FileName     Pointer to the file name.  OPTIONAL and ignored if not FileTypeFileBuffer.\r
+  @param[in] DiskName     Pointer to the disk name.  OPTIONAL and ignored if not FileTypeDiskBuffer.\r
+  @param[in] DiskOffset   Offset into the disk.  OPTIONAL and ignored if not FileTypeDiskBuffer.\r
+  @param[in] DiskSize     Size of the disk buffer.  OPTIONAL and ignored if not FileTypeDiskBuffer.\r
+  @param[in] MemoryOffset Offset into the Memory.  OPTIONAL and ignored if not FileTypeMemBuffer.\r
+  @param[in] MemorySize   Size of the Memory buffer.  OPTIONAL and ignored if not FileTypeMemBuffer.\r
+  @param[in] BufferType   The type of buffer to save.  IGNORED.\r
+  @param[in] Recover      TRUE for recovermode, FALSE otherwise.\r
+\r
+  @return EFI_SUCCESS     The operation was successful.\r
+**/\r
 EFI_STATUS\r
+EFIAPI\r
 HBufferImageRead (\r
   IN CONST CHAR16                   *FileName,\r
   IN CONST CHAR16                   *DiskName,\r
@@ -985,6 +973,19 @@ HBufferImageRead (
   return Status;\r
 }\r
 \r
+/**\r
+  Save the current image.\r
+\r
+  @param[in] FileName     Pointer to the file name.  OPTIONAL and ignored if not FileTypeFileBuffer.\r
+  @param[in] DiskName     Pointer to the disk name.  OPTIONAL and ignored if not FileTypeDiskBuffer.\r
+  @param[in] DiskOffset   Offset into the disk.  OPTIONAL and ignored if not FileTypeDiskBuffer.\r
+  @param[in] DiskSize     Size of the disk buffer.  OPTIONAL and ignored if not FileTypeDiskBuffer.\r
+  @param[in] MemoryOffset Offset into the Memory.  OPTIONAL and ignored if not FileTypeMemBuffer.\r
+  @param[in] MemorySize   Size of the Memory buffer.  OPTIONAL and ignored if not FileTypeMemBuffer.\r
+  @param[in] BufferType   The type of buffer to save.  IGNORED.\r
+\r
+  @return EFI_SUCCESS     The operation was successful.\r
+**/\r
 EFI_STATUS\r
 HBufferImageSave (\r
   IN CHAR16                         *FileName,\r
@@ -1035,29 +1036,20 @@ HBufferImageSave (
   return Status;\r
 }\r
 \r
-HEFI_EDITOR_LINE *\r
-HBufferImageCreateLine (\r
-  VOID\r
-  )\r
-/*++\r
-\r
-Routine Description: \r
-\r
-  Create a new line and append it to the line list\r
+/**
+  Create a new line and append it to the line list.\r
     Fields affected:\r
     NumLines\r
     Lines \r
 \r
-Arguments:  \r
+  @retval NULL    create line failed.\r
+  @return         the line created.\r
 \r
-  None\r
-\r
-Returns:  \r
-\r
-  NULL -- create line failed\r
-  Not NULL -- the line created\r
-\r
---*/\r
+**/\r
+HEFI_EDITOR_LINE *\r
+HBufferImageCreateLine (\r
+  VOID\r
+  )\r
 {\r
   HEFI_EDITOR_LINE  *Line;\r
 \r
@@ -1091,26 +1083,15 @@ Returns:
   return Line;\r
 }\r
 \r
+/**
+  Free the current image.\r
+\r
+  @retval EFI_SUCCESS   The operation was successful.\r
+**/\r
 EFI_STATUS\r
 HBufferImageFree (\r
   VOID\r
   )\r
-/*++\r
-\r
-Routine Description: \r
-\r
-  Function called when load a new file in. It will free all the old lines\r
-  and set FileModified field to FALSE\r
-\r
-Arguments:  \r
-\r
-  None\r
-\r
-Returns:  \r
-\r
-  EFI_SUCCESS\r
-\r
---*/\r
 {\r
   //\r
   // free all lines\r
@@ -1120,33 +1101,25 @@ Returns:
   return EFI_SUCCESS;\r
 }\r
 \r
+/**
+  Dispatch input to different handler\r
+\r
+  @param[in] Key    The input key:\r
+                     the keys can be:\r
+                       ASCII KEY\r
+                        Backspace/Delete\r
+                        Direction key: up/down/left/right/pgup/pgdn\r
+                        Home/End\r
+                        INS\r
+\r
+  @retval EFI_SUCCESS           The operation was successful.\r
+  @retval EFI_LOAD_ERROR        A load error occured.\r
+  @retval EFI_OUT_OF_RESOURCES  A Memory allocation failed.\r
+**/\r
 EFI_STATUS\r
 HBufferImageHandleInput (\r
   IN  EFI_INPUT_KEY *Key\r
   )\r
-/*++\r
-\r
-Routine Description: \r
-\r
-  Dispatch input to different handler\r
-\r
-Arguments:  \r
-\r
-  Key -- input key\r
-   the keys can be:\r
-     ASCII KEY\r
-      Backspace/Delete\r
-      Direction key: up/down/left/right/pgup/pgdn\r
-      Home/End\r
-      INS\r
-\r
-Returns:  \r
-\r
-  EFI_SUCCESS\r
-  EFI_LOAD_ERROR\r
-  EFI_OUT_OF_RESOURCES\r
-\r
---*/\r
 {\r
   EFI_STATUS  Status;\r
 \r
@@ -1231,27 +1204,20 @@ Returns:
   return Status;\r
 }\r
 \r
+/**
+  ASCII key + Backspace + return.\r
+\r
+  @param[in] Char               The input char.\r
+\r
+  @retval EFI_SUCCESS           The operation was successful.\r
+  @retval EFI_LOAD_ERROR        A load error occured.\r
+  @retval EFI_OUT_OF_RESOURCES  A memory allocation failed.\r
+**/\r
 EFI_STATUS\r
+EFIAPI\r
 HBufferImageDoCharInput (\r
   IN  CHAR16  Char\r
   )\r
-/*++\r
-\r
-Routine Description: \r
-\r
-  ASCII key + Backspace + return\r
-\r
-Arguments:  \r
-\r
-  Char -- input char\r
-\r
-Returns:  \r
-\r
-  EFI_SUCCESS\r
-  EFI_LOAD_ERROR\r
-  EFI_OUT_OF_RESOURCES\r
-\r
---*/\r
 {\r
   EFI_STATUS  Status;\r
 \r
@@ -1289,26 +1255,19 @@ Returns:
   return Status;\r
 }\r
 \r
+/**\r
+  change char to int value based on Hex.\r
+\r
+  @param[in] Char     The input char.\r
+\r
+  @return The character's index value.\r
+  @retval -1  The operation failed.\r
+**/\r
 INTN\r
+EFIAPI\r
 HBufferImageCharToHex (\r
   IN CHAR16 Char\r
   )\r
-/*++\r
-\r
-Routine Description: \r
-\r
-  change char to int value based on Hex\r
-\r
-Arguments:  \r
-\r
-  Char -- input char\r
-\r
-Returns:  \r
-\r
-  int value;\r
-\r
-\r
---*/\r
 {\r
   //\r
   // change the character to hex\r
@@ -1328,26 +1287,19 @@ Returns:
   return -1;\r
 }\r
 \r
+/**\r
+  Add character.\r
+\r
+  @param[in] Char -- input char.\r
+\r
+  @retval EFI_SUCCESS             The operation was successful.\r
+  @retval EFI_OUT_OF_RESOURCES    A memory allocation failed.\r
+**/\r
 EFI_STATUS\r
+EFIAPI\r
 HBufferImageAddChar (\r
   IN  CHAR16  Char\r
   )\r
-/*++\r
-\r
-Routine Description: \r
-\r
-  Add character\r
-\r
-Arguments:  \r
-\r
-  Char -- input char\r
-\r
-Returns:  \r
-\r
-  EFI_SUCCESS\r
-  EFI_OUT_OF_RESOURCES\r
-\r
---*/\r
 {\r
   HEFI_EDITOR_LINE  *Line;\r
   HEFI_EDITOR_LINE  *NewLine;\r
@@ -1403,7 +1355,7 @@ Returns:
     // at the low 4 bits of the last character of a full line\r
     // so if no next line, need to create a new line\r
     //\r
-    if (High == FALSE && FCol == 0x10) {\r
+    if (!High && FCol == 0x10) {\r
 \r
       HBufferImageOnlyLineNeedRefresh = FALSE;\r
       HBufferImageNeedRefresh         = TRUE;\r
@@ -1431,7 +1383,7 @@ Returns:
     //\r
     // if already at end of this line, scroll it to the start of next line\r
     //\r
-    if (FCol == 0x10 && High == FALSE) {\r
+    if (FCol == 0x10 && !High) {\r
       //\r
       // definitely has next line\r
       //\r
@@ -1469,27 +1421,18 @@ Returns:
   return EFI_SUCCESS;\r
 }\r
 \r
+/**\r
+  Check user specified FileRow and FileCol is in current screen.\r
+\r
+  @param[in] FileRow    Row of file position ( start from 1 ).\r
+\r
+  @retval TRUE   It's on the current screen.\r
+  @retval FALSE  It's not on the current screen.\r
+**/\r
 BOOLEAN\r
 HInCurrentScreen (\r
   IN  UINTN FileRow\r
   )\r
-/*++\r
-\r
-Routine Description: \r
-\r
-  Check user specified FileRow and FileCol is in current screen\r
-\r
-Arguments:  \r
-\r
-  FileRow -- Row of file position ( start from 1 )\r
-\r
-\r
-Returns:  \r
-\r
-  TRUE\r
-  FALSE\r
-\r
---*/\r
 {\r
   if (FileRow >= HBufferImage.LowVisibleRow && FileRow <= HBufferImage.LowVisibleRow + (HMainEditor.ScreenSize.Row - 5) - 1) {\r
     return TRUE;\r
@@ -1498,26 +1441,19 @@ Returns:
   return FALSE;\r
 }\r
 \r
+/**\r
+  Check user specified FileRow is above current screen.\r
+\r
+  @param[in] FileRow  Row of file position ( start from 1 ).\r
+  \r
+  @retval TRUE   It is above the current screen.\r
+  @retval FALSE  It is not above the current screen.\r
+\r
+**/\r
 BOOLEAN\r
 HAboveCurrentScreen (\r
   IN  UINTN FileRow\r
   )\r
-/*++\r
-\r
-Routine Description: \r
-\r
-  Check user specified FileRow is above current screen\r
-\r
-Arguments:  \r
-\r
-  FileRow -- Row of file position ( start from 1 )\r
-  \r
-Returns:  \r
-\r
-  TRUE\r
-  FALSE\r
-\r
---*/\r
 {\r
   if (FileRow < HBufferImage.LowVisibleRow) {\r
     return TRUE;\r
@@ -1526,26 +1462,19 @@ Returns:
   return FALSE;\r
 }\r
 \r
+/**\r
+  Check user specified FileRow is under current screen.\r
+\r
+  @param[in] FileRow    Row of file position ( start from 1 ).\r
+\r
+  @retval TRUE      It is under the current screen.\r
+  @retval FALSE     It is not under the current screen.\r
+\r
+**/\r
 BOOLEAN\r
 HUnderCurrentScreen (\r
   IN  UINTN FileRow\r
   )\r
-/*++\r
-\r
-Routine Description: \r
-\r
-  Check user specified FileRow is under current screen\r
-\r
-Arguments:  \r
-\r
-  FileRow -- Row of file position ( start from 1 )\r
-\r
-Returns:  \r
-\r
-  TRUE\r
-  FALSE\r
-\r
---*/\r
 {\r
   if (FileRow > HBufferImage.LowVisibleRow + (HMainEditor.ScreenSize.Row - 5) - 1) {\r
     return TRUE;\r
@@ -1554,29 +1483,20 @@ Returns:
   return FALSE;\r
 }\r
 \r
+/**\r
+  According to cursor's file position, adjust screen display.\r
+\r
+  @param[in] NewFilePosRow    Row of file position ( start from 1 ).\r
+  @param[in] NewFilePosCol    Column of file position ( start from 1 ).\r
+  @param[in] HighBits         Cursor will on high4 bits or low4 bits.\r
+**/\r
 VOID\r
 HBufferImageMovePosition (\r
   IN UINTN    NewFilePosRow,\r
   IN UINTN    NewFilePosCol,\r
   IN BOOLEAN  HighBits\r
   )\r
-/*++\r
-\r
-Routine Description: \r
-\r
-  According to cursor's file position, adjust screen display\r
 \r
-Arguments:  \r
-\r
-  NewFilePosRow -- Row of file position ( start from 1 )\r
-  NewFilePosCol -- Column of file position ( start from 1 )   \r
-  HighBits      -- cursor will on high4 bits or low4 bits\r
-\r
-Returns:  \r
-\r
-  None\r
-\r
---*/\r
 {\r
   INTN    RowGap;\r
   UINTN   Abs;\r
@@ -1641,7 +1561,7 @@ Returns:
     NewDisplayCol++;\r
   }\r
 \r
-  if (HighBits == FALSE) {\r
+  if (!HighBits) {\r
     NewDisplayCol++;\r
   }\r
 \r
@@ -1654,25 +1574,15 @@ Returns:
 \r
 }\r
 \r
+/**\r
+  Scroll cursor to right.\r
+\r
+  @retval EFI_SUCCESS   The operation was successful.\r
+**/\r
 EFI_STATUS\r
 HBufferImageScrollRight (\r
   VOID\r
   )\r
-/*++\r
-\r
-Routine Description: \r
-\r
-  Scroll cursor to right\r
-\r
-Arguments:  \r
-\r
-  None\r
-\r
-Returns:  \r
-\r
-  EFI_SUCCESS\r
-\r
---*/\r
 {\r
   HEFI_EDITOR_LINE  *Line;\r
   UINTN             FRow;\r
@@ -1722,25 +1632,15 @@ Returns:
   return EFI_SUCCESS;\r
 }\r
 \r
+/**\r
+  Scroll cursor to left.\r
+\r
+  @retval EFI_SUCCESS   The operation was successful.\r
+**/\r
 EFI_STATUS\r
 HBufferImageScrollLeft (\r
   VOID\r
   )\r
-/*++\r
-\r
-Routine Description: \r
-\r
-  Scroll cursor to left\r
-\r
-Arguments:  \r
-\r
-  None\r
-\r
-Returns:  \r
-\r
-  EFI_SUCCESS\r
-\r
---*/\r
 {\r
 \r
   HEFI_EDITOR_LINE  *Line;\r
@@ -1781,25 +1681,15 @@ Returns:
   return EFI_SUCCESS;\r
 }\r
 \r
+/**\r
+  Scroll cursor to the next line\r
+\r
+  @retval EFI_SUCCESS   The operation was successful.\r
+**/\r
 EFI_STATUS\r
 HBufferImageScrollDown (\r
   VOID\r
   )\r
-/*++\r
-\r
-Routine Description: \r
-\r
-  Scroll cursor to the next line\r
-\r
-Arguments:  \r
-\r
-  None\r
-\r
-Returns:  \r
-\r
-  EFI_SUCCESS\r
-\r
---*/\r
 {\r
   HEFI_EDITOR_LINE  *Line;\r
   UINTN             FRow;\r
@@ -1836,25 +1726,15 @@ Returns:
   return EFI_SUCCESS;\r
 }\r
 \r
+/**\r
+  Scroll cursor to previous line\r
+\r
+  @retval EFI_SUCCESS   The operation was successful.\r
+**/\r
 EFI_STATUS\r
 HBufferImageScrollUp (\r
   VOID\r
   )\r
-/*++\r
-\r
-Routine Description: \r
-\r
-  Scroll cursor to previous line\r
-\r
-Arguments:  \r
-\r
-  None\r
-\r
-Returns:  \r
-\r
-  EFI_SUCCESS\r
-\r
---*/\r
 {\r
   HEFI_EDITOR_LINE  *Line;\r
   UINTN             FRow;\r
@@ -1880,25 +1760,15 @@ Returns:
   return EFI_SUCCESS;\r
 }\r
 \r
+/**\r
+  Scroll cursor to next page\r
+\r
+  @retval EFI_SUCCESS   The operation was successful.\r
+**/\r
 EFI_STATUS\r
 HBufferImagePageDown (\r
   VOID\r
   )\r
-/*++\r
-\r
-Routine Description: \r
-\r
-  Scroll cursor to next page\r
-\r
-Arguments:  \r
-\r
-  None\r
-\r
-Returns:  \r
-\r
-  EFI_SUCCESS\r
-\r
---*/\r
 {\r
   HEFI_EDITOR_LINE  *Line;\r
   UINTN             FRow;\r
@@ -1943,25 +1813,15 @@ Returns:
   return EFI_SUCCESS;\r
 }\r
 \r
+/**\r
+  Scroll cursor to previous page\r
+\r
+  @retval EFI_SUCCESS   The operation was successful.\r
+**/\r
 EFI_STATUS\r
 HBufferImagePageUp (\r
   VOID\r
   )\r
-/*++\r
-\r
-Routine Description: \r
-\r
-  Scroll cursor to previous page\r
-\r
-Arguments:  \r
-\r
-  None\r
-\r
-Returns:  \r
-\r
-  EFI_SUCCESS\r
-\r
---*/\r
 {\r
   HEFI_EDITOR_LINE  *Line;\r
   UINTN             FRow;\r
@@ -2001,25 +1861,15 @@ Returns:
   return EFI_SUCCESS;\r
 }\r
 \r
+/**\r
+  Scroll cursor to start of line\r
+\r
+  @retval EFI_SUCCESS  The operation was successful.\r
+**/\r
 EFI_STATUS\r
 HBufferImageHome (\r
   VOID\r
   )\r
-/*++\r
-\r
-Routine Description: \r
-\r
-  Scroll cursor to start of line\r
-\r
-Arguments:  \r
-\r
-  None\r
-\r
-Returns:  \r
-\r
-  EFI_SUCCESS\r
-\r
---*/\r
 {\r
   HEFI_EDITOR_LINE  *Line;\r
   UINTN             FRow;\r
@@ -2043,25 +1893,15 @@ Returns:
   return EFI_SUCCESS;\r
 }\r
 \r
+/**\r
+  Scroll cursor to end of line.\r
+\r
+  @retval EFI_SUCCESS  Teh operation was successful.\r
+**/\r
 EFI_STATUS\r
 HBufferImageEnd (\r
   VOID\r
   )\r
-/*++\r
-\r
-Routine Description: \r
-\r
-  Scroll cursor to end of line\r
-\r
-Arguments:  \r
-\r
-  None\r
-\r
-Returns:  \r
-\r
-  EFI_SUCCESS\r
-\r
---*/\r
 {\r
   HEFI_EDITOR_LINE  *Line;\r
   UINTN             FRow;\r
@@ -2092,6 +1932,11 @@ Returns:
   return EFI_SUCCESS;\r
 }\r
 \r
+/**\r
+  Get the size of the open buffer.\r
+\r
+  @retval The size in bytes.\r
+**/\r
 UINTN\r
 HBufferImageGetTotalSize (\r
   VOID\r
@@ -2122,28 +1967,21 @@ HBufferImageGetTotalSize (
   return Size;\r
 }\r
 \r
+/**\r
+  Delete character from buffer.\r
+  \r
+  @param[in] Pos      Position, Pos starting from 0.\r
+  @param[in] Count    The Count of characters to delete.\r
+  @param[OUT] DeleteBuffer    The DeleteBuffer.\r
+\r
+  @retval EFI_SUCCESS Success \r
+**/\r
 EFI_STATUS\r
 HBufferImageDeleteCharacterFromBuffer (\r
   IN  UINTN         Pos,\r
   IN  UINTN         Count,\r
   OUT UINT8         *DeleteBuffer\r
   )\r
-/*++\r
-Routine Description:\r
-\r
-  Delete character from buffer\r
-  \r
-Arguments:\r
-\r
-  Pos - Position, Pos starting from 0\r
-  Count - Count\r
-  DeleteBuffer - DeleteBuffer\r
-\r
-Returns:\r
-\r
-  EFI_SUCCESS Success\r
-  \r
---*/\r
 {\r
   UINTN             Index;\r
 \r
@@ -2264,28 +2102,21 @@ Returns:
   return EFI_SUCCESS;\r
 }\r
 \r
+/**\r
+  Add character to buffer, add before pos.\r
+\r
+  @param[in] Pos        Position, Pos starting from 0.\r
+  @param[in] Count      Count of characters to add.\r
+  @param[in] AddBuffer  Add buffer.\r
+\r
+  @retval EFI_SUCCESS   Success.  \r
+**/\r
 EFI_STATUS\r
 HBufferImageAddCharacterToBuffer (\r
   IN  UINTN          Pos,\r
   IN  UINTN          Count,\r
   IN  UINT8          *AddBuffer\r
   )\r
-/*++'\r
-Routine Description:\r
-\r
-  Add character to buffer, add before pos\r
-\r
-Arguments:\r
-\r
-  Pos - Position, Pos starting from 0\r
-  Count - Count\r
-  AddBuffer - Add buffer\r
-\r
-Returns:\r
-\r
-  EFI_SUCCESS Success\r
-  \r
---*/\r
 {\r
   INTN              Index;\r
 \r
@@ -2378,25 +2209,16 @@ Returns:
   return EFI_SUCCESS;\r
 }\r
 \r
+/**\r
+  Delete the previous character.\r
+\r
+  @retval EFI_SUCCESS   The operationw as successful.\r
+**/\r
 EFI_STATUS\r
+EFIAPI\r
 HBufferImageDoBackspace (\r
   VOID\r
   )\r
-/*++\r
-\r
-Routine Description: \r
-\r
-  delete the previous character\r
-\r
-Arguments:  \r
-\r
-  None\r
-\r
-Returns:  \r
-\r
-  EFI_SUCCESS\r
-\r
---*/\r
 {\r
   HEFI_EDITOR_LINE  *Line;\r
 \r
@@ -2447,25 +2269,16 @@ Returns:
   return EFI_SUCCESS;\r
 }\r
 \r
+/**\r
+  Delete current character from line.\r
+\r
+  @retval EFI_SUCCESS   The operationw as successful.\r
+**/\r
 EFI_STATUS\r
+EFIAPI\r
 HBufferImageDoDelete (\r
   VOID\r
   )\r
-/*++\r
-\r
-Routine Description: \r
-\r
-  Delete current character from line\r
-\r
-Arguments:  \r
-\r
-  None\r
-\r
-Returns:  \r
-\r
-  EFI_SUCCESS\r
-\r
---*/\r
 {\r
 \r
   HEFI_EDITOR_LINE  *Line;\r
@@ -2513,30 +2326,40 @@ Returns:
   return EFI_SUCCESS;\r
 }\r
 \r
+/**\r
+  Change the raw buffer to a list of lines for the UI.\r
+  \r
+  @param[in] Buffer   The pointer to the buffer to fill.\r
+  @param[in] Bytes    The size of the buffer in bytes.\r
+\r
+  @retval EFI_SUCCESS           The operation was successful.\r
+  @retval EFI_OUT_OF_RESOURCES  A memory allocation failed.\r
+**/\r
 EFI_STATUS\r
+EFIAPI\r
 HBufferImageBufferToList (\r
   IN VOID   *Buffer,\r
   IN UINTN  Bytes\r
   )\r
 {\r
-  UINTN             i;\r
-  UINTN             j;\r
+  UINTN             TempI;\r
+  UINTN             TempJ;\r
   UINTN             Left;\r
   HEFI_EDITOR_LINE  *Line;\r
   UINT8             *BufferPtr;\r
 \r
-  i         = 0;\r
+  TempI         = 0;\r
   Left      = 0;\r
   BufferPtr = (UINT8 *) Buffer;\r
 \r
   //\r
   // parse file content line by line\r
   //\r
-  while (i < Bytes) {\r
-    if (Bytes - i >= 0x10) {\r
+  while (TempI < Bytes) {\r
+    if (Bytes - TempI >= 0x10) {\r
       Left = 0x10;\r
     } else {\r
-      Left = Bytes - i;\r
+      Left = Bytes - TempI;\r
     }\r
 \r
     //\r
@@ -2549,9 +2372,9 @@ HBufferImageBufferToList (
 \r
     Line->Size = Left;\r
 \r
-    for (j = 0; j < Left; j++) {\r
-      Line->Buffer[j] = BufferPtr[i];\r
-      i++;\r
+    for (TempJ = 0; TempJ < Left; TempJ++) {\r
+      Line->Buffer[TempJ] = BufferPtr[TempI];\r
+      TempI++;\r
     }\r
 \r
   }\r
@@ -2569,7 +2392,16 @@ HBufferImageBufferToList (
   return EFI_SUCCESS;\r
 }\r
 \r
+/**\r
+  Change the list of lines from the UI to a raw buffer.\r
+  \r
+  @param[in] Buffer   The pointer to the buffer to fill.\r
+  @param[in] Bytes    The size of the buffer in bytes.\r
+\r
+  @retval EFI_SUCCESS   The operation was successful.\r
+**/\r
 EFI_STATUS\r
+EFIAPI\r
 HBufferImageListToBuffer (\r
   IN VOID   *Buffer,\r
   IN UINTN  Bytes\r
@@ -2599,6 +2431,7 @@ HBufferImageListToBuffer (
 \r
     Line = CR (Link, HEFI_EDITOR_LINE, Link, EFI_EDITOR_LINE_LIST);\r
 \r
+    //@todo shouldn't this be an error???\r
     if (Count + Line->Size > Bytes) {\r
       return EFI_SUCCESS;\r
     }\r
@@ -2616,14 +2449,21 @@ HBufferImageListToBuffer (
   return EFI_SUCCESS;\r
 }\r
 \r
+/**\r
+  Move the mouse in the image buffer.\r
+\r
+  @param[in] TextX    The x-coordinate.\r
+  @param[in] TextY    The y-coordinate.\r
+**/\r
 VOID\r
+EFIAPI\r
 HBufferImageAdjustMousePosition (\r
   IN INT32 TextX,\r
   IN INT32 TextY\r
   )\r
 {\r
-  UINTN X;\r
-  UINTN Y;\r
+  UINTN TempX;\r
+  UINTN TempY;\r
   UINTN AbsX;\r
   UINTN AbsY;\r
 \r
@@ -2632,7 +2472,7 @@ HBufferImageAdjustMousePosition (
   // This function will change it to MousePosition\r
   //\r
   //\r
-  // get absolute X value\r
+  // get absolute TempX value\r
   //\r
   if (TextX >= 0) {\r
     AbsX = TextX;\r
@@ -2640,7 +2480,7 @@ HBufferImageAdjustMousePosition (
     AbsX = -TextX;\r
   }\r
   //\r
-  // get absolute Y value\r
+  // get absolute TempY value\r
   //\r
   if (TextY >= 0) {\r
     AbsY = TextY;\r
@@ -2648,48 +2488,48 @@ HBufferImageAdjustMousePosition (
     AbsY = -TextY;\r
   }\r
 \r
-  X = HBufferImage.MousePosition.Column;\r
-  Y = HBufferImage.MousePosition.Row;\r
+  TempX = HBufferImage.MousePosition.Column;\r
+  TempY = HBufferImage.MousePosition.Row;\r
 \r
   if (TextX >= 0) {\r
-    X += TextX;\r
+    TempX += TextX;\r
   } else {\r
-    if (X >= AbsX) {\r
-      X -= AbsX;\r
+    if (TempX >= AbsX) {\r
+      TempX -= AbsX;\r
     } else {\r
-      X = 0;\r
+      TempX = 0;\r
     }\r
   }\r
 \r
   if (TextY >= 0) {\r
-    Y += TextY;\r
+    TempY += TextY;\r
   } else {\r
-    if (Y >= AbsY) {\r
-      Y -= AbsY;\r
+    if (TempY >= AbsY) {\r
+      TempY -= AbsY;\r
     } else {\r
-      Y = 0;\r
+      TempY = 0;\r
     }\r
   }\r
   //\r
   // check whether new mouse column position is beyond screen\r
   // if not, adjust it\r
   //\r
-  if (X >= 10 && X <= (10 + 0x10 * 3 - 1)) {\r
-    HBufferImage.MousePosition.Column = X;\r
-  } else if (X < 10) {\r
+  if (TempX >= 10 && TempX <= (10 + 0x10 * 3 - 1)) {\r
+    HBufferImage.MousePosition.Column = TempX;\r
+  } else if (TempX < 10) {\r
     HBufferImage.MousePosition.Column = 10;\r
-  } else if (X > (10 + 0x10 * 3 - 1)) {\r
+  } else if (TempX > (10 + 0x10 * 3 - 1)) {\r
     HBufferImage.MousePosition.Column = 10 + 0x10 * 3 - 1;\r
   }\r
   //\r
   // check whether new mouse row position is beyond screen\r
   // if not, adjust it\r
   //\r
-  if (Y >= 2 && Y <= (HMainEditor.ScreenSize.Row - 4)) {\r
-    HBufferImage.MousePosition.Row = Y;\r
-  } else if (Y < 2) {\r
+  if (TempY >= 2 && TempY <= (HMainEditor.ScreenSize.Row - 4)) {\r
+    HBufferImage.MousePosition.Row = TempY;\r
+  } else if (TempY < 2) {\r
     HBufferImage.MousePosition.Row = 2;\r
-  } else if (Y > (HMainEditor.ScreenSize.Row - 4)) {\r
+  } else if (TempY > (HMainEditor.ScreenSize.Row - 4)) {\r
     HBufferImage.MousePosition.Row = (HMainEditor.ScreenSize.Row - 4);\r
   }\r
 \r
index d661e50524704feec220ac759a78e2fbfc444b5e..5e637ce700f46069a63431f874b858c3e4bd3357 100644 (file)
@@ -188,10 +188,15 @@ HBufferImageReplace (
   UINTN\r
   );\r
 \r
+/**
+  Free the current image.\r
+\r
+  @retval EFI_SUCCESS   The operation was successful.\r
+**/\r
 EFI_STATUS\r
 HBufferImageFree (\r
   VOID\r
-  ) ;\r
+  );\r
 \r
 EFI_STATUS\r
 HBufferImageDeleteCharacterFromBuffer (\r
index fd6387a20a9a78e98e8817dc696259c859a6d245..5397071b3b197b5defa279ed72efc56e0bd9e95d 100644 (file)
@@ -489,7 +489,8 @@ Returns:
   //\r
   // now everything is ready , you can set the new file name to filebuffer\r
   //\r
-  if (BufferTypeBackup != FileTypeFileBuffer || StringNoCaseCompare (&FileName, &HFileImage.FileName) != 0) {\r
+  if ((BufferTypeBackup != FileTypeFileBuffer && FileName != NULL) ||\r
+     (FileName != NULL && HFileImage.FileName != NULL && StringNoCaseCompare (&FileName, &HFileImage.FileName) != 0)){\r
     //\r
     // not the same\r
     //\r
index 53718c775138928d87c04622a553b2bc79c7d0a9..36c913939b0d5b7773fd77f56915236f376f7f90 100644 (file)
@@ -135,8 +135,8 @@ ShellCommandRunHexEdit (
         Size    = ShellStrToUintn(ShellCommandLineGetRawValue(Package, 2));\r
       }\r
     }\r
-    if (WhatToDo == FileTypeNone && ShellCommandLineGetRawValue(Package, 1) != NULL) {\r
-        Name      = ShellCommandLineGetRawValue(Package, 1);\r
+    Name = ShellCommandLineGetRawValue(Package, 1);\r
+    if (WhatToDo == FileTypeNone && Name != NULL) {\r
         if (!IsValidFileName(Name)) {\r
           ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_PROBLEM), gShellDebug1HiiHandle, Name);\r
           ShellStatus = SHELL_INVALID_PARAMETER;\r
index 961e0cca68f6f08cef73b1212f6c73c476c5430c..58c25f81d4d9ef08a0f451df8959578e4e1bbcab 100644 (file)
@@ -1868,9 +1868,9 @@ Returns:
     || ReadChange ) {\r
 \r
     MainTitleBarRefresh (\r
-      HMainEditor.BufferImage->BufferType == FileTypeFileBuffer?HMainEditor.BufferImage->FileImage->FileName:HMainEditor.BufferImage->BufferType == FileTypeDiskBuffer?HMainEditor.BufferImage->DiskImage->Name:NULL,\r
+      HMainEditor.BufferImage->BufferType == FileTypeFileBuffer&&HMainEditor.BufferImage->FileImage!=NULL?HMainEditor.BufferImage->FileImage->FileName:HMainEditor.BufferImage->BufferType == FileTypeDiskBuffer&&HMainEditor.BufferImage->DiskImage!=NULL?HMainEditor.BufferImage->DiskImage->Name:NULL,\r
       HMainEditor.BufferImage->BufferType,\r
-      HMainEditor.BufferImage->FileImage->ReadOnly,\r
+      (BOOLEAN)(HMainEditor.BufferImage->FileImage!=NULL?HMainEditor.BufferImage->FileImage->ReadOnly:FALSE),\r
       HMainEditor.BufferImage->Modified,\r
       HMainEditor.ScreenSize.Column,\r
       HMainEditor.ScreenSize.Row,\r
index 7b7e5928bd204923a96cbf3740e773bcffcc67a7..f3e3f5f37b316c5c1ec5fb1d7dce30f1a8e54c51 100644 (file)
@@ -2969,7 +2969,7 @@ QueryTable (
     //\r
     if (High > Low && Key >= Low && Key <= High) {\r
       StrnCpy (Info, Table[Index].Info, InfoLen-1);\r
-      StrCat (Info, L"\n");\r
+      StrnCat (Info, L"\n", InfoLen - StrLen(Info));\r
       return Key;\r
     }\r
     //\r
@@ -2977,7 +2977,7 @@ QueryTable (
     //\r
     if (Table[Index].Key == Key) {\r
       StrnCpy (Info, Table[Index].Info, InfoLen-1);\r
-      StrCat (Info, L"\n");\r
+      StrnCat (Info, L"\n", InfoLen - StrLen(Info));\r
       return Key;\r
     }\r
   }\r
index ddcfd45de381cbb375db39daf08babe2f56453c2..64110099d36d8f39f08db98bbd0cd77a9103c6e9 100644 (file)
@@ -69,6 +69,7 @@ ShellCommandRunEndFor (
 {\r
   EFI_STATUS          Status;\r
   BOOLEAN             Found;\r
+  SCRIPT_FILE         *CurrentScriptFile;\r
 \r
   Status = CommandInit();\r
   ASSERT_EFI_ERROR(Status);\r
@@ -86,6 +87,7 @@ ShellCommandRunEndFor (
   Found = MoveToTag(GetPreviousNode, L"for", L"endfor", NULL, ShellCommandGetCurrentScriptFile(), FALSE, FALSE, FALSE);\r
 \r
   if (!Found) {\r
+    CurrentScriptFile = ShellCommandGetCurrentScriptFile();\r
     ShellPrintHiiEx(\r
       -1, \r
       -1, \r
@@ -94,9 +96,9 @@ ShellCommandRunEndFor (
       gShellLevel1HiiHandle, \r
       L"For", \r
       L"EndFor", \r
-      ShellCommandGetCurrentScriptFile()!=NULL\r
-        &&ShellCommandGetCurrentScriptFile()->CurrentCommand!=NULL\r
-          ?ShellCommandGetCurrentScriptFile()->CurrentCommand->Line:0);\r
+      CurrentScriptFile!=NULL\r
+        && CurrentScriptFile->CurrentCommand!=NULL\r
+          ? CurrentScriptFile->CurrentCommand->Line:0);\r
     return (SHELL_NOT_FOUND);\r
   }\r
   return (SHELL_SUCCESS);\r
@@ -421,7 +423,16 @@ ShellCommandRunFor (
       Info->CurrentValue    = NULL;\r
       ArgSetWalker            = ArgSet;\r
       if (ArgSetWalker[0] != L'(') {\r
-        ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_PROBLEM_SCRIPT), gShellLevel1HiiHandle, ArgSet, ShellCommandGetCurrentScriptFile()->CurrentCommand->Line);\r
+        ShellPrintHiiEx(\r
+          -1, \r
+          -1, \r
+          NULL, \r
+          STRING_TOKEN (STR_GEN_PROBLEM_SCRIPT), \r
+          gShellLevel1HiiHandle, \r
+          ArgSet, \r
+          CurrentScriptFile!=NULL \r
+            && CurrentScriptFile->CurrentCommand!=NULL\r
+            ? CurrentScriptFile->CurrentCommand->Line:0);\r
         ShellStatus = SHELL_INVALID_PARAMETER;\r
       } else {\r
         TempSpot = StrStr(ArgSetWalker, L")");\r
@@ -437,7 +448,15 @@ ShellCommandRunFor (
           }\r
         }\r
         if (TempSpot == NULL) {\r
-          ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_PROBLEM_SCRIPT), gShellLevel1HiiHandle, ArgSet, ShellCommandGetCurrentScriptFile()->CurrentCommand->Line);\r
+          ShellPrintHiiEx(\r
+            -1, \r
+            -1, \r
+            NULL, \r
+            STRING_TOKEN (STR_GEN_PROBLEM_SCRIPT), \r
+            gShellLevel1HiiHandle, \r
+            CurrentScriptFile!=NULL \r
+              && CurrentScriptFile->CurrentCommand!=NULL\r
+              ? CurrentScriptFile->CurrentCommand->Line:0);\r
           ShellStatus = SHELL_INVALID_PARAMETER;\r
         } else {\r
           *TempSpot = CHAR_NULL;\r
@@ -446,7 +465,16 @@ ShellCommandRunFor (
             ArgSetWalker++;\r
           }\r
           if (!ShellIsValidForNumber(ArgSetWalker)) {\r
-            ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_PROBLEM_SCRIPT), gShellLevel1HiiHandle, ArgSet, ShellCommandGetCurrentScriptFile()->CurrentCommand->Line);\r
+            ShellPrintHiiEx(\r
+              -1, \r
+              -1, \r
+              NULL, \r
+              STRING_TOKEN (STR_GEN_PROBLEM_SCRIPT), \r
+              gShellLevel1HiiHandle, \r
+              ArgSet, \r
+              CurrentScriptFile!=NULL \r
+                && CurrentScriptFile->CurrentCommand!=NULL\r
+                ? CurrentScriptFile->CurrentCommand->Line:0);\r
             ShellStatus = SHELL_INVALID_PARAMETER;\r
           } else {\r
             if (ArgSetWalker[0] == L'-') {\r
@@ -459,7 +487,16 @@ ShellCommandRunFor (
               ArgSetWalker++;\r
             }\r
             if (ArgSetWalker == NULL || *ArgSetWalker == CHAR_NULL || !ShellIsValidForNumber(ArgSetWalker)){\r
-              ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_PROBLEM_SCRIPT), gShellLevel1HiiHandle, ArgSet, ShellCommandGetCurrentScriptFile()->CurrentCommand->Line);\r
+              ShellPrintHiiEx(\r
+                -1, \r
+                -1, \r
+                NULL, \r
+                STRING_TOKEN (STR_GEN_PROBLEM_SCRIPT), \r
+                gShellLevel1HiiHandle, \r
+                ArgSet, \r
+                CurrentScriptFile!=NULL \r
+                  && CurrentScriptFile->CurrentCommand!=NULL\r
+                  ? CurrentScriptFile->CurrentCommand->Line:0);\r
               ShellStatus = SHELL_INVALID_PARAMETER;\r
             } else {\r
               if (ArgSetWalker[0] == L'-') {\r
@@ -479,7 +516,16 @@ ShellCommandRunFor (
               }\r
               if (ArgSetWalker != NULL && *ArgSetWalker != CHAR_NULL) {\r
                 if (ArgSetWalker == NULL || *ArgSetWalker == CHAR_NULL || !ShellIsValidForNumber(ArgSetWalker)){\r
-                  ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_PROBLEM_SCRIPT), gShellLevel1HiiHandle, ArgSet, ShellCommandGetCurrentScriptFile()->CurrentCommand->Line);\r
+                  ShellPrintHiiEx(\r
+                    -1, \r
+                    -1, \r
+                    NULL, \r
+                    STRING_TOKEN (STR_GEN_PROBLEM_SCRIPT), \r
+                    gShellLevel1HiiHandle, \r
+                    ArgSet, \r
+                    CurrentScriptFile!=NULL \r
+                      && CurrentScriptFile->CurrentCommand!=NULL\r
+                      ? CurrentScriptFile->CurrentCommand->Line:0);\r
                   ShellStatus = SHELL_INVALID_PARAMETER;\r
                 } else {\r
                   if (*ArgSetWalker == L')') {\r
@@ -492,7 +538,16 @@ ShellCommandRunFor (
                     }\r
 \r
                     if (StrStr(ArgSetWalker, L" ") != NULL) {\r
-                      ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_PROBLEM_SCRIPT), gShellLevel1HiiHandle, ArgSet, ShellCommandGetCurrentScriptFile()->CurrentCommand->Line);\r
+                      ShellPrintHiiEx(\r
+                        -1, \r
+                        -1, \r
+                        NULL, \r
+                        STRING_TOKEN (STR_GEN_PROBLEM_SCRIPT), \r
+                        gShellLevel1HiiHandle, \r
+                        ArgSet, \r
+                        CurrentScriptFile!=NULL \r
+                          && CurrentScriptFile->CurrentCommand!=NULL\r
+                          ? CurrentScriptFile->CurrentCommand->Line:0);\r
                       ShellStatus = SHELL_INVALID_PARAMETER;\r
                     }\r
                   }\r
@@ -512,7 +567,16 @@ ShellCommandRunFor (
       }\r
       CurrentScriptFile->CurrentCommand->Data = Info;\r
     } else {\r
-      ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_PROBLEM_SCRIPT), gShellLevel1HiiHandle, ArgSet, ShellCommandGetCurrentScriptFile()->CurrentCommand->Line);\r
+      ShellPrintHiiEx(\r
+        -1, \r
+        -1, \r
+        NULL, \r
+        STRING_TOKEN (STR_GEN_PROBLEM_SCRIPT), \r
+        gShellLevel1HiiHandle, \r
+        ArgSet, \r
+        CurrentScriptFile!=NULL \r
+          && CurrentScriptFile->CurrentCommand!=NULL\r
+          ? CurrentScriptFile->CurrentCommand->Line:0);\r
       ShellStatus = SHELL_INVALID_PARAMETER;\r
     }\r
   } else {\r
@@ -553,7 +617,17 @@ ShellCommandRunFor (
         // find the matching endfor (we're done with the loop)\r
         //\r
         if (!MoveToTag(GetNextNode, L"endfor", L"for", NULL, CurrentScriptFile, TRUE, FALSE, FALSE)) {\r
-          ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_SYNTAX_NO_MATCHING), gShellLevel1HiiHandle, L"EndFor", L"For", ShellCommandGetCurrentScriptFile()->CurrentCommand->Line);\r
+          ShellPrintHiiEx(\r
+            -1, \r
+            -1, \r
+            NULL, \r
+            STRING_TOKEN (STR_SYNTAX_NO_MATCHING), \r
+            gShellLevel1HiiHandle, \r
+            L"EndFor", \r
+            L"For", \r
+            CurrentScriptFile!=NULL \r
+              && CurrentScriptFile->CurrentCommand!=NULL\r
+              ? CurrentScriptFile->CurrentCommand->Line:0);\r
           ShellStatus = SHELL_DEVICE_ERROR;\r
         }\r
         if (Info->RemoveSubstAlias) {\r
@@ -611,7 +685,17 @@ ShellCommandRunFor (
         // find the matching endfor (we're done with the loop)\r
         //\r
         if (!MoveToTag(GetNextNode, L"endfor", L"for", NULL, CurrentScriptFile, TRUE, FALSE, FALSE)) {\r
-          ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_SYNTAX_NO_MATCHING), gShellLevel1HiiHandle, L"EndFor", L"For", ShellCommandGetCurrentScriptFile()->CurrentCommand->Line);\r
+          ShellPrintHiiEx(\r
+            -1, \r
+            -1, \r
+            NULL, \r
+            STRING_TOKEN (STR_SYNTAX_NO_MATCHING), \r
+            gShellLevel1HiiHandle, \r
+            L"EndFor", \r
+            L"For", \r
+            CurrentScriptFile!=NULL \r
+              && CurrentScriptFile->CurrentCommand!=NULL\r
+              ? CurrentScriptFile->CurrentCommand->Line:0);\r
           ShellStatus = SHELL_DEVICE_ERROR;\r
         }\r
         if (Info->RemoveSubstAlias) {\r
index 3e5a59c5756019d325cbca3d4c8f3a27f00960b3..4d48c7f1e9436ac351678ea345276f10b4558276 100644 (file)
@@ -33,6 +33,7 @@ ShellCommandRunGoto (
   SHELL_STATUS        ShellStatus;\r
   CHAR16              *CompareString;\r
   UINTN               Size;\r
+  SCRIPT_FILE         *CurrentScriptFile;\r
 \r
   ShellStatus         = SHELL_SUCCESS;\r
   CompareString       = NULL;\r
@@ -79,6 +80,7 @@ ShellCommandRunGoto (
       // Check forwards and then backwards for a label...\r
       //\r
       if (!MoveToTag(GetNextNode, L"endfor", L"for", CompareString, ShellCommandGetCurrentScriptFile(), FALSE, FALSE, TRUE)) {\r
+        CurrentScriptFile = ShellCommandGetCurrentScriptFile();\r
         ShellPrintHiiEx(\r
           -1, \r
           -1, \r
@@ -87,9 +89,9 @@ ShellCommandRunGoto (
           gShellLevel1HiiHandle, \r
           CompareString, \r
           L"Goto", \r
-          ShellCommandGetCurrentScriptFile()!=NULL\r
-            &&ShellCommandGetCurrentScriptFile()->CurrentCommand!=NULL\r
-              ?ShellCommandGetCurrentScriptFile()->CurrentCommand->Line:0);\r
+          CurrentScriptFile!=NULL \r
+            && CurrentScriptFile->CurrentCommand!=NULL\r
+            ? CurrentScriptFile->CurrentCommand->Line:0);\r
         ShellStatus = SHELL_NOT_FOUND;\r
       }\r
     FreePool(CompareString);\r
index a3c4482bb3bfc3284347a7deba775f65e1ee3f0c..1d83f8a24616c4756697c68e071962d96e02e2ed 100644 (file)
@@ -825,7 +825,7 @@ ShellCommandRunIf (
   BOOLEAN             CurrentValue;\r
   END_TAG_TYPE        Ending;\r
   END_TAG_TYPE        PreviousEnding;\r
-\r
+  SCRIPT_FILE         *CurrentScriptFile;\r
 \r
   Status = CommandInit();\r
   ASSERT_EFI_ERROR(Status);\r
@@ -843,7 +843,8 @@ ShellCommandRunIf (
   //\r
   // Make sure that an End exists.\r
   //\r
-  if (!MoveToTag(GetNextNode, L"endif", L"if", NULL, ShellCommandGetCurrentScriptFile(), TRUE, TRUE, FALSE)) {\r
+  CurrentScriptFile = ShellCommandGetCurrentScriptFile();\r
+  if (!MoveToTag(GetNextNode, L"endif", L"if", NULL, CurrentScriptFile, TRUE, TRUE, FALSE)) {\r
     ShellPrintHiiEx(\r
       -1, \r
       -1, \r
@@ -852,9 +853,9 @@ ShellCommandRunIf (
       gShellLevel1HiiHandle, \r
       L"EnfIf", \r
       L"If", \r
-      ShellCommandGetCurrentScriptFile()!=NULL\r
-        &&ShellCommandGetCurrentScriptFile()->CurrentCommand!=NULL\r
-          ?ShellCommandGetCurrentScriptFile()->CurrentCommand->Line:0);\r
+      CurrentScriptFile!=NULL \r
+        && CurrentScriptFile->CurrentCommand!=NULL\r
+        ? CurrentScriptFile->CurrentCommand->Line:0);\r
     return (SHELL_DEVICE_ERROR);\r
   }\r
 \r
@@ -928,7 +929,18 @@ ShellCommandRunIf (
       // build up the next statement for analysis\r
       //\r
       if (!BuildNextStatement(CurrentParameter, &EndParameter, &Ending)) {\r
-        ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_SYNTAX_NO_MATCHING), gShellLevel1HiiHandle, L"Then", L"If", ShellCommandGetCurrentScriptFile()->CurrentCommand->Line);\r
+        CurrentScriptFile = ShellCommandGetCurrentScriptFile();\r
+        ShellPrintHiiEx(\r
+          -1, \r
+          -1, \r
+          NULL, \r
+          STRING_TOKEN (STR_SYNTAX_NO_MATCHING), \r
+          gShellLevel1HiiHandle, \r
+          L"Then", \r
+          L"If",\r
+          CurrentScriptFile!=NULL \r
+            && CurrentScriptFile->CurrentCommand!=NULL\r
+            ? CurrentScriptFile->CurrentCommand->Line:0);\r
         ShellStatus = SHELL_INVALID_PARAMETER;\r
       } else {\r
         //\r
@@ -979,6 +991,7 @@ ShellCommandRunElse (
   IN EFI_SYSTEM_TABLE  *SystemTable\r
   )\r
 {\r
+  SCRIPT_FILE *CurrentScriptFile;\r
   ASSERT_EFI_ERROR(CommandInit());\r
 \r
   if (gEfiShellParametersProtocol->Argc > 1) {\r
@@ -991,8 +1004,9 @@ ShellCommandRunElse (
     return (SHELL_UNSUPPORTED);\r
   }\r
 \r
+  CurrentScriptFile = ShellCommandGetCurrentScriptFile();\r
 \r
-  if (!MoveToTag(GetPreviousNode, L"if", L"endif", NULL, ShellCommandGetCurrentScriptFile(), FALSE, TRUE, FALSE)) {\r
+  if (!MoveToTag(GetPreviousNode, L"if", L"endif", NULL, CurrentScriptFile, FALSE, TRUE, FALSE)) {\r
     ShellPrintHiiEx(\r
       -1, \r
       -1, \r
@@ -1001,12 +1015,12 @@ ShellCommandRunElse (
       gShellLevel1HiiHandle, \r
       L"If", \r
       L"Else", \r
-      ShellCommandGetCurrentScriptFile()!=NULL\r
-        &&ShellCommandGetCurrentScriptFile()->CurrentCommand!=NULL\r
-          ?ShellCommandGetCurrentScriptFile()->CurrentCommand->Line:0);\r
+      CurrentScriptFile!=NULL \r
+        && CurrentScriptFile->CurrentCommand!=NULL\r
+        ? CurrentScriptFile->CurrentCommand->Line:0);\r
     return (SHELL_DEVICE_ERROR);\r
   }\r
-  if (!MoveToTag(GetPreviousNode, L"if", L"else", NULL, ShellCommandGetCurrentScriptFile(), FALSE, TRUE, FALSE)) {\r
+  if (!MoveToTag(GetPreviousNode, L"if", L"else", NULL, CurrentScriptFile, FALSE, TRUE, FALSE)) {\r
     ShellPrintHiiEx(\r
       -1, \r
       -1, \r
@@ -1015,13 +1029,13 @@ ShellCommandRunElse (
       gShellLevel1HiiHandle, \r
       L"If", \r
       L"Else", \r
-      ShellCommandGetCurrentScriptFile()!=NULL\r
-        &&ShellCommandGetCurrentScriptFile()->CurrentCommand!=NULL\r
-          ?ShellCommandGetCurrentScriptFile()->CurrentCommand->Line:0);\r
+      CurrentScriptFile!=NULL \r
+        && CurrentScriptFile->CurrentCommand!=NULL\r
+        ? CurrentScriptFile->CurrentCommand->Line:0);\r
     return (SHELL_DEVICE_ERROR);\r
   }\r
 \r
-  if (!MoveToTag(GetNextNode, L"endif", L"if", NULL, ShellCommandGetCurrentScriptFile(), FALSE, FALSE, FALSE)) {\r
+  if (!MoveToTag(GetNextNode, L"endif", L"if", NULL, CurrentScriptFile, FALSE, FALSE, FALSE)) {\r
     ShellPrintHiiEx(\r
       -1, \r
       -1, \r
@@ -1030,9 +1044,9 @@ ShellCommandRunElse (
       gShellLevel1HiiHandle, \r
       L"EndIf", \r
       "Else", \r
-      ShellCommandGetCurrentScriptFile()!=NULL\r
-        &&ShellCommandGetCurrentScriptFile()->CurrentCommand!=NULL\r
-          ?ShellCommandGetCurrentScriptFile()->CurrentCommand->Line:0);\r
+      CurrentScriptFile!=NULL \r
+        && CurrentScriptFile->CurrentCommand!=NULL\r
+        ? CurrentScriptFile->CurrentCommand->Line:0);\r
     return (SHELL_DEVICE_ERROR);\r
   }\r
 \r
@@ -1052,6 +1066,7 @@ ShellCommandRunEndIf (
   IN EFI_SYSTEM_TABLE  *SystemTable\r
   )\r
 {\r
+  SCRIPT_FILE *CurrentScriptFile;\r
   ASSERT_EFI_ERROR(CommandInit());\r
 \r
   if (gEfiShellParametersProtocol->Argc > 1) {\r
@@ -1064,7 +1079,8 @@ ShellCommandRunEndIf (
     return (SHELL_UNSUPPORTED);\r
   }\r
 \r
-  if (!MoveToTag(GetPreviousNode, L"if", L"endif", NULL, ShellCommandGetCurrentScriptFile(), FALSE, TRUE, FALSE)) {\r
+  CurrentScriptFile = ShellCommandGetCurrentScriptFile();\r
+  if (!MoveToTag(GetPreviousNode, L"if", L"endif", NULL, CurrentScriptFile, FALSE, TRUE, FALSE)) {\r
     ShellPrintHiiEx(\r
       -1, \r
       -1, \r
@@ -1073,9 +1089,9 @@ ShellCommandRunEndIf (
       gShellLevel1HiiHandle, \r
       L"If", \r
       L"EndIf", \r
-      ShellCommandGetCurrentScriptFile()!=NULL\r
-        &&ShellCommandGetCurrentScriptFile()->CurrentCommand!=NULL\r
-          ?ShellCommandGetCurrentScriptFile()->CurrentCommand->Line:0);\r
+      CurrentScriptFile!=NULL \r
+        && CurrentScriptFile->CurrentCommand!=NULL\r
+        ? CurrentScriptFile->CurrentCommand->Line:0);\r
     return (SHELL_DEVICE_ERROR);\r
   }\r
 \r
index e7d19c9bed702c84d339c68265010282991aba3c..68130d4db834c5b8677e14cfc4373a744a5de185 100644 (file)
@@ -650,7 +650,7 @@ PerformMappingDisplay(
       &BufferSize,\r
       HandleBuffer);\r
   }\r
-  if (!EFI_ERROR(Status)) {\r
+  if (!EFI_ERROR(Status) && HandleBuffer != NULL) {\r
     //\r
     // Get the map name(s) for each one.\r
     //\r
index 53b7770dfe12073e9a2d05e1e5ac3f0d2ce43179..51cf33f1ba788aaa8e137affd423cf87809aea3e 100644 (file)
@@ -30,7 +30,7 @@ EFIAPI
 HandleVol(\r
   IN CONST CHAR16  *Path,\r
   IN CONST BOOLEAN Delete,\r
-  IN CONST CHAR16  *Name\r
+  IN CONST CHAR16  *Name OPTIONAL\r
   )\r
 {\r
   EFI_STATUS            Status;\r
@@ -45,6 +45,7 @@ HandleVol(
   ShellStatus   = SHELL_SUCCESS;\r
 \r
   if (\r
+      Name != NULL && (\r
       StrStr(Name, L"%") != NULL ||\r
       StrStr(Name, L"^") != NULL ||\r
       StrStr(Name, L"*") != NULL ||\r
@@ -60,7 +61,7 @@ HandleVol(
       StrStr(Name, L">") != NULL ||\r
       StrStr(Name, L"?") != NULL ||\r
       StrStr(Name, L"/") != NULL ||\r
-      StrStr(Name, L" ") != NULL\r
+      StrStr(Name, L" ") != NULL )\r
       ){\r
     ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_PROBLEM), gShellLevel2HiiHandle, Name);\r
     return (SHELL_INVALID_PARAMETER);\r
@@ -150,6 +151,8 @@ HandleVol(
   }\r
 \r
   gEfiShellProtocol->CloseFile(ShellFileHandle);\r
+  \r
+  ASSERT(SysInfo != NULL);\r
 \r
   //\r
   // print VolumeInfo table\r
@@ -200,6 +203,7 @@ ShellCommandRunVol (
   CHAR16        *FullPath;\r
   CHAR16        *TempSpot;\r
   UINTN         Length;\r
+  CONST CHAR16  *NewName;\r
 \r
   Length              = 0;\r
   ProblemParam        = NULL;\r
@@ -266,20 +270,21 @@ ShellCommandRunVol (
         StrnCatGrow(&FullPath, &Length, PathName, 0);\r
         StrnCatGrow(&FullPath, &Length, L":\\", 0);\r
         DeleteMode = ShellCommandLineGetFlag(Package, L"-d");\r
+        NewName    = ShellCommandLineGetValue(Package, L"-n");\r
         if (DeleteMode && ShellCommandLineGetFlag(Package, L"-n")) {\r
           ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_PARAM_CON), gShellLevel2HiiHandle);\r
           ShellStatus = SHELL_INVALID_PARAMETER;\r
-        } else if (ShellCommandLineGetFlag(Package, L"-n") && ShellCommandLineGetValue(Package, L"-n") == NULL) {\r
+        } else if (ShellCommandLineGetFlag(Package, L"-n") && NewName == NULL) {\r
           ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_NO_VALUE), gShellLevel2HiiHandle, L"-n");\r
           ShellStatus = SHELL_INVALID_PARAMETER;\r
-        } else if (ShellCommandLineGetValue(Package, L"-n") != NULL && StrLen(ShellCommandLineGetValue(Package, L"-n")) > 11) {\r
+        } else if (NewName != NULL && StrLen(NewName) > 11) {\r
           ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_PROBLEM_VAL), gShellLevel2HiiHandle, L"-n");\r
           ShellStatus = SHELL_INVALID_PARAMETER;\r
         } else if (ShellStatus == SHELL_SUCCESS) {\r
           ShellStatus = HandleVol(\r
             FullPath,\r
             DeleteMode,\r
-            ShellCommandLineGetValue(Package, L"-n")\r
+            NewName\r
            );\r
         }\r
       }\r
index 3bfdf847dea2a59cc9b4050e7ec3fc559c6f1ff5..d4326448f63576cb2eb3f74f5d07ba1edd60b170 100644 (file)
@@ -781,9 +781,14 @@ IfconfigSetNicAddrByHii (
   if (ConfigHdr != NULL) {\r
     Length = StrLen (ConfigHdr);\r
   } else {\r
-    Length = 0;\r
+    ShellStatus = SHELL_OUT_OF_RESOURCES;\r
+    goto ON_EXIT;\r
   }\r
   ConfigResp = AllocateZeroPool ((Length + NIC_ITEM_CONFIG_SIZE * 2 + 100) * sizeof (CHAR16));\r
+  if (ConfigResp == NULL) {\r
+    ShellStatus = SHELL_OUT_OF_RESOURCES;\r
+    goto ON_EXIT;\r
+  }\r
   if (ConfigHdr != NULL) {\r
     StrCpy (ConfigResp, ConfigHdr);\r
   }\r