From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mga14.intel.com (mga14.intel.com [192.55.52.115]) by mx.groups.io with SMTP id smtpd.web11.6794.1606808640482515727 for ; Mon, 30 Nov 2020 23:44:00 -0800 Authentication-Results: mx.groups.io; dkim=missing; spf=pass (domain: intel.com, ip: 192.55.52.115, mailfrom: gregx.yeh@intel.com) IronPort-SDR: tz9dC/crCgQUfQAhkzHe/lxelWbfH6qPtz1EO7ZdXLD8HNnbCaxQwyL83DvYDmfyfFBMjym5bU hONcyidufYKA== X-IronPort-AV: E=McAfee;i="6000,8403,9821"; a="171997944" X-IronPort-AV: E=Sophos;i="5.78,383,1599548400"; d="scan'208";a="171997944" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga005.jf.intel.com ([10.7.209.41]) by fmsmga103.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 30 Nov 2020 23:43:59 -0800 IronPort-SDR: Bi8bSMjTUFJ6KRxuNoz13bmRcxL6avGdNLAFADt4FnuIeLlWs2v9bjGSU/hrqH0U0g6ZHK8URi y0nev5t3Id9A== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.78,383,1599548400"; d="scan'208";a="549453968" Received: from chinghux-desk1.gar.corp.intel.com ([10.5.215.141]) by orsmga005.jf.intel.com with ESMTP; 30 Nov 2020 23:43:58 -0800 From: "GregX Yeh" To: devel@edk2.groups.io Cc: Bob Feng , Liming Gao Subject: [PATCH] [edk2-staging] BaseTools/FMMT: Replace file failure when FV level over 2 Date: Tue, 1 Dec 2020 15:43:55 +0800 Message-Id: <20201201074355.21964-1-gregx.yeh@intel.com> X-Mailer: git-send-email 2.16.2.windows.1 Fixed replace file failure when FFS in multi level FV and FV level over 2. Signed-off-by: GregX Yeh Cc: Bob Feng Cc: Liming Gao --- BaseTools/Source/C/FMMT/FmmtLib.c | 25 +++++++------------------ 1 file changed, 7 insertions(+), 18 deletions(-) diff --git a/BaseTools/Source/C/FMMT/FmmtLib.c b/BaseTools/Source/C/FMMT/FmmtLib.c index b945e9b63d..952d64fc35 100644 --- a/BaseTools/Source/C/FMMT/FmmtLib.c +++ b/BaseTools/Source/C/FMMT/FmmtLib.c @@ -709,10 +709,10 @@ LibGenFfsFile ( free(FfsFileName); FfsFileName = NULL; - CurrentFv->FfsNumbers = *FfsCount; - *FfsCount += 1; + CurrentFv->FfsNumbers = *FfsCount; + if (ErasePolarity) { CurrentFile->State = (UINT8)~(CurrentFile->State); } @@ -833,7 +833,6 @@ LibParseSection ( CHAR8 *ToolInputFileName; CHAR8 *ToolOutputFileName; BOOLEAN HasUiSection; - BOOLEAN FirstInFlag; DataOffset = 0; GuidAttr = 0; @@ -869,7 +868,6 @@ LibParseSection ( EncapDataNeedUpdata = TRUE; LargeHeaderOffset = 0; HasUiSection = FALSE; - FirstInFlag = TRUE; while (ParsedLength < BufferLength) { @@ -997,9 +995,7 @@ LibParseSection ( break; case EFI_SECTION_COMPRESSION: - if (FirstInFlag) { - Level ++; - } + Level ++; NumberOfSections ++; EncapDataNeedUpdata = TRUE; @@ -1181,9 +1177,7 @@ LibParseSection ( // looks up the appropriate tool to use for extracting // a GUID defined FV section. // - if (FirstInFlag) { - Level ++; - } + Level ++; NumberOfSections++; EncapDataNeedUpdata = TRUE; HasUiSection = TRUE; @@ -1682,7 +1676,6 @@ LibParseSection ( } ParsedLength += SectionLength; - FirstInFlag = FALSE; // // We make then next section begin on a 4-byte boundary // @@ -4274,7 +4267,7 @@ LibEncapNewFvFile( LocalEncapDataNext = LocalEncapDataTemp->NextNode; if (LocalEncapDataNext != NULL && LocalEncapDataNext->NextNode != NULL) { - LibEncapNewFvFile(FvInFd, TemDir, LocalEncapDataTemp, 1, &ChildFileNameList); + LibEncapNewFvFile(FvInFd, TemDir, LocalEncapDataTemp,LocalEncapDataTemp->Level - 1, &ChildFileNameList); ChildFileNameList->ParentLevel = LocalEncapDataTemp->Level -1; if (FvInFd->ChildFvFFS == NULL) { FvInFd->ChildFvFFS = ChildFileNameList; @@ -4329,7 +4322,7 @@ LibEncapNewFvFile( } else { LocalEncapData = CurrentEncapData; while (LocalEncapData != NULL) { - if (Level_Break > 1 && LocalEncapData->Type == FMMT_ENCAP_TREE_FFS) { + if (LocalEncapData->Type == FMMT_ENCAP_TREE_FFS) { LocalEncapDataTemp = LocalEncapData->RightNode; while (LocalEncapDataTemp != NULL) { LocalEncapDataNext = LocalEncapDataTemp->NextNode; @@ -4485,7 +4478,7 @@ LibEncapNewFvFile( // FfsFoundFlag = FALSE; IsRootFv = FALSE; - for (Index=0; Index <= FvInFd->FfsNumbers; Index++) { + for (Index=0; Index < FvInFd->FfsNumbers; Index++) { if (OutputFileNameList != NULL && OutputFileNameList->FFSName != NULL && OutputFileNameList->IsFFS == FALSE){ break; } @@ -5077,10 +5070,6 @@ LibEncapNewFvFile( if (CurrentEncapData == NULL) { LocalEncapData = FvInFd->EncapData; } else { - if (OutputFileNameList != NULL && OutputFileNameList->FFSName != NULL && OutputFileNameList->IsFFS == TRUE) { - *OutputFile = OutputFileNameList; - return EFI_SUCCESS; - } LocalEncapData = CurrentEncapData; } ParentLevel -= 1; -- 2.16.2.windows.1