From nobody Thu May 9 04:35:17 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of groups.io designates 66.175.222.12 as permitted sender) client-ip=66.175.222.12; envelope-from=bounce+27952+65737+1787277+3901457@groups.io; helo=web01.groups.io; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.12 as permitted sender) smtp.mailfrom=bounce+27952+65737+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=intel.com ARC-Seal: i=1; a=rsa-sha256; t=1601424952; cv=none; d=zohomail.com; s=zohoarc; b=kAqTA+1Gb1elOXbcYlT1HDANbNoTTq194tyrfw9tnGO25XsAWxJUpGNrC3E1JQP61epowctvF1tUlAZiktf6ujZK4zYXx7AT0B1g5fZ3oUldiTaHKTCP3a26dIwCR9hpbilpSFbicyp55c3n9Zkg+5nHS2C96/CnopCbBqXFg+c= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1601424952; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Id:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:References:Sender:Subject:To; bh=ku1oFCtALMHkdazLAYwTj6KtcyJcgXZ9LH0Co2rfOR0=; b=eozYqyQoKKkmXvbcSilAbU2s3X/6vBlizdGK6ZB97Udaq2pea+SlsXKxtFXdFgdeO+glwyXgoCki/Q09BAurEZOnKK2Z8I5rMtaEuSyZi4KVpsvt2j4TYyGZn8fv5oUzJCwli82r/5aQUwDZYBXm6Yq3uG2PPvFPHjAV0ZjZHYU= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.12 as permitted sender) smtp.mailfrom=bounce+27952+65737+1787277+3901457@groups.io; dmarc=fail header.from= (p=none dis=none) header.from= Received: from web01.groups.io (web01.groups.io [66.175.222.12]) by mx.zohomail.com with SMTPS id 1601424952020738.6482617006839; Tue, 29 Sep 2020 17:15:52 -0700 (PDT) Return-Path: X-Received: by 127.0.0.2 with SMTP id YddBYY1788612xCyWxrv5zNF; Tue, 29 Sep 2020 17:15:51 -0700 X-Received: from mga04.intel.com (mga04.intel.com [192.55.52.120]) by mx.groups.io with SMTP id smtpd.web10.4115.1601424950205740244 for ; Tue, 29 Sep 2020 17:15:50 -0700 IronPort-SDR: aGrHRyKUKdVRKK88f5dHYMNYbGsTyuAq28i1NKnnAPyIHccDxYGNTky9uIeiZYQVPeHoMtQrnL X2gTJrhtgzWQ== X-IronPort-AV: E=McAfee;i="6000,8403,9759"; a="159708753" X-IronPort-AV: E=Sophos;i="5.77,320,1596524400"; d="scan'208";a="159708753" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False X-Received: from orsmga006.jf.intel.com ([10.7.209.51]) by fmsmga104.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 29 Sep 2020 17:15:48 -0700 IronPort-SDR: hxtTwumQOzt3wSvGLYjBAgFnWKIbhX/eoiB3wpjGXm2kr+BJWkOyK/Q86NsGpiE9rfO/R8ZXut HxB2syAdxi2g== X-IronPort-AV: E=Sophos;i="5.77,320,1596524400"; d="scan'208";a="312397975" X-Received: from nldesimo-desk1.amr.corp.intel.com ([10.209.9.28]) by orsmga006-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 29 Sep 2020 17:15:43 -0700 From: "Nate DeSimone" To: devel@edk2.groups.io Cc: Chasel Chiu , Liming Gao , Eric Dong Subject: [edk2-devel] [edk2-platforms] [PATCH V1 1/2] MinPlatformPkg: Add missing bounds checks to CompressLib Date: Tue, 29 Sep 2020 17:15:28 -0700 Message-Id: <20200930001529.2212-2-nathaniel.l.desimone@intel.com> In-Reply-To: <20200930001529.2212-1-nathaniel.l.desimone@intel.com> References: <20200930001529.2212-1-nathaniel.l.desimone@intel.com> MIME-Version: 1.0 Precedence: Bulk List-Unsubscribe: Sender: devel@edk2.groups.io List-Id: Mailing-List: list devel@edk2.groups.io; contact devel+owner@edk2.groups.io Reply-To: devel@edk2.groups.io,nathaniel.l.desimone@intel.com X-Gm-Message-State: ht1ZK7rkL9V65zDzhDTDreQ5x1787277AA= Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1601424951; bh=IThfaQKsC/dBLD2Y1rARl+s29v7LRJRSOmScFr51PXQ=; h=Cc:Date:From:Reply-To:Subject:To; b=UGzSo2aFpoXU03bU8qJsaCc4VyRApSZK6hcw+FiA8/UQHUzvVtKGDQYVh/UdznLU+HB I58LJNDPe8jf3vv8MrKwQOlorieeQFrxMtgW16ODjvYVgG417ht025BU/USAZIaiq9+97 L5O1Vq2mY2opYEWTfPRzDs4nVS5UqMYpLsg= X-ZohoMail-DKIM: pass (identity @groups.io) Content-Type: text/plain; charset="utf-8" Current code only as bounds checks in ASSERT macros. They are also needed in release mode where ASSERT is not used. Signed-off-by: Nate DeSimone Cc: Chasel Chiu Cc: Nate DeSimone Cc: Liming Gao Cc: Eric Dong Reviewed-by: Chasel Chiu --- .../MinPlatformPkg/Library/CompressLib/CompressLib.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/Platform/Intel/MinPlatformPkg/Library/CompressLib/CompressLib.= c b/Platform/Intel/MinPlatformPkg/Library/CompressLib/CompressLib.c index 9f93e1ee2d..537eb3b693 100644 --- a/Platform/Intel/MinPlatformPkg/Library/CompressLib/CompressLib.c +++ b/Platform/Intel/MinPlatformPkg/Library/CompressLib/CompressLib.c @@ -1002,7 +1002,10 @@ CountTFreq ( mTFreq[2]++; } } else { - ASSERT((LoopVar3+2)<(2 * NT - 1)); + ASSERT ((LoopVar3 + 2) < (2 * NT - 1)); + if ((LoopVar3 + 2) >=3D (2 * NT - 1)) { + return; + } mTFreq[LoopVar3 + 2]++; } } @@ -1101,7 +1104,10 @@ WriteCLen ( PutBits (CBIT, Count - 20); } } else { - ASSERT((LoopVar3+2)=3D NPT) { + return; + } PutBits (mPTLen[LoopVar3 + 2], mPTCode[LoopVar3 + 2]); } } --=20 2.27.0.windows.1 -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#65737): https://edk2.groups.io/g/devel/message/65737 Mute This Topic: https://groups.io/mt/77208968/1787277 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [importer@patchew.org] -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- From nobody Thu May 9 04:35:17 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of groups.io designates 66.175.222.12 as permitted sender) client-ip=66.175.222.12; envelope-from=bounce+27952+65736+1787277+3901457@groups.io; helo=web01.groups.io; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.12 as permitted sender) smtp.mailfrom=bounce+27952+65736+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=intel.com ARC-Seal: i=1; a=rsa-sha256; t=1601424951; cv=none; d=zohomail.com; s=zohoarc; b=JWI2OFcXaEcYBhO/WehFYk7eS1nqeg2sP4OwCuc620jj4TSCjoNwdQGkSqS9SU2o//193OKXwcm45e+cJ4Qb3gtLRms6iJW7OH4DaSgNgWSl/JsLhrxX1/4hPY2kdEX9wvXj+LqAaIh/Go9z8+wBt9OSwwSIZj+8mjAVuyWU5G4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1601424951; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Id:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:References:Sender:Subject:To; bh=+jjROQa8iMxN35PnzG2SZ6P6HgN+u2doQ7SVdhosMkk=; b=I93aoer669rPe+C+BSaoX1+Ca+CGqOipsqENhjIT/VUeu8IFYXMdtJZexS3WbuaSAkxKBoRlAkwGghAEqITfHLcra0Dmu6vLwbBg+tVFJ1VHrelj9Wwh51C91e6ziaedA0XZqJjb2HGzVoYy8gec1k3q5vBaDPPHTL2ulpjv/io= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.12 as permitted sender) smtp.mailfrom=bounce+27952+65736+1787277+3901457@groups.io; dmarc=fail header.from= (p=none dis=none) header.from= Received: from web01.groups.io (web01.groups.io [66.175.222.12]) by mx.zohomail.com with SMTPS id 1601424951172430.964967487604; Tue, 29 Sep 2020 17:15:51 -0700 (PDT) Return-Path: X-Received: by 127.0.0.2 with SMTP id UwQvYY1788612xTLCvjk6vsa; Tue, 29 Sep 2020 17:15:50 -0700 X-Received: from mga04.intel.com (mga04.intel.com []) by mx.groups.io with SMTP id smtpd.web11.4236.1601424949864889339 for ; Tue, 29 Sep 2020 17:15:50 -0700 IronPort-SDR: dwqm6MyZq2GKx4poE12qzeGaUNCf1D29Tr76TLcgbsRqKHN+voF3UwI72JXnItemQGVwTIOBiK utVzxCZTsqcQ== X-IronPort-AV: E=McAfee;i="6000,8403,9759"; a="159708759" X-IronPort-AV: E=Sophos;i="5.77,320,1596524400"; d="scan'208";a="159708759" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False X-Received: from orsmga006.jf.intel.com ([10.7.209.51]) by fmsmga104.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 29 Sep 2020 17:15:48 -0700 IronPort-SDR: 8NN6iHjXFfs6bbcmGjpfExbXCQ4QLC4FAdblucAlH2boNz6HPvVW7UjYxgdWRmzYLcEtvbDMhs Cc/FWXniegTA== X-IronPort-AV: E=Sophos;i="5.77,320,1596524400"; d="scan'208";a="312397977" X-Received: from nldesimo-desk1.amr.corp.intel.com ([10.209.9.28]) by orsmga006-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 29 Sep 2020 17:15:43 -0700 From: "Nate DeSimone" To: devel@edk2.groups.io Cc: Chasel Chiu , Liming Gao , Eric Dong Subject: [edk2-devel] [edk2-platforms] [PATCH V1 2/2] MinPlatformPkg: Coding style cleanups in CompressLib Date: Tue, 29 Sep 2020 17:15:29 -0700 Message-Id: <20200930001529.2212-3-nathaniel.l.desimone@intel.com> In-Reply-To: <20200930001529.2212-1-nathaniel.l.desimone@intel.com> References: <20200930001529.2212-1-nathaniel.l.desimone@intel.com> MIME-Version: 1.0 Precedence: Bulk List-Unsubscribe: Sender: devel@edk2.groups.io List-Id: Mailing-List: list devel@edk2.groups.io; contact devel+owner@edk2.groups.io Reply-To: devel@edk2.groups.io,nathaniel.l.desimone@intel.com X-Gm-Message-State: ZhVpbXtRFjdVzRdy6G7rzqODx1787277AA= Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1601424950; bh=VfICd5nPIy3sWiGERd8P0WGrC+3i3sc8XRmJteNhrOk=; h=Cc:Date:From:Reply-To:Subject:To; b=qwVguUFoLBITjtRIdj3geFajoNyXkSrWoJJBfsUeqfwQf6cxlJoJ2KnSrzBWhQLbDpj 7BtOdRJh/oQf37IKunVNZ3F+MiVgP+ItYQhiHI2CqsqNPCGWUsdFPzHDGTp9VzOys2cgp QWmkwhafwxy8zowk3pXhKQVGHz5JI8ybA/E= X-ZohoMail-DKIM: pass (identity @groups.io) Content-Type: text/plain; charset="utf-8" Signed-off-by: Nate DeSimone Cc: Chasel Chiu Cc: Nate DeSimone Cc: Liming Gao Cc: Eric Dong Reviewed-by: Chasel Chiu --- .../Library/CompressLib/CompressLib.c | 177 +++++++++--------- .../Library/CompressLib/CompressLib.inf | 4 +- 2 files changed, 95 insertions(+), 86 deletions(-) diff --git a/Platform/Intel/MinPlatformPkg/Library/CompressLib/CompressLib.= c b/Platform/Intel/MinPlatformPkg/Library/CompressLib/CompressLib.c index 537eb3b693..a9aeea32c1 100644 --- a/Platform/Intel/MinPlatformPkg/Library/CompressLib/CompressLib.c +++ b/Platform/Intel/MinPlatformPkg/Library/CompressLib/CompressLib.c @@ -7,7 +7,7 @@ This sequence is further divided into Blocks and Huffman codings are applied to each Block. =20 - Copyright (c) 2007 - 2014, Intel Corporation. All rights reserved.
+ Copyright (c) 2007 - 2020, Intel Corporation. All rights reserved.
SPDX-License-Identifier: BSD-2-Clause-Patent =20 **/ @@ -31,7 +31,6 @@ // Macro Definitions // typedef INT16 NODE; -#define UINT8_MAX 0xff #define UINT8_BIT 8 #define THRESHOLD 3 #define INIT_CRC 0 @@ -42,7 +41,7 @@ typedef INT16 NODE; #define PERC_FLAG 0x8000U #define CODE_BIT 16 #define NIL 0 -#define MAX_HASH_VAL (3 * WNDSIZ + (WNDSIZ / 512 + 1) * UINT8_MAX) +#define MAX_HASH_VAL (3 * WNDSIZ + (WNDSIZ / 512 + 1) * MAX_UINT8) #define HASH(LoopVar7, LoopVar5) ((LoopVar7) + ((LoopVar5) << (WNDB= IT - 9)) + WNDSIZ * 2) #define CRCPOLY 0xA001 #define UPDATE_CRC(LoopVar5) mCrc =3D mCrcTable[(mCrc ^ (LoopVar5)) & = 0xFF] ^ (mCrc >> UINT8_BIT) @@ -50,7 +49,7 @@ typedef INT16 NODE; // // C: the Char&Len Set; P: the Position Set; T: the exTra Set // -#define NC (UINT8_MAX + MAXMATCH + 2 - THRESHOLD) +#define NC (MAX_UINT8 + MAXMATCH + 2 - THRESHOLD) #define CBIT 9 #define NP (WNDBIT + 1) #define PBIT 4 @@ -66,13 +65,13 @@ typedef INT16 NODE; // =20 /** - Put a dword to output stream + Put a dword to output stream. =20 @param[in] Data The dword to put. **/ VOID EFIAPI -PutDword( +PutDword ( IN UINT32 Data ); =20 @@ -110,7 +109,7 @@ STATIC UINT16 *mSortPtr; STATIC UINT16 mLenCnt[17]; STATIC UINT16 mLeft[2 * NC - 1]; STATIC UINT16 mRight[2 * NC - 1]; -STATIC UINT16 mCrcTable[UINT8_MAX + 1]; +STATIC UINT16 mCrcTable[MAX_UINT8 + 1]; STATIC UINT16 mCFreq[2 * NC - 1]; STATIC UINT16 mCCode[NC]; STATIC UINT16 mPFreq[2 * NP - 1]; @@ -142,7 +141,7 @@ MakeCrcTable ( =20 UINT32 LoopVar4; =20 - for (LoopVar1 =3D 0; LoopVar1 <=3D UINT8_MAX; LoopVar1++) { + for (LoopVar1 =3D 0; LoopVar1 <=3D MAX_UINT8; LoopVar1++) { LoopVar4 =3D LoopVar1; for (LoopVar2 =3D 0; LoopVar2 < UINT8_BIT; LoopVar2++) { if ((LoopVar4 & 1) !=3D 0) { @@ -186,7 +185,7 @@ PutDword ( =20 /** Allocate memory spaces for data structures used in compression process. - =20 + @retval EFI_SUCCESS Memory was allocated successfully. @retval EFI_OUT_OF_RESOURCES A memory allocation failed. **/ @@ -197,9 +196,9 @@ AllocateMemory ( ) { mText =3D AllocateZeroPool (WNDSIZ * 2 + MAXMATCH); - mLevel =3D AllocateZeroPool ((WNDSIZ + UINT8_MAX + 1) * sizeof (*mL= evel)); - mChildCount =3D AllocateZeroPool ((WNDSIZ + UINT8_MAX + 1) * sizeof (*mC= hildCount)); - mPosition =3D AllocateZeroPool ((WNDSIZ + UINT8_MAX + 1) * sizeof (*mP= osition)); + mLevel =3D AllocateZeroPool ((WNDSIZ + MAX_UINT8 + 1) * sizeof (*mL= evel)); + mChildCount =3D AllocateZeroPool ((WNDSIZ + MAX_UINT8 + 1) * sizeof (*mC= hildCount)); + mPosition =3D AllocateZeroPool ((WNDSIZ + MAX_UINT8 + 1) * sizeof (*mP= osition)); mParent =3D AllocateZeroPool (WNDSIZ * 2 * sizeof (*mParent)); mPrev =3D AllocateZeroPool (WNDSIZ * 2 * sizeof (*mPrev)); mNext =3D AllocateZeroPool ((MAX_HASH_VAL + 1) * sizeof (*mNext)); @@ -251,8 +250,8 @@ InitSlide ( { NODE LoopVar1; =20 - SetMem (mLevel + WNDSIZ, (UINT8_MAX + 1) * sizeof (UINT8), 1); - SetMem (mPosition + WNDSIZ, (UINT8_MAX + 1) * sizeof (NODE), 0); + SetMem (mLevel + WNDSIZ, (MAX_UINT8 + 1) * sizeof (UINT8), 1); + SetMem (mPosition + WNDSIZ, (MAX_UINT8 + 1) * sizeof (NODE), 0); =20 SetMem (mParent + WNDSIZ, WNDSIZ * sizeof (NODE), 0); =20 @@ -284,7 +283,7 @@ Child ( { NODE LoopVar4; =20 - LoopVar4 =3D mNext[HASH (LoopVar6, LoopVar5)]; + LoopVar4 =3D mNext[HASH (LoopVar6, LoopVar5)]; mParent[NIL] =3D LoopVar6; /* sentinel */ while (mParent[LoopVar4] !=3D LoopVar6) { LoopVar4 =3D mNext[LoopVar4]; @@ -299,6 +298,7 @@ Child ( @param[in] LoopVar6 The parent node. @param[in] LoopVar5 The edge character. @param[in] LoopVar4 The child node. + **/ VOID EFIAPI @@ -326,6 +326,7 @@ MakeChild ( Split a node. =20 @param[in] Old The node to split. + **/ VOID EFIAPI @@ -340,12 +341,12 @@ Split ( New =3D mAvail; mAvail =3D mNext[New]; mChildCount[New] =3D 0; - LoopVar10 =3D mPrev[Old]; + LoopVar10 =3D mPrev[Old]; mPrev[New] =3D LoopVar10; - mNext[LoopVar10] =3D New; - LoopVar10 =3D mNext[Old]; + mNext[LoopVar10] =3D New; + LoopVar10 =3D mNext[Old]; mNext[New] =3D LoopVar10; - mPrev[LoopVar10] =3D New; + mPrev[LoopVar10] =3D New; mParent[New] =3D mParent[Old]; mLevel[New] =3D (UINT8) mMatchLen; mPosition[New] =3D mPos; @@ -414,7 +415,7 @@ InsertNode ( if (LoopVar4 =3D=3D NIL) { MakeChild (LoopVar6, LoopVar5, mPos); mMatchLen =3D 1; - return ; + return; } =20 mMatchLen =3D 2; @@ -426,10 +427,10 @@ InsertNode ( // for (;;) { if (LoopVar4 >=3D WNDSIZ) { - LoopVar2 =3D MAXMATCH; + LoopVar2 =3D MAXMATCH; mMatchPos =3D LoopVar4; } else { - LoopVar2 =3D mLevel[LoopVar4]; + LoopVar2 =3D mLevel[LoopVar4]; mMatchPos =3D (NODE) (mPosition[LoopVar4] & ~PERC_FLAG); } =20 @@ -437,12 +438,12 @@ InsertNode ( mMatchPos -=3D WNDSIZ; } =20 - TempString3 =3D &mText[mPos + mMatchLen]; - TempString2 =3D &mText[mMatchPos + mMatchLen]; + TempString3 =3D &mText[mPos + mMatchLen]; + TempString2 =3D &mText[mMatchPos + mMatchLen]; while (mMatchLen < LoopVar2) { if (*TempString3 !=3D *TempString2) { Split (LoopVar4); - return ; + return; } =20 mMatchLen++; @@ -459,20 +460,20 @@ InsertNode ( LoopVar4 =3D Child (LoopVar6, *TempString3); if (LoopVar4 =3D=3D NIL) { MakeChild (LoopVar6, *TempString3, mPos); - return ; + return; } =20 mMatchLen++; } =20 LoopVar10 =3D mPrev[LoopVar4]; - mPrev[mPos] =3D LoopVar10; + mPrev[mPos] =3D LoopVar10; mNext[LoopVar10] =3D mPos; LoopVar10 =3D mNext[LoopVar4]; - mNext[mPos] =3D LoopVar10; + mNext[mPos] =3D LoopVar10; mPrev[LoopVar10] =3D mPos; - mParent[mPos] =3D LoopVar6; - mParent[LoopVar4] =3D NIL; + mParent[mPos] =3D LoopVar6; + mParent[LoopVar4] =3D NIL; =20 // // Special usage of 'next' @@ -503,22 +504,22 @@ DeleteNode ( NODE LoopVar9; =20 if (mParent[mPos] =3D=3D NIL) { - return ; + return; } =20 LoopVar4 =3D mPrev[mPos]; - LoopVar11 =3D mNext[mPos]; + LoopVar11 =3D mNext[mPos]; mNext[LoopVar4] =3D LoopVar11; - mPrev[LoopVar11] =3D LoopVar4; + mPrev[LoopVar11] =3D LoopVar4; LoopVar4 =3D mParent[mPos]; - mParent[mPos] =3D NIL; + mParent[mPos] =3D NIL; if (LoopVar4 >=3D WNDSIZ) { - return ; + return; } =20 mChildCount[LoopVar4]--; if (mChildCount[LoopVar4] > 1) { - return ; + return; } =20 LoopVar10 =3D (NODE) (mPosition[LoopVar4] & ~PERC_FLAG); @@ -529,7 +530,7 @@ DeleteNode ( LoopVar11 =3D LoopVar10; LoopVar6 =3D mParent[LoopVar4]; LoopVar9 =3D mPosition[LoopVar6]; - while ((LoopVar9 & PERC_FLAG) !=3D 0){ + while ((LoopVar9 & PERC_FLAG) !=3D 0) { LoopVar9 &=3D ~PERC_FLAG; if (LoopVar9 >=3D mPos) { LoopVar9 -=3D WNDSIZ; @@ -558,9 +559,9 @@ DeleteNode ( =20 LoopVar11 =3D Child (LoopVar4, mText[LoopVar10 + mLevel[LoopVa= r4]]); LoopVar10 =3D mPrev[LoopVar11]; - LoopVar9 =3D mNext[LoopVar11]; + LoopVar9 =3D mNext[LoopVar11]; mNext[LoopVar10] =3D LoopVar9; - mPrev[LoopVar9] =3D LoopVar10; + mPrev[LoopVar9] =3D LoopVar10; LoopVar10 =3D mPrev[LoopVar4]; mNext[LoopVar10] =3D LoopVar11; mPrev[LoopVar11] =3D LoopVar10; @@ -568,9 +569,9 @@ DeleteNode ( mPrev[LoopVar10] =3D LoopVar11; mNext[LoopVar11] =3D LoopVar10; mParent[LoopVar11] =3D mParent[LoopVar4]; - mParent[LoopVar4] =3D NIL; - mNext[LoopVar4] =3D mAvail; - mAvail =3D LoopVar4; + mParent[LoopVar4] =3D NIL; + mNext[LoopVar4] =3D mAvail; + mAvail =3D LoopVar4; } =20 /** @@ -580,6 +581,7 @@ DeleteNode ( @param[in] LoopVar8 The number of bytes to read. =20 @return The number of bytes actually read. + **/ INT32 EFIAPI @@ -613,6 +615,7 @@ FreadCrc ( =20 @retval TRUE The operation was successful. @retval FALSE The operation failed due to insufficient memory. + **/ BOOLEAN EFIAPI @@ -647,12 +650,13 @@ GetNextMatch ( /** Send entry LoopVar1 down the queue. =20 - @param[in] LoopVar1 The index of the item to move. + @param[in] Index The index of the item to move. + **/ VOID EFIAPI DownHeap ( - IN INT32 i + IN INT32 Index ) { INT32 LoopVar1; @@ -660,10 +664,10 @@ DownHeap ( INT32 LoopVar2; =20 // - // priority queue: send i-th entry down heap + // priority queue: send Index-th entry down heap // - LoopVar2 =3D mHeap[i]; - LoopVar1 =3D 2 * i; + LoopVar2 =3D mHeap[Index]; + LoopVar1 =3D 2 * Index; while (LoopVar1 <=3D mHeapSize) { if (LoopVar1 < mHeapSize && mFreq[mHeap[LoopVar1]] > mFreq[mHeap[LoopV= ar1 + 1]]) { LoopVar1++; @@ -673,18 +677,19 @@ DownHeap ( break; } =20 - mHeap[i] =3D mHeap[LoopVar1]; - i =3D LoopVar1; - LoopVar1 =3D 2 * i; + mHeap[Index] =3D mHeap[LoopVar1]; + Index =3D LoopVar1; + LoopVar1 =3D 2 * Index; } =20 - mHeap[i] =3D (INT16) LoopVar2; + mHeap[Index] =3D (INT16) LoopVar2; } =20 /** Count the number of each code length for a Huffman tree. =20 @param[in] LoopVar1 The top node. + **/ VOID EFIAPI @@ -758,17 +763,18 @@ MakeLen ( =20 /** Assign code to each symbol based on the code length array. - =20 + @param[in] LoopVar8 The number of symbols. @param[in] Len The code length array. @param[out] Code The stores codes for each symbol. + **/ VOID EFIAPI MakeCode ( IN INT32 LoopVar8, - IN UINT8 Len[ ], - OUT UINT16 Code[ ] + IN UINT8 Len[], + OUT UINT16 Code[] ) { INT32 LoopVar1; @@ -783,7 +789,7 @@ MakeCode ( Code[LoopVar1] =3D Start[Len[LoopVar1]]++; } } - =20 + /** Generates Huffman codes given a frequency distribution of symbols. =20 @@ -793,14 +799,15 @@ MakeCode ( @param[out] CodeParm The code for each symbol. =20 @return The root of the Huffman tree. + **/ INT32 EFIAPI MakeTree ( IN INT32 NParm, - IN UINT16 FreqParm[ ], - OUT UINT8 LenParm[ ], - OUT UINT16 CodeParm[ ] + IN UINT16 FreqParm[], + OUT UINT8 LenParm[], + OUT UINT16 CodeParm[] ) { INT32 LoopVar1; @@ -815,11 +822,11 @@ MakeTree ( // make tree, calculate len[], return root // mTempInt32 =3D NParm; - mFreq =3D FreqParm; - mLen =3D LenParm; - Avail =3D mTempInt32; - mHeapSize =3D 0; - mHeap[1] =3D 0; + mFreq =3D FreqParm; + mLen =3D LenParm; + Avail =3D mTempInt32; + mHeapSize =3D 0; + mHeap[1] =3D 0; for (LoopVar1 =3D 0; LoopVar1 < mTempInt32; LoopVar1++) { mLen[LoopVar1] =3D 0; if ((mFreq[LoopVar1]) !=3D 0) { @@ -856,7 +863,7 @@ MakeTree ( =20 LoopVar3 =3D Avail++; mFreq[LoopVar3] =3D (UINT16) (mFreq[LoopVar1] + mFreq[LoopVar2]); - mHeap[1] =3D (INT16) LoopVar3; + mHeap[1] =3D (INT16) LoopVar3; DownHeap (1); mLeft[LoopVar3] =3D (UINT16) LoopVar1; mRight[LoopVar3] =3D (UINT16) LoopVar2; @@ -877,6 +884,7 @@ MakeTree ( =20 @param[in] LoopVar8 The rightmost LoopVar8 bits of the data is used. @param[in] x The data. + **/ VOID EFIAPI @@ -891,7 +899,7 @@ PutBits ( mSubBitBuf |=3D x << (mBitCount -=3D LoopVar8); } else { =20 - Temp =3D (UINT8)(mSubBitBuf | (x >> (LoopVar8 -=3D mBitCount))); + Temp =3D (UINT8) (mSubBitBuf | (x >> (LoopVar8 -=3D mBitCount))); if (mDst < mDstUpperLimit) { *mDst++ =3D Temp; } @@ -901,7 +909,7 @@ PutBits ( mSubBitBuf =3D x << (mBitCount =3D UINT8_BIT - LoopVar8); } else { =20 - Temp =3D (UINT8)(x >> (LoopVar8 - UINT8_BIT)); + Temp =3D (UINT8) (x >> (LoopVar8 - UINT8_BIT)); if (mDst < mDstUpperLimit) { *mDst++ =3D Temp; } @@ -950,7 +958,7 @@ EncodeP ( =20 PutBits (mPTLen[LoopVar5], mPTCode[LoopVar5]); if (LoopVar5 > 1) { - PutBits(LoopVar5 - 1, LoopVar7 & (0xFFFFU >> (17 - LoopVar5))); + PutBits (LoopVar5 - 1, LoopVar7 & (0xFFFFU >> (17 - LoopVar5))); } } =20 @@ -1057,6 +1065,7 @@ WritePTLen ( =20 /** Outputs the code length array for Char&Length Set. + **/ VOID EFIAPI @@ -1136,8 +1145,8 @@ SendBlock ( UINT32 Size; Flags =3D 0; =20 - Root =3D MakeTree (NC, mCFreq, mCLen, mCCode); - Size =3D mCFreq[Root]; + Root =3D MakeTree (NC, mCFreq, mCLen, mCCode); + Size =3D mCFreq[Root]; PutBits (16, Size); if (Root >=3D NC) { CountTFreq (); @@ -1172,8 +1181,8 @@ SendBlock ( } else { Flags <<=3D 1; } - if ((Flags & (1U << (UINT8_BIT - 1))) !=3D 0){ - EncodeC(mBuf[Pos++] + (1U << UINT8_BIT)); + if ((Flags & (1U << (UINT8_BIT - 1))) !=3D 0) { + EncodeC (mBuf[Pos++] + (1U << UINT8_BIT)); LoopVar3 =3D mBuf[Pos++] << UINT8_BIT; LoopVar3 +=3D mBuf[Pos++]; =20 @@ -1209,7 +1218,7 @@ HufEncodeStart ( /** Outputs an Original Character or a Pointer. =20 - @param[in] LoopVar5 The original character or the 'String Length' el= ement of=20 + @param[in] LoopVar5 The original character or the 'String Length' el= ement of a Pointer. @param[in] LoopVar7 The 'Position' field of a Pointer. **/ @@ -1235,11 +1244,11 @@ CompressOutput ( mBuf[mOutputPos++] =3D (UINT8) LoopVar5; mCFreq[LoopVar5]++; if (LoopVar5 >=3D (1U << UINT8_BIT)) { - mBuf[CPos] =3D (UINT8)(mBuf[CPos]|mOutputMask); - mBuf[mOutputPos++] =3D (UINT8)(LoopVar7 >> UINT8_BIT); + mBuf[CPos] =3D (UINT8) (mBuf[CPos]|mOutputMask); + mBuf[mOutputPos++] =3D (UINT8) (LoopVar7 >> UINT8_BIT); mBuf[mOutputPos++] =3D (UINT8) LoopVar7; - LoopVar5 =3D 0; - while (LoopVar7!=3D0) { + LoopVar5 =3D 0; + while (LoopVar7 !=3D 0) { LoopVar7 >>=3D 1; LoopVar5++; } @@ -1301,8 +1310,8 @@ Encode ( } =20 while (mRemainder > 0) { - LastMatchLen =3D mMatchLen; - LastMatchPos =3D mMatchPos; + LastMatchLen =3D mMatchLen; + LastMatchPos =3D mMatchPos; if (!GetNextMatch ()) { Status =3D EFI_OUT_OF_RESOURCES; } @@ -1315,14 +1324,14 @@ Encode ( // Not enough benefits are gained by outputting a pointer, // so just output the original character // - CompressOutput(mText[mPos - 1], 0); + CompressOutput (mText[mPos - 1], 0); } else { // // Outputting a pointer is beneficial enough, do it. // =20 - CompressOutput(LastMatchLen + (UINT8_MAX + 1 - THRESHOLD), - (mPos - LastMatchPos - 2) & (WNDSIZ - 1)); + CompressOutput (LastMatchLen + (MAX_UINT8 + 1 - THRESHOLD), + (mPos - LastMatchPos - 2) & (WNDSIZ - 1)); LastMatchLen--; while (LastMatchLen > 0) { if (!GetNextMatch ()) { @@ -1381,15 +1390,15 @@ Compress ( mSrc =3D SrcBuffer; mSrcUpperLimit =3D mSrc + SrcSize; mDst =3D DstBuffer; - mDstUpperLimit =3D mDst +*DstSize; + mDstUpperLimit =3D mDst + *DstSize; =20 PutDword (0L); PutDword (0L); =20 MakeCrcTable (); =20 - mOrigSize =3D mCompSize =3D 0; - mCrc =3D INIT_CRC; + mOrigSize =3D mCompSize =3D 0; + mCrc =3D INIT_CRC; =20 // // Compress it diff --git a/Platform/Intel/MinPlatformPkg/Library/CompressLib/CompressLib.= inf b/Platform/Intel/MinPlatformPkg/Library/CompressLib/CompressLib.inf index 6a8ac3c588..4e069246d0 100644 --- a/Platform/Intel/MinPlatformPkg/Library/CompressLib/CompressLib.inf +++ b/Platform/Intel/MinPlatformPkg/Library/CompressLib/CompressLib.inf @@ -1,7 +1,7 @@ ## @file -# UEFI Decompress Library implementation. +# UEFI Compression Library implementation. # -# Copyright (c) 2007 - 2014, Intel Corporation. All rights reserved.
+# Copyright (c) 2007 - 2020, Intel Corporation. All rights reserved.
# # SPDX-License-Identifier: BSD-2-Clause-Patent # --=20 2.27.0.windows.1 -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#65736): https://edk2.groups.io/g/devel/message/65736 Mute This Topic: https://groups.io/mt/77208967/1787277 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [importer@patchew.org] -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-