]> git.proxmox.com Git - mirror_edk2.git/blobdiff - MdeModulePkg/Universal/Variable/RuntimeDxe/Reclaim.c
1) Add type cast for better coding style.
[mirror_edk2.git] / MdeModulePkg / Universal / Variable / RuntimeDxe / Reclaim.c
index 11bf1a02b6f6a5299479d9d08dfb1f9694f4817e..44c56e232f891dadeb73f5cb619b0d1d1d46afb8 100644 (file)
@@ -3,7 +3,7 @@
   Handles non-volatile variable store garbage collection, using FTW\r
   (Fault Tolerant Write) protocol.\r
 \r
-Copyright (c) 2006 - 2010, Intel Corporation. All rights reserved.<BR>\r
+Copyright (c) 2006 - 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
@@ -47,6 +47,7 @@ GetLbaAndOffsetByAddress (
   EFI_FV_BLOCK_MAP_ENTRY              *FvbMapEntry;\r
   UINT32                              LbaIndex;\r
 \r
+  Fvb     = NULL;\r
   *Lba    = (EFI_LBA) (-1);\r
   *Offset = 0;\r
   \r
@@ -99,8 +100,7 @@ GetLbaAndOffsetByAddress (
   VariableBase. Fault Tolerant Write protocol is used for writing.\r
 \r
   @param  VariableBase   Base address of variable to write\r
-  @param  Buffer         Point to the data buffer.\r
-  @param  BufferSize     The number of bytes of the data Buffer.\r
+  @param  VariableBuffer Point to the variable data buffer.\r
 \r
   @retval EFI_SUCCESS    The function completed successfully.\r
   @retval EFI_NOT_FOUND  Fail to locate Fault Tolerant Write protocol.\r
@@ -110,15 +110,13 @@ GetLbaAndOffsetByAddress (
 EFI_STATUS\r
 FtwVariableSpace (\r
   IN EFI_PHYSICAL_ADDRESS   VariableBase,\r
-  IN UINT8                  *Buffer,\r
-  IN UINTN                  BufferSize\r
+  IN VARIABLE_STORE_HEADER  *VariableBuffer\r
   )\r
 {\r
   EFI_STATUS                         Status;\r
   EFI_HANDLE                         FvbHandle;\r
   EFI_LBA                            VarLba;\r
   UINTN                              VarOffset;\r
-  UINT8                              *FtwBuffer;\r
   UINTN                              FtwBufferSize;\r
   EFI_FAULT_TOLERANT_WRITE_PROTOCOL  *FtwProtocol;\r
 \r
@@ -143,17 +141,9 @@ FtwVariableSpace (
   if (EFI_ERROR (Status)) {\r
     return EFI_ABORTED;\r
   }\r
-  //\r
-  // Prepare for the variable data.\r
-  //\r
-  FtwBufferSize = ((VARIABLE_STORE_HEADER *) ((UINTN) VariableBase))->Size;\r
-  FtwBuffer     = AllocatePool (FtwBufferSize);\r
-  if (FtwBuffer == NULL) {\r
-    return EFI_OUT_OF_RESOURCES;\r
-  }\r
 \r
-  SetMem (FtwBuffer, FtwBufferSize, (UINT8) 0xff);\r
-  CopyMem (FtwBuffer, Buffer, BufferSize);\r
+  FtwBufferSize = ((VARIABLE_STORE_HEADER *) ((UINTN) VariableBase))->Size;\r
+  ASSERT (FtwBufferSize == VariableBuffer->Size);\r
 \r
   //\r
   // FTW write record.\r
@@ -165,9 +155,8 @@ FtwVariableSpace (
                           FtwBufferSize,  // NumBytes\r
                           NULL,           // PrivateData NULL\r
                           FvbHandle,      // Fvb Handle\r
-                          FtwBuffer       // write buffer\r
+                          (VOID *) VariableBuffer // write buffer\r
                           );\r
 \r
-  FreePool (FtwBuffer);\r
   return Status;\r
 }\r