[edk2-devel] [Patch V2 6/7] MdeModulePkg/Variable/RuntimeDxeUnitTest: Fix 32-bit GCC builds

Michael D Kinney posted 7 patches 4 years, 3 months ago
[edk2-devel] [Patch V2 6/7] MdeModulePkg/Variable/RuntimeDxeUnitTest: Fix 32-bit GCC builds
Posted by Michael D Kinney 4 years, 3 months ago
When using will_return() on a pointer value, it must be
cast to UINTN to be compatible with 32-bit GCC builds.
This uses the same approach in samples provided in the
UnitTestFramworkPkg when passing pointer values to
UT_ASSERT_EQUAL().

Cc: Hao A Wu <hao.a.wu@intel.com>
Cc: Liming Gao <gaoliming@byosoft.com.cn>
Cc: Bret Barkelew <Bret.Barkelew@microsoft.com>
Signed-off-by: Michael D Kinney <michael.d.kinney@intel.com>
Reviewed-by: Philippe Mathieu-Daude <philmd@redhat.com>
---
 .../RuntimeDxeUnitTest/VariableLockRequestToLockUnitTest.c  | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/MdeModulePkg/Universal/Variable/RuntimeDxe/RuntimeDxeUnitTest/VariableLockRequestToLockUnitTest.c b/MdeModulePkg/Universal/Variable/RuntimeDxe/RuntimeDxeUnitTest/VariableLockRequestToLockUnitTest.c
