]> git.proxmox.com Git - mirror_edk2.git/blobdiff - ShellPkg/Application/Shell/ConsoleWrappers.c
ShellPkg: Clean up source files
[mirror_edk2.git] / ShellPkg / Application / Shell / ConsoleWrappers.c
index 04a7513a3346fabb272c70c58c74bfe184e7f190..a0861e6a1d2390be7ab345a11ead4814ab1015c3 100644 (file)
@@ -2,7 +2,7 @@
   Function definitions for shell simple text in and out on top of file handles.\r
 \r
   (C) Copyright 2013 Hewlett-Packard Development Company, L.P.<BR>\r
-  Copyright (c) 2010 - 2015, Intel Corporation. All rights reserved.<BR>\r
+  Copyright (c) 2010 - 2018, 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
@@ -105,7 +105,7 @@ FileBasedSimpleTextInReadKeyStroke(
     CharSize = sizeof(CHAR16);\r
   } else {\r
     CharSize = sizeof(CHAR8);\r
-  } \r
+  }\r
   //\r
   // Decrement the amount of free space by Size or set to zero (for odd length files)\r
   //\r
@@ -123,7 +123,7 @@ FileBasedSimpleTextInReadKeyStroke(
 }\r
 \r
 /**\r
-  Function to create a EFI_SIMPLE_TEXT_INPUT_PROTOCOL on top of a \r
+  Function to create a EFI_SIMPLE_TEXT_INPUT_PROTOCOL on top of a\r
   SHELL_FILE_HANDLE to support redirecting input from a file.\r
 \r
   @param[in]  FileHandleToUse The pointer to the SHELL_FILE_HANDLE to use.\r
@@ -133,7 +133,6 @@ FileBasedSimpleTextInReadKeyStroke(
   @return                     A pointer to the allocated protocol structure;\r
 **/\r
 EFI_SIMPLE_TEXT_INPUT_PROTOCOL*\r
