]> git.proxmox.com Git - mirror_edk2.git/blobdiff - MdePkg/Library/BaseUefiDecompressLib/BaseUefiDecompressLib.c
MdePkg: Fix Xcode 9 Beta treating 32-bit left shift as undefined
[mirror_edk2.git] / MdePkg / Library / BaseUefiDecompressLib / BaseUefiDecompressLib.c
index cd5d8c8d8ba887bd4b6543bcae5abe2ad8fb8fdc..e818543d925530ee9a9f66245c423c15b22bc2a6 100644 (file)
@@ -1,7 +1,7 @@
 /** @file\r
   UEFI Decompress Library implementation refer to UEFI specification.\r
 \r
-  Copyright (c) 2006 - 2010, Intel Corporation. All rights reserved.<BR>\r
+  Copyright (c) 2006 - 2015, Intel Corporation. All rights reserved.<BR>\r
   Portions copyright (c) 2008 - 2009, Apple Inc. 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
@@ -27,7 +27,7 @@
 \r
   Shift mBitBuf NumOfBits left. Read in NumOfBits of bits from source.\r
 \r
-  @param  Sd        The global scratch data\r
+  @param  Sd        The global scratch data.\r
   @param  NumOfBits The number of bits to shift and read.\r
 \r
 **/\r
