From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: mx.groups.io; dkim=missing; spf=pass (domain: intel.com, ip: 134.134.136.31, mailfrom: eric.jin@intel.com) Received: from mga06.intel.com (mga06.intel.com [134.134.136.31]) by groups.io with SMTP; Thu, 01 Aug 2019 01:47:40 -0700 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga006.fm.intel.com ([10.253.24.20]) by orsmga104.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 01 Aug 2019 01:47:39 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.64,333,1559545200"; d="scan'208";a="372535304" Received: from jjin9-mobl.ccr.corp.intel.com ([10.239.192.65]) by fmsmga006.fm.intel.com with ESMTP; 01 Aug 2019 01:47:38 -0700 From: "Eric Jin" To: devel@edk2.groups.io Cc: Sean Brogan , Bret Barkelew , Liming Gao , Michael D Kinney Subject: [PATCH 12/14] FmpDevicePkg/FmpDxe: Change where FmpControllerState is updated Date: Thu, 1 Aug 2019 16:47:35 +0800 Message-Id: <20190801084735.10116-1-eric.jin@intel.com> X-Mailer: git-send-email 2.20.1.windows.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit REF: https://bugzilla.tianocore.org/show_bug.cgi?id=1525 In the 4 Setxxx() functions, do not update FmpControllerState contents unless Update is TRUE. This does not change any behavior, but it does make the logic easier to understand. Cc: Sean Brogan Cc: Bret Barkelew Cc: Liming Gao Signed-off-by: Michael D Kinney Reviewed-by: Eric Jin --- FmpDevicePkg/FmpDxe/VariableSupport.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/FmpDevicePkg/FmpDxe/VariableSupport.c b/FmpDevicePkg/FmpDxe/VariableSupport.c index 414a077ab2..a2deff94a5 100644 --- a/FmpDevicePkg/FmpDxe/VariableSupport.c +++ b/FmpDevicePkg/FmpDxe/VariableSupport.c @@ -498,11 +498,11 @@ SetVersionInVariable ( if (FmpControllerState->Version != Version) { Update = TRUE; } - FmpControllerState->VersionValid = TRUE; - FmpControllerState->Version = Version; if (!Update) { DEBUG ((DEBUG_INFO, "FmpDxe(%s): No need to update controller state. Same value as before.\n", mImageIdName)); } else { + FmpControllerState->VersionValid = TRUE; + FmpControllerState->Version = Version; Status = gRT->SetVariable ( Private->FmpStateVariableName, &gEfiCallerIdGuid, @@ -561,11 +561,11 @@ SetLowestSupportedVersionInVariable ( if (FmpControllerState->Lsv < LowestSupportedVersion) { Update = TRUE; } - FmpControllerState->LsvValid = TRUE; - FmpControllerState->Lsv = LowestSupportedVersion; if (!Update) { DEBUG ((DEBUG_INFO, "FmpDxe(%s): No need to update controller state. Same value as before.\n", mImageIdName)); } else { + FmpControllerState->LsvValid = TRUE; + FmpControllerState->Lsv = LowestSupportedVersion; Status = gRT->SetVariable ( Private->FmpStateVariableName, &gEfiCallerIdGuid, @@ -624,11 +624,11 @@ SetLastAttemptStatusInVariable ( if (FmpControllerState->LastAttemptStatus != LastAttemptStatus) { Update = TRUE; } - FmpControllerState->LastAttemptStatusValid = TRUE; - FmpControllerState->LastAttemptStatus = LastAttemptStatus; if (!Update) { DEBUG ((DEBUG_INFO, "FmpDxe(%s): No need to update controller state. Same value as before.\n", mImageIdName)); } else { + FmpControllerState->LastAttemptStatusValid = TRUE; + FmpControllerState->LastAttemptStatus = LastAttemptStatus; Status = gRT->SetVariable ( Private->FmpStateVariableName, &gEfiCallerIdGuid, @@ -687,11 +687,11 @@ SetLastAttemptVersionInVariable ( if (FmpControllerState->LastAttemptVersion != LastAttemptVersion) { Update = TRUE; } - FmpControllerState->LastAttemptVersionValid = TRUE; - FmpControllerState->LastAttemptVersion = LastAttemptVersion; if (!Update) { DEBUG ((DEBUG_INFO, "FmpDxe(%s): No need to update controller state. Same value as before.\n", mImageIdName)); } else { + FmpControllerState->LastAttemptVersionValid = TRUE; + FmpControllerState->LastAttemptVersion = LastAttemptVersion; Status = gRT->SetVariable ( Private->FmpStateVariableName, &gEfiCallerIdGuid, -- 2.20.1.windows.1