-EFIAPI\r
 CreateSimpleTextInOnFile(\r
   IN SHELL_FILE_HANDLE  FileHandleToUse,\r
   IN EFI_HANDLE         *HandleLocation\r
@@ -163,7 +162,7 @@ CreateSimpleTextInOnFile(
   ProtocolToReturn->FileHandle                 = FileHandleToUse;\r
   ProtocolToReturn->SimpleTextIn.Reset         = FileBasedSimpleTextInReset;\r
   ProtocolToReturn->SimpleTextIn.ReadKeyStroke = FileBasedSimpleTextInReadKeyStroke;\r
-  \r
+\r
   Status = gBS->CreateEvent (\r
                   EVT_NOTIFY_WAIT,\r
                   TPL_NOTIFY,\r
@@ -178,9 +177,9 @@ CreateSimpleTextInOnFile(
   }\r
   ///@todo possibly also install SimpleTextInputEx on the handle at this point.\r
   Status = gBS->InstallProtocolInterface(\r
-    &(ProtocolToReturn->TheHandle), \r
-    &gEfiSimpleTextInProtocolGuid, \r
-    EFI_NATIVE_INTERFACE, \r
+    &(ProtocolToReturn->TheHandle),\r
+    &gEfiSimpleTextInProtocolGuid,\r
+    EFI_NATIVE_INTERFACE,\r
     &(ProtocolToReturn->SimpleTextIn));\r
   if (!EFI_ERROR(Status)) {\r
     *HandleLocation = ProtocolToReturn->TheHandle;\r
@@ -192,7 +191,7 @@ CreateSimpleTextInOnFile(
 }\r
 \r
 /**\r
-  Function to close a EFI_SIMPLE_TEXT_INPUT_PROTOCOL on top of a \r
+  Function to close a EFI_SIMPLE_TEXT_INPUT_PROTOCOL on top of a\r
   SHELL_FILE_HANDLE to support redirecting input from a file.\r
 \r
   @param[in]  SimpleTextIn    The pointer to the SimpleTextIn to close.\r
@@ -200,7 +199,6 @@ CreateSimpleTextInOnFile(
   @retval EFI_SUCCESS         The object was closed.\r
 **/\r
 EFI_STATUS\r
-EFIAPI\r
 CloseSimpleTextInOnFile(\r
   IN EFI_SIMPLE_TEXT_INPUT_PROTOCOL  *SimpleTextIn\r
   )\r
@@ -215,8 +213,8 @@ CloseSimpleTextInOnFile(
   Status = gBS->CloseEvent(((SHELL_EFI_SIMPLE_TEXT_INPUT_PROTOCOL *)SimpleTextIn)->SimpleTextIn.WaitForKey);\r
 \r
   Status1 = gBS->UninstallProtocolInterface(\r
-    ((SHELL_EFI_SIMPLE_TEXT_INPUT_PROTOCOL*)SimpleTextIn)->TheHandle, \r
-    &gEfiSimpleTextInProtocolGuid, \r
+    ((SHELL_EFI_SIMPLE_TEXT_INPUT_PROTOCOL*)SimpleTextIn)->TheHandle,\r
+    &gEfiSimpleTextInProtocolGuid,\r
     &(((SHELL_EFI_SIMPLE_TEXT_INPUT_PROTOCOL*)SimpleTextIn)->SimpleTextIn));\r
 \r
   FreePool(SimpleTextIn);\r
@@ -285,9 +283,9 @@ FileBasedSimpleTextOutQueryMode (
   )\r
 {\r
   EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *PassThruProtocol;\r
-  \r
+\r
   PassThruProtocol = ((SHELL_EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *)This)->OriginalSimpleTextOut;\r
-  \r
+\r
   // Pass the QueryMode call thru to the original SimpleTextOutProtocol\r
   return (PassThruProtocol->QueryMode(\r
     PassThruProtocol,\r
@@ -423,7 +421,7 @@ FileBasedSimpleTextOutOutputString (
 }\r
 \r
 /**\r
-  Function to create a EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL on top of a \r
+  Function to create a EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL on top of a\r
   SHELL_FILE_HANDLE to support redirecting output from a file.\r
 \r
   @param[in]  FileHandleToUse  The pointer to the SHELL_FILE_HANDLE to use.\r
@@ -434,7 +432,6 @@ FileBasedSimpleTextOutOutputString (
   @return                     A pointer to the allocated protocol structure;\r
 **/\r
 EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL*\r
-EFIAPI\r
 CreateSimpleTextOutOnFile(\r
   IN SHELL_FILE_HANDLE               FileHandleToUse,\r
   IN EFI_HANDLE                      *HandleLocation,\r
@@ -476,21 +473,22 @@ CreateSimpleTextOutOnFile(
   ProtocolToReturn->SimpleTextOut.Mode->CursorVisible = OriginalProtocol->Mode->CursorVisible;\r
 \r
   Status = gBS->InstallProtocolInterface(\r
-    &(ProtocolToReturn->TheHandle), \r
-    &gEfiSimpleTextOutProtocolGuid, \r
-    EFI_NATIVE_INTERFACE, \r
+    &(ProtocolToReturn->TheHandle),\r
+    &gEfiSimpleTextOutProtocolGuid,\r
+    EFI_NATIVE_INTERFACE,\r
     &(ProtocolToReturn->SimpleTextOut));\r
   if (!EFI_ERROR(Status)) {\r
     *HandleLocation = ProtocolToReturn->TheHandle;\r
     return ((EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL*)ProtocolToReturn);\r
   } else {\r
-    FreePool(ProtocolToReturn);\r
+    SHELL_FREE_NON_NULL(ProtocolToReturn->SimpleTextOut.Mode);\r
+    SHELL_FREE_NON_NULL(ProtocolToReturn);\r
     return (NULL);\r
   }\r
 }\r
 \r
 /**\r
-  Function to close a EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL on top of a \r
+  Function to close a EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL on top of a\r
   SHELL_FILE_HANDLE to support redirecting output from a file.\r
 \r
   @param[in] SimpleTextOut    The pointer to the SimpleTextOUT to close.\r
@@ -498,7 +496,6 @@ CreateSimpleTextOutOnFile(
   @retval EFI_SUCCESS         The object was closed.\r
 **/\r
 EFI_STATUS\r
-EFIAPI\r
 CloseSimpleTextOutOnFile(\r
   IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL  *SimpleTextOut\r
   )\r
@@ -508,9 +505,10 @@ CloseSimpleTextOutOnFile(
     return (EFI_INVALID_PARAMETER);\r
   }\r
   Status = gBS->UninstallProtocolInterface(\r
-    ((SHELL_EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL*)SimpleTextOut)->TheHandle, \r
-    &gEfiSimpleTextOutProtocolGuid, \r
+    ((SHELL_EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL*)SimpleTextOut)->TheHandle,\r
+    &gEfiSimpleTextOutProtocolGuid,\r
     &(((SHELL_EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL*)SimpleTextOut)->SimpleTextOut));\r
+  FreePool(SimpleTextOut->Mode);\r
   FreePool(SimpleTextOut);\r
   return (Status);\r
 }\r