@@ -40,14 +40,14 @@ FillBuf (
   //\r
   // Left shift NumOfBits of bits in advance\r
   //\r
-  Sd->mBitBuf = (UINT32) (Sd->mBitBuf << NumOfBits);\r
+  Sd->mBitBuf = (UINT32) LShiftU64 (((UINT64)Sd->mBitBuf), NumOfBits);\r
 \r
   //\r
   // Copy data needed in bytes into mSbuBitBuf\r
   //\r
   while (NumOfBits > Sd->mBitCount) {\r
-\r
-    Sd->mBitBuf |= (UINT32) (Sd->mSubBitBuf << (NumOfBits = (UINT16) (NumOfBits - Sd->mBitCount)));\r
+    NumOfBits = (UINT16) (NumOfBits - Sd->mBitCount);\r
+    Sd->mBitBuf |= (UINT32) LShiftU64 (((UINT64)Sd->mSubBitBuf), NumOfBits);\r
 \r
     if (Sd->mCompSize > 0) {\r
       //\r
@@ -68,7 +68,7 @@ FillBuf (
   }\r
 \r
   //\r
-  // Caculate additional bit count read to update mBitCount\r
+  // Calculate additional bit count read to update mBitCount\r
   //\r
   Sd->mBitCount = (UINT16) (Sd->mBitCount - NumOfBits);\r
   \r
@@ -119,10 +119,10 @@ GetBits (
   and Position Set according to code length array.\r
   If TableBits > 16, then ASSERT ().\r
 \r
-  @param  Sd        The global scratch data\r
-  @param  NumOfChar The number of symbols in the symbol set\r
-  @param  BitLen    Code length array\r
-  @param  TableBits The width of the mapping table\r
+  @param  Sd        The global scratch data.\r
+  @param  NumOfChar The number of symbols in the symbol set.\r
+  @param  BitLen    Code length array.\r
+  @param  TableBits The width of the mapping table.\r
   @param  Table     The table to be created.\r
 \r
   @retval  0 OK.\r
@@ -262,7 +262,7 @@ MakeTable (
 \r
   Get a position value according to Position Huffman Table.\r
 \r
-  @param  Sd the global scratch data\r
+  @param  Sd The global scratch data.\r
 \r
   @return The position value decoded.\r
 \r
@@ -308,7 +308,7 @@ DecodeP (
 /**\r
   Reads code lengths for the Extra Set or the Position Set.\r
 \r
-  Read in the Extra Set or Pointion Set Length Arrary, then\r
+  Read in the Extra Set or Position Set Length Array, then\r
   generate the Huffman code mapping for them.\r
 \r
   @param  Sd      The global scratch data.\r
@@ -333,6 +333,7 @@ ReadPTLen (
   UINT16  Index;\r
   UINT32  Mask;\r
 \r
+  ASSERT (nn <= NPT);\r
   //\r
   // Read Extra Set Code Length Array size \r
   //\r
@@ -401,7 +402,7 @@ ReadPTLen (
   Read in and decode the Char&Len Set Code Length Array, then\r
   generate the Huffman Code mapping table for the Char&Len Set.\r
 \r
-  @param  Sd the global scratch data\r
+  @param  Sd The global scratch data.\r
 \r
 **/\r
 VOID\r
@@ -507,7 +508,7 @@ DecodeC (
     Sd->mBlockSize    = (UINT16) GetBits (Sd, 16);\r
 \r
     //\r
-    // Read in the Extra Set Code Length Arrary,\r
+    // Read in the Extra Set Code Length Array,\r
     // Generate the Huffman code mapping table for Extra Set.\r
     //\r
     Sd->mBadTableFlag = ReadPTLen (Sd, NT, TBIT, 3);\r
@@ -516,13 +517,13 @@ DecodeC (
     }\r
 \r
     //\r
-    // Read in and decode the Char&Len Set Code Length Arrary,\r
+    // Read in and decode the Char&Len Set Code Length Array,\r
     // Generate the Huffman code mapping table for Char&Len Set.\r
     //\r
     ReadCLen (Sd);\r
 \r
     //\r
-    // Read in the Position Set Code Length Arrary, \r
+    // Read in the Position Set Code Length Array,\r
     // Generate the Huffman code mapping table for the Position Set.\r
     //\r
     Sd->mBadTableFlag = ReadPTLen (Sd, MAXNP, Sd->mPBit, (UINT16) (-1));\r
@@ -561,7 +562,7 @@ DecodeC (
 /**\r
   Decode the source data and put the resulting data into the destination buffer.\r
 \r
-  @param  Sd The global scratch data\r
+  @param  Sd The global scratch data.\r
 \r
 **/\r
 VOID\r
@@ -659,13 +660,13 @@ Done:
   @param  SourceSize      The size, in bytes, of the source buffer.\r
   @param  DestinationSize A pointer to the size, in bytes, of the uncompressed buffer\r
                           that will be generated when the compressed buffer specified\r
-                          by Source and SourceSize is decompressed..\r
+                          by Source and SourceSize is decompressed.\r
   @param  ScratchSize     A pointer to the size, in bytes, of the scratch buffer that\r
                           is required to decompress the compressed buffer specified \r
                           by Source and SourceSize.\r
 \r
   @retval  RETURN_SUCCESS The size of the uncompressed data was returned \r
-                          in DestinationSize and the size of the scratch \r
+                          in DestinationSize, and the size of the scratch \r
                           buffer was returned in ScratchSize.\r
   @retval  RETURN_INVALID_PARAMETER \r
                           The size of the uncompressed data or the size of \r
@@ -721,7 +722,7 @@ UefiDecompressGetInfo (
   If the required scratch buffer size > 0 and Scratch is NULL, then ASSERT().\r
 \r
   @param  Source      The source buffer containing the compressed data.\r
-  @param  Destination The destination buffer to store the decompressed data\r
+  @param  Destination The destination buffer to store the decompressed data.\r
   @param  Scratch     A temporary scratch buffer that is used to perform the decompression.\r
                       This is an optional parameter that may be NULL if the \r
                       required scratch buffer size is 0.\r
@@ -776,7 +777,7 @@ UefiDecompress (
   Sd->mSrcBase  = (UINT8 *)Src;\r
   Sd->mDstBase  = Dst;\r
   //\r
-  // CompSize and OrigSize are caculated in bytes\r
+  // CompSize and OrigSize are calculated in bytes\r
   //\r
   Sd->mCompSize = CompSize;\r
   Sd->mOrigSize = OrigSize;\r