From: "Yao, Jiewen" <jiewen.yao@intel.com>
To: "Kinney, Michael D" <michael.d.kinney@intel.com>,
"devel@edk2.groups.io" <devel@edk2.groups.io>
Cc: "Wang, Jian J" <jian.j.wang@intel.com>
Subject: Re: [Patch 08/12] SecurityPkg/Library/SecureBootVariableLib: Fix VS20xx 4122 errors
Date: Sun, 26 Mar 2023 02:50:34 +0000 [thread overview]
Message-ID: <MW4PR11MB58723A28E28D8AE6C9D698F98C8A9@MW4PR11MB5872.namprd11.prod.outlook.com> (raw)
In-Reply-To: <20230325184541.596-9-michael.d.kinney@intel.com>
Reviewed-by: Jiewen Yao
> -----Original Message-----
> From: Kinney, Michael D <michael.d.kinney@intel.com>
> Sent: Sunday, March 26, 2023 2:46 AM
> To: devel@edk2.groups.io
> Cc: Yao, Jiewen <jiewen.yao@intel.com>; Wang, Jian J
> <jian.j.wang@intel.com>
> Subject: [Patch 08/12] SecurityPkg/Library/SecureBootVariableLib: Fix
> VS20xx 4122 errors
>
> The unit test code for the SecureBootVariableLib is initializing
> local variable structures in their declaration from other local
> variables that are also initialized in their declaration. ANSI C
> does not allow this and error 4122 is generated on VS20xx compilers.
>
> The test cases are updated to initialize the local structure
> fields in C statements instead of their local variable declaration.
>
> Cc: Jiewen Yao <jiewen.yao@intel.com>
> Cc: Jian J Wang <jian.j.wang@intel.com>
> Signed-off-by: Michael D Kinney <michael.d.kinney@intel.com>
> ---
> .../UnitTest/SecureBootVariableLibUnitTest.c | 170 +++++++++---------
> 1 file changed, 83 insertions(+), 87 deletions(-)
>
> diff --git
> a/SecurityPkg/Library/SecureBootVariableLib/UnitTest/SecureBootVariableLi
> bUnitTest.c
> b/SecurityPkg/Library/SecureBootVariableLib/UnitTest/SecureBootVariableLi
> bUnitTest.c
> index 3a92d5d83457..e4cdc68bbb35 100644
> ---
> a/SecurityPkg/Library/SecureBootVariableLib/UnitTest/SecureBootVariableLi
> bUnitTest.c
> +++
> b/SecurityPkg/Library/SecureBootVariableLib/UnitTest/SecureBootVariableLi
> bUnitTest.c
> @@ -351,10 +351,10 @@ SecureBootCreateDataFromInputSimple (
> UINTN SigListSize = 0;
> EFI_STATUS Status;
> UINT8 TestData[] = { 0 };
> - SECURE_BOOT_CERTIFICATE_INFO KeyInfo = {
> - .Data = TestData,
> - .DataSize = sizeof (TestData)
> - };
> + SECURE_BOOT_CERTIFICATE_INFO KeyInfo;
> +
> + KeyInfo.Data = TestData;
> + KeyInfo.DataSize = sizeof (TestData);
>
> Status = SecureBootCreateDataFromInput (&SigListSize, &SigList, 1,
> &KeyInfo);
>
> @@ -441,16 +441,12 @@ SecureBootCreateDataFromInputMultiple (
> UINT8 TestData1[] = { 0 };
> UINT8 TestData2[] = { 1, 2 };
> EFI_STATUS Status;
> - SECURE_BOOT_CERTIFICATE_INFO KeyInfo[2] = {
> - {
> - .Data = TestData1,
> - .DataSize = sizeof (TestData1)
> - },
> - {
> - .Data = TestData2,
> - .DataSize = sizeof (TestData2)
> - }
> - };
> + SECURE_BOOT_CERTIFICATE_INFO KeyInfo[2];
> +
> + KeyInfo[0].Data = TestData1;
> + KeyInfo[0].DataSize = sizeof (TestData1);
> + KeyInfo[1].Data = TestData2;
> + KeyInfo[1].DataSize = sizeof (TestData2);
>
> Status = SecureBootCreateDataFromInput (&SigListSize, &SigList, 2,
> KeyInfo);
> UT_ASSERT_NOT_EFI_ERROR (Status);
> @@ -1219,19 +1215,19 @@ SetSecureBootVariablesShouldComplete (
> UINT8 PkDummy = 0xFE;
> UINT8 *Payload = NULL;
> UINTN PayloadSize = sizeof (DbDummy);
> - SECURE_BOOT_PAYLOAD_INFO PayloadInfo = {
> - .DbPtr = &DbDummy,
> - .DbSize = sizeof (DbDummy),
> - .DbxPtr = &DbxDummy,
> - .DbxSize = sizeof (DbxDummy),
> - .DbtPtr = &DbtDummy,
> - .DbtSize = sizeof (DbtDummy),
> - .KekPtr = &KekDummy,
> - .KekSize = sizeof (KekDummy),
> - .PkPtr = &PkDummy,
> - .PkSize = sizeof (PkDummy),
> - .SecureBootKeyName = L"Food"
> - };
> + SECURE_BOOT_PAYLOAD_INFO PayloadInfo;
> +
> + PayloadInfo.DbPtr = &DbDummy;
> + PayloadInfo.DbSize = sizeof (DbDummy);
> + PayloadInfo.DbxPtr = &DbxDummy;
> + PayloadInfo.DbxSize = sizeof (DbxDummy);
> + PayloadInfo.DbtPtr = &DbtDummy;
> + PayloadInfo.DbtSize = sizeof (DbtDummy);
> + PayloadInfo.KekPtr = &KekDummy;
> + PayloadInfo.KekSize = sizeof (KekDummy);
> + PayloadInfo.PkPtr = &PkDummy;
> + PayloadInfo.PkSize = sizeof (PkDummy);
> + PayloadInfo.SecureBootKeyName = L"Food";
>
> expect_memory (MockGetVariable, VariableName,
> EFI_SECURE_BOOT_MODE_NAME, sizeof
> (EFI_SECURE_BOOT_MODE_NAME));
> expect_value (MockGetVariable, VendorGuid, &gEfiGlobalVariableGuid);
> @@ -1385,11 +1381,11 @@ SetSecureBootVariablesShouldStopFailDBX (
> UINT8 DbxDummy = 0xBE;
> UINT8 *Payload = NULL;
> UINTN PayloadSize = sizeof (DbxDummy);
> - SECURE_BOOT_PAYLOAD_INFO PayloadInfo = {
> - .DbxPtr = &DbxDummy,
> - .DbxSize = sizeof (DbxDummy),
> - .SecureBootKeyName = L"Fail DBX"
> - };
> + SECURE_BOOT_PAYLOAD_INFO PayloadInfo;
> +
> + PayloadInfo.DbxPtr = &DbxDummy;
> + PayloadInfo.DbxSize = sizeof (DbxDummy);
> + PayloadInfo.SecureBootKeyName = L"Fail DBX";
>
> expect_memory (MockGetVariable, VariableName,
> EFI_SECURE_BOOT_MODE_NAME, sizeof
> (EFI_SECURE_BOOT_MODE_NAME));
> expect_value (MockGetVariable, VendorGuid, &gEfiGlobalVariableGuid);
> @@ -1442,13 +1438,13 @@ SetSecureBootVariablesShouldStopFailDB (
> UINT8 DbxDummy = 0xBE;
> UINT8 *Payload = NULL;
> UINTN PayloadSize = sizeof (DbDummy);
> - SECURE_BOOT_PAYLOAD_INFO PayloadInfo = {
> - .DbPtr = &DbDummy,
> - .DbSize = sizeof (DbDummy),
> - .DbxPtr = &DbxDummy,
> - .DbxSize = sizeof (DbxDummy),
> - .SecureBootKeyName = L"Fail DB"
> - };
> + SECURE_BOOT_PAYLOAD_INFO PayloadInfo;
> +
> + PayloadInfo.DbPtr = &DbDummy;
> + PayloadInfo.DbSize = sizeof (DbDummy);
> + PayloadInfo.DbxPtr = &DbxDummy;
> + PayloadInfo.DbxSize = sizeof (DbxDummy);
> + PayloadInfo.SecureBootKeyName = L"Fail DB";
>
> expect_memory (MockGetVariable, VariableName,
> EFI_SECURE_BOOT_MODE_NAME, sizeof
> (EFI_SECURE_BOOT_MODE_NAME));
> expect_value (MockGetVariable, VendorGuid, &gEfiGlobalVariableGuid);
> @@ -1516,15 +1512,15 @@ SetSecureBootVariablesShouldStopFailDBT (
> UINT8 DbxDummy = 0xBE;
> UINT8 *Payload = NULL;
> UINTN PayloadSize = sizeof (DbDummy);
> - SECURE_BOOT_PAYLOAD_INFO PayloadInfo = {
> - .DbPtr = &DbDummy,
> - .DbSize = sizeof (DbDummy),
> - .DbxPtr = &DbxDummy,
> - .DbxSize = sizeof (DbxDummy),
> - .DbtPtr = &DbtDummy,
> - .DbtSize = sizeof (DbtDummy),
> - .SecureBootKeyName = L"Fail DBT"
> - };
> + SECURE_BOOT_PAYLOAD_INFO PayloadInfo;
> +
> + PayloadInfo.DbPtr = &DbDummy;
> + PayloadInfo.DbSize = sizeof (DbDummy);
> + PayloadInfo.DbxPtr = &DbxDummy;
> + PayloadInfo.DbxSize = sizeof (DbxDummy);
> + PayloadInfo.DbtPtr = &DbtDummy;
> + PayloadInfo.DbtSize = sizeof (DbtDummy);
> + PayloadInfo.SecureBootKeyName = L"Fail DBT";
>
> expect_memory (MockGetVariable, VariableName,
> EFI_SECURE_BOOT_MODE_NAME, sizeof
> (EFI_SECURE_BOOT_MODE_NAME));
> expect_value (MockGetVariable, VendorGuid, &gEfiGlobalVariableGuid);
> @@ -1608,19 +1604,19 @@ SetSecureBootVariablesShouldStopFailKEK (
> UINT8 PkDummy = 0xFE;
> UINT8 *Payload = NULL;
> UINTN PayloadSize = sizeof (DbDummy);
> - SECURE_BOOT_PAYLOAD_INFO PayloadInfo = {
> - .DbPtr = &DbDummy,
> - .DbSize = sizeof (DbDummy),
> - .DbxPtr = &DbxDummy,
> - .DbxSize = sizeof (DbxDummy),
> - .DbtPtr = &DbtDummy,
> - .DbtSize = sizeof (DbtDummy),
> - .KekPtr = &KekDummy,
> - .KekSize = sizeof (KekDummy),
> - .PkPtr = &PkDummy,
> - .PkSize = sizeof (PkDummy),
> - .SecureBootKeyName = L"Food"
> - };
> + SECURE_BOOT_PAYLOAD_INFO PayloadInfo;
> +
> + PayloadInfo.DbPtr = &DbDummy;
> + PayloadInfo.DbSize = sizeof (DbDummy);
> + PayloadInfo.DbxPtr = &DbxDummy;
> + PayloadInfo.DbxSize = sizeof (DbxDummy);
> + PayloadInfo.DbtPtr = &DbtDummy;
> + PayloadInfo.DbtSize = sizeof (DbtDummy);
> + PayloadInfo.KekPtr = &KekDummy;
> + PayloadInfo.KekSize = sizeof (KekDummy);
> + PayloadInfo.PkPtr = &PkDummy;
> + PayloadInfo.PkSize = sizeof (PkDummy);
> + PayloadInfo.SecureBootKeyName = L"Food";
>
> expect_memory (MockGetVariable, VariableName,
> EFI_SECURE_BOOT_MODE_NAME, sizeof
> (EFI_SECURE_BOOT_MODE_NAME));
> expect_value (MockGetVariable, VendorGuid, &gEfiGlobalVariableGuid);
> @@ -1718,19 +1714,19 @@ SetSecureBootVariablesShouldStopFailPK (
> UINT8 PkDummy = 0xFE;
> UINT8 *Payload = NULL;
> UINTN PayloadSize = sizeof (DbDummy);
> - SECURE_BOOT_PAYLOAD_INFO PayloadInfo = {
> - .DbPtr = &DbDummy,
> - .DbSize = sizeof (DbDummy),
> - .DbxPtr = &DbxDummy,
> - .DbxSize = sizeof (DbxDummy),
> - .DbtPtr = &DbtDummy,
> - .DbtSize = sizeof (DbtDummy),
> - .KekPtr = &KekDummy,
> - .KekSize = sizeof (KekDummy),
> - .PkPtr = &PkDummy,
> - .PkSize = sizeof (PkDummy),
> - .SecureBootKeyName = L"Food"
> - };
> + SECURE_BOOT_PAYLOAD_INFO PayloadInfo;
> +
> + PayloadInfo.DbPtr = &DbDummy;
> + PayloadInfo.DbSize = sizeof (DbDummy);
> + PayloadInfo.DbxPtr = &DbxDummy;
> + PayloadInfo.DbxSize = sizeof (DbxDummy);
> + PayloadInfo.DbtPtr = &DbtDummy;
> + PayloadInfo.DbtSize = sizeof (DbtDummy);
> + PayloadInfo.KekPtr = &KekDummy;
> + PayloadInfo.KekSize = sizeof (KekDummy);
> + PayloadInfo.PkPtr = &PkDummy;
> + PayloadInfo.PkSize = sizeof (PkDummy);
> + PayloadInfo.SecureBootKeyName = L"Food";
>
> expect_memory (MockGetVariable, VariableName,
> EFI_SECURE_BOOT_MODE_NAME, sizeof
> (EFI_SECURE_BOOT_MODE_NAME));
> expect_value (MockGetVariable, VendorGuid, &gEfiGlobalVariableGuid);
> @@ -1841,19 +1837,19 @@ SetSecureBootVariablesDBTOptional (
> UINT8 PkDummy = 0xFE;
> UINT8 *Payload = NULL;
> UINTN PayloadSize = sizeof (DbDummy);
> - SECURE_BOOT_PAYLOAD_INFO PayloadInfo = {
> - .DbPtr = &DbDummy,
> - .DbSize = sizeof (DbDummy),
> - .DbxPtr = &DbxDummy,
> - .DbxSize = sizeof (DbxDummy),
> - .DbtPtr = NULL,
> - .DbtSize = 0,
> - .KekPtr = &KekDummy,
> - .KekSize = sizeof (KekDummy),
> - .PkPtr = &PkDummy,
> - .PkSize = sizeof (PkDummy),
> - .SecureBootKeyName = L"Food"
> - };
> + SECURE_BOOT_PAYLOAD_INFO PayloadInfo;
> +
> + PayloadInfo.DbPtr = &DbDummy;
> + PayloadInfo.DbSize = sizeof (DbDummy);
> + PayloadInfo.DbxPtr = &DbxDummy;
> + PayloadInfo.DbxSize = sizeof (DbxDummy);
> + PayloadInfo.DbtPtr = NULL;
> + PayloadInfo.DbtSize = 0;
> + PayloadInfo.KekPtr = &KekDummy;
> + PayloadInfo.KekSize = sizeof (KekDummy);
> + PayloadInfo.PkPtr = &PkDummy;
> + PayloadInfo.PkSize = sizeof (PkDummy);
> + PayloadInfo.SecureBootKeyName = L"Food";
>
> expect_memory (MockGetVariable, VariableName,
> EFI_SECURE_BOOT_MODE_NAME, sizeof
> (EFI_SECURE_BOOT_MODE_NAME));
> expect_value (MockGetVariable, VendorGuid, &gEfiGlobalVariableGuid);
> --
> 2.39.1.windows.1
next prev parent reply other threads:[~2023-03-26 2:50 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-03-25 18:45 [Patch 00/12] Add gmock support for host-based unit testing Michael D Kinney
2023-03-25 18:45 ` [Patch 01/12] UnitTestFrameworkPkg: Add subhook submodule required for gmock Michael D Kinney
2023-03-25 18:45 ` [Patch 02/12] .pytool/CISettings.py: Add subhook submodule Michael D Kinney
2023-03-25 18:45 ` [Patch 03/12] UnitTestFrameworkPkg: Add gmock support to GoogleTestLib Michael D Kinney
2023-03-25 18:45 ` [Patch 04/12] UnitTestFrameworkPkg/ReadMe.md: Add gmock documentation Michael D Kinney
2023-03-28 18:23 ` Johnson, Chris N
2023-03-25 18:45 ` [Patch 05/12] MdePkg: Add gmock examples Michael D Kinney
2023-03-25 18:45 ` [Patch 06/12] MdeModulePkg/Library/UefiSortLib: Add GoogleTestLib example Michael D Kinney
2023-03-25 18:45 ` [Patch 07/12] SecurityPkg: Add gmock example Michael D Kinney
2023-03-26 2:51 ` Yao, Jiewen
2023-03-25 18:45 ` [Patch 08/12] SecurityPkg/Library/SecureBootVariableLib: Fix VS20xx 4122 errors Michael D Kinney
2023-03-26 2:50 ` Yao, Jiewen [this message]
2023-03-25 18:45 ` [Patch 09/12] SecurityPkg/Library/SecureBootVariableLib: HOST_APPLICATION IA32/X64 only Michael D Kinney
2023-03-26 2:50 ` Yao, Jiewen
2023-03-25 18:45 ` [Patch 10/12] MdePkg/Library/BaseLib: " Michael D Kinney
2023-03-25 18:45 ` [Patch 11/12] MdeModulePkg: " Michael D Kinney
2023-03-25 18:45 ` [Patch 12/12] PrmPkg/Library: " Michael D Kinney
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-list from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=MW4PR11MB58723A28E28D8AE6C9D698F98C8A9@MW4PR11MB5872.namprd11.prod.outlook.com \
--to=devel@edk2.groups.io \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox