]> git.proxmox.com Git - mirror_edk2.git/blobdiff - ShellPkg/Application/Shell/ShellManParser.c
Refine comments and two code style.
[mirror_edk2.git] / ShellPkg / Application / Shell / ShellManParser.c
index e184c78d4f36e57dd9d4bcac551e83e8c803a163..bcc1f8e0a3b463fa65225e0dda70a7b3551d5c8e 100644 (file)
@@ -1,7 +1,7 @@
 /** @file\r
   Provides interface to shell MAN file parser.\r
 \r
-  Copyright (c) 2009 - 2010, Intel Corporation. All rights reserved.<BR>\r
+  Copyright (c) 2009 - 2011, 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
@@ -368,7 +368,7 @@ ManBufferFindTitleSection(
 \r
   Status    = EFI_SUCCESS;\r
 \r
-  TitleString = AllocatePool((7*sizeof(CHAR16)) + StrSize(Command));\r
+  TitleString = AllocateZeroPool((7*sizeof(CHAR16)) + StrSize(Command));\r
   if (TitleString == NULL) {\r
     return (EFI_OUT_OF_RESOURCES);\r
   }\r
@@ -389,24 +389,27 @@ ManBufferFindTitleSection(
       ;  CurrentLocation++);\r
 \r
     TitleEnd = StrStr(CurrentLocation, L"\"");\r
-    ASSERT(TitleEnd != NULL);\r
-    if (BriefDesc != NULL) {\r
-      *BriefSize = StrSize(TitleEnd);\r
-      *BriefDesc = AllocateZeroPool(*BriefSize);\r
-      if (*BriefDesc == NULL) {\r
-        Status = EFI_OUT_OF_RESOURCES;\r
-      } else {\r
-        StrnCpy(*BriefDesc, CurrentLocation, TitleEnd-CurrentLocation);\r
+    if (TitleEnd == NULL) {\r
+      Status = EFI_DEVICE_ERROR;\r
+    } else {\r
+      if (BriefDesc != NULL) {\r
+        *BriefSize = StrSize(TitleEnd);\r
+        *BriefDesc = AllocateZeroPool(*BriefSize);\r
+        if (*BriefDesc == NULL) {\r
+          Status = EFI_OUT_OF_RESOURCES;\r
+        } else {\r
+          StrnCpy(*BriefDesc, CurrentLocation, TitleEnd-CurrentLocation);\r
+        }\r
       }\r
-    }\r
 \r
-    for (CurrentLocation = TitleEnd\r
-      ;  *CurrentLocation != L'\n'\r
-      ;  CurrentLocation++);\r
-    for (\r
-      ;  *CurrentLocation == L' ' || *CurrentLocation == L'\n' || *CurrentLocation == L'\r'\r
-      ;  CurrentLocation++);\r
-    *Buffer = CurrentLocation;\r
+      for (CurrentLocation = TitleEnd\r
+        ;  *CurrentLocation != L'\n'\r
+        ;  CurrentLocation++);\r
+      for (\r
+        ;  *CurrentLocation == L' ' || *CurrentLocation == L'\n' || *CurrentLocation == L'\r'\r
+        ;  CurrentLocation++);\r
+      *Buffer = CurrentLocation;\r
+    }\r
   }\r
 \r
   FreePool(TitleString);\r
@@ -420,12 +423,12 @@ ManBufferFindTitleSection(
 \r
   Upon a sucessful return the caller is responsible to free the memory in *BriefDesc\r
 \r
-  @param[in] Handle             FileHandle to read from\r
-  @param[in] Command            name of command's section to find\r
-  @param[out] BriefDesc         pointer to pointer to string where description goes.\r
-  @param[out] BriefSize         pointer to size of allocated BriefDesc\r
-  @param[in,out] Ascii          TRUE if the file is ASCII, FALSE otherwise, will be\r
-                                set if the file handle is at the 0 position.\r
+  @param[in] Handle              FileHandle to read from\r
+  @param[in] Command             name of command's section to find\r
+  @param[out] BriefDesc          pointer to pointer to string where description goes.\r
+  @param[out] BriefSize          pointer to size of allocated BriefDesc\r
+  @param[in, out] Ascii          TRUE if the file is ASCII, FALSE otherwise, will be\r
+                                 set if the file handle is at the 0 position.\r
 \r
   @retval EFI_OUT_OF_RESOURCES  a memory allocation failed.\r
   @retval EFI_SUCCESS           the section was found and its description sotred in\r
@@ -465,7 +468,7 @@ ManFileFindTitleSection(
     return (EFI_OUT_OF_RESOURCES);\r
   }\r
 \r
-  TitleString = AllocatePool((4*sizeof(CHAR16)) + StrSize(Command));\r
+  TitleString = AllocateZeroPool((4*sizeof(CHAR16)) + StrSize(Command));\r
   if (TitleString == NULL) {\r
     FreePool(ReadLine);\r
     return (EFI_OUT_OF_RESOURCES);\r