]> git.proxmox.com Git - mirror_edk2.git/blobdiff - ShellPkg/Library/UefiShellLevel2CommandsLib/Cp.c
ShellPkg/UefiShellLevel2CommandsLib: Remove unnecessary EFIAPI
[mirror_edk2.git] / ShellPkg / Library / UefiShellLevel2CommandsLib / Cp.c
index 5cfbc9064f8318670fe7c16807ccb65c15577769..b8f6d310f66b9a417590f6a05990ca75ff2fc7a2 100644 (file)
@@ -2,7 +2,7 @@
   Main file for cp shell level 2 function.\r
 \r
   (C) Copyright 2015 Hewlett-Packard Development Company, L.P.<BR>\r
-  Copyright (c) 2009 - 2015, Intel Corporation. All rights reserved.<BR>\r
+  Copyright (c) 2009 - 2016, 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
@@ -35,7 +35,6 @@
   @retval SHELL_OUT_OF_RESOURCES    a memory allocation failed\r
 **/\r
 SHELL_STATUS\r
-EFIAPI\r
 ValidateAndCopyFiles(\r
   IN CONST EFI_SHELL_FILE_INFO  *FileList,\r
   IN CONST CHAR16               *DestDir,\r
@@ -58,7 +57,6 @@ ValidateAndCopyFiles(
   @retval SHELL_SUCCESS   The source file was copied to the destination\r
 **/\r
 SHELL_STATUS\r
-EFIAPI\r
 CopySingleFile(\r
   IN CONST CHAR16 *Source,\r
   IN CONST CHAR16 *Dest,\r
@@ -229,7 +227,10 @@ CopySingleFile(
       // copy data between files\r
       //\r
       Buffer = AllocateZeroPool(ReadSize);\r
-      ASSERT(Buffer != NULL);\r
+      if (Buffer == NULL) {\r
+        ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_GEN_OUT_MEM), gShellLevel2HiiHandle, CmdName);\r
+        return SHELL_OUT_OF_RESOURCES;\r
+      }\r
       while (ReadSize == PcdGet32(PcdShellFileOperationSize) && !EFI_ERROR(Status)) {\r
         Status = ShellReadFile(SourceHandle, &ReadSize, Buffer);\r
         if (!EFI_ERROR(Status)) {\r
@@ -288,7 +289,6 @@ CopySingleFile(
   @retval SHELL_OUT_OF_RESOURCES    a memory allocation failed\r
 **/\r
 SHELL_STATUS\r
-EFIAPI\r
 ValidateAndCopyFiles(\r
   IN CONST EFI_SHELL_FILE_INFO  *FileList,\r
   IN CONST CHAR16               *DestDir,\r
@@ -573,7 +573,6 @@ ValidateAndCopyFiles(
   @retval SHELL_SUCCESS             The operation was successful.\r
 **/\r
 SHELL_STATUS\r
-EFIAPI\r
 ProcessValidateAndCopyFiles(\r
   IN       EFI_SHELL_FILE_INFO  *FileList,\r
   IN CONST CHAR16               *DestDir,\r
@@ -717,10 +716,14 @@ ShellCommandRunCp (
             ShellStatus = SHELL_NOT_FOUND;\r
           } else  {\r
             FullCwd = AllocateZeroPool(StrSize(Cwd) + sizeof(CHAR16));\r
-            ASSERT (FullCwd != NULL);\r
-            StrCpyS(FullCwd, StrSize(Cwd)/sizeof(CHAR16)+1, Cwd);\r
-            ShellStatus = ProcessValidateAndCopyFiles(FileList, FullCwd, SilentMode, RecursiveMode);\r
-            FreePool(FullCwd);\r
+            if (FullCwd == NULL) {\r
+              ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_GEN_OUT_MEM), gShellLevel2HiiHandle, L"cp");\r
+              ShellStatus = SHELL_OUT_OF_RESOURCES;\r
+            } else {\r
+              StrCpyS (FullCwd, StrSize (Cwd) / sizeof (CHAR16) + 1, Cwd);\r
+              ShellStatus = ProcessValidateAndCopyFiles (FileList, FullCwd, SilentMode, RecursiveMode);\r
+              FreePool (FullCwd);\r
+            }\r
           }\r
         }\r
 \r