index 44d70e639d77..880994fe71fc 100644
--- a/MdeModulePkg/Universal/Variable/RuntimeDxe/RuntimeDxeUnitTest/VariableLockRequestToLockUnitTest.c
+++ b/MdeModulePkg/Universal/Variable/RuntimeDxe/RuntimeDxeUnitTest/VariableLockRequestToLockUnitTest.c
@@ -287,7 +287,7 @@ LockingAnUnlockedVariableShouldFail (
   // With a policy, make sure that writes still work, since the variable doesn't exist.
   will_return( StubGetVariableNull, TEST_POLICY_ATTRIBUTES_NULL );    // Attributes
   will_return( StubGetVariableNull, 0 );                              // Size
-  will_return( StubGetVariableNull, NULL );                           // DataPtr
+  will_return( StubGetVariableNull, (UINTN)NULL );                    // DataPtr
   will_return( StubGetVariableNull, EFI_NOT_FOUND);                   // Status
 
   Status = VariableLockRequestToLock (NULL, TEST_VAR_1_NAME, &mTestGuid1);
@@ -342,7 +342,7 @@ LockingALockedVariableWithMatchingDataShouldSucceed (
   Data = 1;
   will_return( StubGetVariableNull, TEST_POLICY_ATTRIBUTES_NULL );    // Attributes
   will_return( StubGetVariableNull, sizeof (Data) );                  // Size
-  will_return( StubGetVariableNull, &Data );                          // DataPtr
+  will_return( StubGetVariableNull, (UINTN)&Data );                   // DataPtr
   will_return( StubGetVariableNull, EFI_SUCCESS);                     // Status
 
   Status = VariableLockRequestToLock (NULL, TEST_VAR_1_NAME, &mTestGuid1);
@@ -397,7 +397,7 @@ LockingALockedVariableWithNonMatchingDataShouldFail (
   Data = 2;
   will_return( StubGetVariableNull, TEST_POLICY_ATTRIBUTES_NULL );    // Attributes
   will_return( StubGetVariableNull, sizeof (Data) );                  // Size
-  will_return( StubGetVariableNull, &Data );                          // DataPtr
+  will_return( StubGetVariableNull, (UINTN)&Data );                   // DataPtr
   will_return( StubGetVariableNull, EFI_SUCCESS);                     // Status
 
   Status = VariableLockRequestToLock (NULL, TEST_VAR_1_NAME, &mTestGuid1);
-- 
2.32.0.windows.1



-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#83302): https://edk2.groups.io/g/devel/message/83302
Mute This Topic: https://groups.io/mt/86804630/1787277
Group Owner: devel+owner@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [importer@patchew.org]
-=-=-=-=-=-=-=-=-=-=-=-


Re: [edk2-devel] [EXTERNAL] [Patch V2 6/7] MdeModulePkg/Variable/RuntimeDxeUnitTest: Fix 32-bit GCC builds
Posted by Bret Barkelew via groups.io 4 years, 3 months ago
Reviewed-by: Bret Barkelew <bret.barkelew@microsoft.com>

- Bret

From: Michael D Kinney<mailto:michael.d.kinney@intel.com>
Sent: Wednesday, November 3, 2021 4:00 PM
To: devel@edk2.groups.io<mailto:devel@edk2.groups.io>
Cc: Hao A Wu<mailto:hao.a.wu@intel.com>; Liming Gao<mailto:gaoliming@byosoft.com.cn>; Bret Barkelew<mailto:Bret.Barkelew@microsoft.com>; Philippe Mathieu-Daude<mailto:philmd@redhat.com>
Subject: [EXTERNAL] [Patch V2 6/7] MdeModulePkg/Variable/RuntimeDxeUnitTest: Fix 32-bit GCC builds

When using will_return() on a pointer value, it must be
cast to UINTN to be compatible with 32-bit GCC builds.
This uses the same approach in samples provided in the
UnitTestFramworkPkg when passing pointer values to
UT_ASSERT_EQUAL().

Cc: Hao A Wu <hao.a.wu@intel.com>
Cc: Liming Gao <gaoliming@byosoft.com.cn>
Cc: Bret Barkelew <Bret.Barkelew@microsoft.com>
Signed-off-by: Michael D Kinney <michael.d.kinney@intel.com>
Reviewed-by: Philippe Mathieu-Daude <philmd@redhat.com>
---
 .../RuntimeDxeUnitTest/VariableLockRequestToLockUnitTest.c  | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/MdeModulePkg/Universal/Variable/RuntimeDxe/RuntimeDxeUnitTest/VariableLockRequestToLockUnitTest.c b/MdeModulePkg/Universal/Variable/RuntimeDxe/RuntimeDxeUnitTest/VariableLockRequestToLockUnitTest.c
index 44d70e639d77..880994fe71fc 100644
--- a/MdeModulePkg/Universal/Variable/RuntimeDxe/RuntimeDxeUnitTest/VariableLockRequestToLockUnitTest.c
+++ b/MdeModulePkg/Universal/Variable/RuntimeDxe/RuntimeDxeUnitTest/VariableLockRequestToLockUnitTest.c
@@ -287,7 +287,7 @@ LockingAnUnlockedVariableShouldFail (
   // With a policy, make sure that writes still work, since the variable doesn't exist.
   will_return( StubGetVariableNull, TEST_POLICY_ATTRIBUTES_NULL );    // Attributes
   will_return( StubGetVariableNull, 0 );                              // Size
-  will_return( StubGetVariableNull, NULL );                           // DataPtr
+  will_return( StubGetVariableNull, (UINTN)NULL );                    // DataPtr
   will_return( StubGetVariableNull, EFI_NOT_FOUND);                   // Status

   Status = VariableLockRequestToLock (NULL, TEST_VAR_1_NAME, &mTestGuid1);
@@ -342,7 +342,7 @@ LockingALockedVariableWithMatchingDataShouldSucceed (
   Data = 1;
   will_return( StubGetVariableNull, TEST_POLICY_ATTRIBUTES_NULL );    // Attributes
   will_return( StubGetVariableNull, sizeof (Data) );                  // Size
-  will_return( StubGetVariableNull, &Data );                          // DataPtr
+  will_return( StubGetVariableNull, (UINTN)&Data );                   // DataPtr
   will_return( StubGetVariableNull, EFI_SUCCESS);                     // Status

   Status = VariableLockRequestToLock (NULL, TEST_VAR_1_NAME, &mTestGuid1);
@@ -397,7 +397,7 @@ LockingALockedVariableWithNonMatchingDataShouldFail (
   Data = 2;
   will_return( StubGetVariableNull, TEST_POLICY_ATTRIBUTES_NULL );    // Attributes
   will_return( StubGetVariableNull, sizeof (Data) );                  // Size
-  will_return( StubGetVariableNull, &Data );                          // DataPtr
+  will_return( StubGetVariableNull, (UINTN)&Data );                   // DataPtr
   will_return( StubGetVariableNull, EFI_SUCCESS);                     // Status

   Status = VariableLockRequestToLock (NULL, TEST_VAR_1_NAME, &mTestGuid1);
--
2.32.0.windows.1



-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#83304): https://edk2.groups.io/g/devel/message/83304
Mute This Topic: https://groups.io/mt/86805498/1787277
Group Owner: devel+owner@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [importer@patchew.org]
-=-=-=-=-=-=-=-=-=-=-=-


Re: [edk2-devel] [Patch V2 6/7] MdeModulePkg/Variable/RuntimeDxeUnitTest: Fix 32-bit GCC builds
Posted by Wu, Hao A 4 years, 3 months ago
> -----Original Message-----
> From: devel@edk2.groups.io <devel@edk2.groups.io> On Behalf Of Michael D
> Kinney
> Sent: Thursday, November 4, 2021 7:00 AM
> To: devel@edk2.groups.io
> Cc: Wu, Hao A <hao.a.wu@intel.com>; Liming Gao
> <gaoliming@byosoft.com.cn>; Bret Barkelew <Bret.Barkelew@microsoft.com>;
> Philippe Mathieu-Daude <philmd@redhat.com>
> Subject: [edk2-devel] [Patch V2 6/7]
> MdeModulePkg/Variable/RuntimeDxeUnitTest: Fix 32-bit GCC builds
> 
> When using will_return() on a pointer value, it must be cast to UINTN to be
> compatible with 32-bit GCC builds.
> This uses the same approach in samples provided in the UnitTestFramworkPkg
> when passing pointer values to UT_ASSERT_EQUAL().


Reviewed-by: Hao A Wu <hao.a.wu@intel.com>

Best Regards,
Hao Wu


> 
> Cc: Hao A Wu <hao.a.wu@intel.com>
> Cc: Liming Gao <gaoliming@byosoft.com.cn>
> Cc: Bret Barkelew <Bret.Barkelew@microsoft.com>
> Signed-off-by: Michael D Kinney <michael.d.kinney@intel.com>
> Reviewed-by: Philippe Mathieu-Daude <philmd@redhat.com>
> ---
>  .../RuntimeDxeUnitTest/VariableLockRequestToLockUnitTest.c  | 6 +++---
>  1 file changed, 3 insertions(+), 3 deletions(-)
> 
> diff --git
> a/MdeModulePkg/Universal/Variable/RuntimeDxe/RuntimeDxeUnitTest/Variabl
> eLockRequestToLockUnitTest.c
> b/MdeModulePkg/Universal/Variable/RuntimeDxe/RuntimeDxeUnitTest/Variabl
> eLockRequestToLockUnitTest.c
> index 44d70e639d77..880994fe71fc 100644
> ---
> a/MdeModulePkg/Universal/Variable/RuntimeDxe/RuntimeDxeUnitTest/Variabl
> eLockRequestToLockUnitTest.c
> +++
> b/MdeModulePkg/Universal/Variable/RuntimeDxe/RuntimeDxeUnitTest/Vari
> +++ ableLockRequestToLockUnitTest.c
> @@ -287,7 +287,7 @@ LockingAnUnlockedVariableShouldFail (
>    // With a policy, make sure that writes still work, since the variable doesn't
> exist.
>    will_return( StubGetVariableNull, TEST_POLICY_ATTRIBUTES_NULL );    //
> Attributes
>    will_return( StubGetVariableNull, 0 );                              // Size
> -  will_return( StubGetVariableNull, NULL );                           // DataPtr
> +  will_return( StubGetVariableNull, (UINTN)NULL );                    // DataPtr
>    will_return( StubGetVariableNull, EFI_NOT_FOUND);                   // Status
> 
>    Status = VariableLockRequestToLock (NULL, TEST_VAR_1_NAME,
> &mTestGuid1); @@ -342,7 +342,7 @@
> LockingALockedVariableWithMatchingDataShouldSucceed (
>    Data = 1;
>    will_return( StubGetVariableNull, TEST_POLICY_ATTRIBUTES_NULL );    //
> Attributes
>    will_return( StubGetVariableNull, sizeof (Data) );                  // Size
> -  will_return( StubGetVariableNull, &Data );                          // DataPtr
> +  will_return( StubGetVariableNull, (UINTN)&Data );                   // DataPtr
>    will_return( StubGetVariableNull, EFI_SUCCESS);                     // Status
> 
>    Status = VariableLockRequestToLock (NULL, TEST_VAR_1_NAME,
> &mTestGuid1); @@ -397,7 +397,7 @@
> LockingALockedVariableWithNonMatchingDataShouldFail (
>    Data = 2;
>    will_return( StubGetVariableNull, TEST_POLICY_ATTRIBUTES_NULL );    //
> Attributes
>    will_return( StubGetVariableNull, sizeof (Data) );                  // Size
> -  will_return( StubGetVariableNull, &Data );                          // DataPtr
> +  will_return( StubGetVariableNull, (UINTN)&Data );                   // DataPtr
>    will_return( StubGetVariableNull, EFI_SUCCESS);                     // Status
> 
>    Status = VariableLockRequestToLock (NULL, TEST_VAR_1_NAME,
> &mTestGuid1);
> --
> 2.32.0.windows.1
> 
> 
> 
> 
> 



-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#83310): https://edk2.groups.io/g/devel/message/83310
Mute This Topic: https://groups.io/mt/86804630/1787277
Group Owner: devel+owner@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [importer@patchew.org]
-=-=-=-=-=-=-=-=-=-=-=-