[edk2-devel] [PATCH v1 1/1] StandaloneMmPkg/StandaloneMmCore: Fix compiler warning

Sami Mujawar sami.mujawar at arm.com
Tue Feb 9 22:07:58 UTC 2021


Hi Michael,

Please see my response inline marked [SAMI].

Other than the minor space change needed to match the coding style, this patch looks good to me.

With that changed:
Reviewed-by: Sami Mujawar <sami.mujawar at arm.com>

Regards,

Sami Mujawar

-----Original Message-----
From: mikuback at linux.microsoft.com <mikuback at linux.microsoft.com> 
Sent: 03 February 2021 03:51 AM
To: devel at edk2.groups.io
Cc: Ard Biesheuvel <Ard.Biesheuvel at arm.com>; Sami Mujawar <Sami.Mujawar at arm.com>; Jiewen Yao <jiewen.yao at intel.com>; Supreeth Venkatesh <Supreeth.Venkatesh at arm.com>
Subject: [PATCH v1 1/1] StandaloneMmPkg/StandaloneMmCore: Fix compiler warning

From: Michael Kubacki <michael.kubacki at microsoft.com>

REF:https://bugzilla.tianocore.org/show_bug.cgi?id=3204

Fixes the following compiler warning in VS2019 by changing defining
the MmramRangeCount variable to be UINTN and type casting prior
to value assignment.

\edk2\StandaloneMmPkg\Core\StandaloneMmCore.c(570): error C2220:
  the following warning is treated as an error
\edk2\StandaloneMmPkg\Core\StandaloneMmCore.c(570): warning C4244:
  '=': conversion from 'UINT64' to 'UINT32', possible loss of data

Cc: Ard Biesheuvel <ard.biesheuvel at arm.com>
Cc: Sami Mujawar <sami.mujawar at arm.com>
Cc: Jiewen Yao <jiewen.yao at intel.com>
Cc: Supreeth Venkatesh <supreeth.venkatesh at arm.com>
Signed-off-by: Michael Kubacki <michael.kubacki at microsoft.com>
---
 StandaloneMmPkg/Core/StandaloneMmCore.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/StandaloneMmPkg/Core/StandaloneMmCore.c b/StandaloneMmPkg/Core/StandaloneMmCore.c
index 8388ec289ca8..d254a68f2fb8 100644
--- a/StandaloneMmPkg/Core/StandaloneMmCore.c
+++ b/StandaloneMmPkg/Core/StandaloneMmCore.c
@@ -511,7 +511,7 @@ StandaloneMmMain (
   EFI_HOB_GUID_TYPE               *MmramRangesHob;
   EFI_MMRAM_HOB_DESCRIPTOR_BLOCK  *MmramRangesHobData;
   EFI_MMRAM_DESCRIPTOR            *MmramRanges;
-  UINT32                          MmramRangeCount;
+  UINTN                           MmramRangeCount;
   EFI_HOB_FIRMWARE_VOLUME         *BfvHob;
 
   ProcessLibraryConstructorList (HobStart, &gMmCoreMmst);
@@ -546,7 +546,7 @@ StandaloneMmMain (
     MmramRangesHobData = GET_GUID_HOB_DATA (MmramRangesHob);
     ASSERT (MmramRangesHobData != NULL);
     MmramRanges = MmramRangesHobData->Descriptor;
-    MmramRangeCount = MmramRangesHobData->NumberOfMmReservedRegions;
+    MmramRangeCount = (UINTN) MmramRangesHobData->NumberOfMmReservedRegions;
[SAMI] There should be no space between the typecast and the variable, i.e. space after typecast (UINTN) and MmramRangesHobData.
Same at other places in this file.
[/SAMI]

     ASSERT (MmramRanges);
     ASSERT (MmramRangeCount);
 
@@ -554,7 +554,7 @@ StandaloneMmMain (
     // Copy the MMRAM ranges into MM_CORE_PRIVATE_DATA table just in case any
     // code relies on them being present there
     //
-    gMmCorePrivate->MmramRangeCount = MmramRangeCount;
+    gMmCorePrivate->MmramRangeCount = (UINT64) MmramRangeCount;
     gMmCorePrivate->MmramRanges =
       (EFI_PHYSICAL_ADDRESS)(UINTN)AllocatePool (MmramRangeCount * sizeof (EFI_MMRAM_DESCRIPTOR));
     ASSERT (gMmCorePrivate->MmramRanges != 0);
@@ -567,7 +567,7 @@ StandaloneMmMain (
     DataInHob       = GET_GUID_HOB_DATA (GuidHob);
     gMmCorePrivate = (MM_CORE_PRIVATE_DATA *)(UINTN)DataInHob->Address;
     MmramRanges     = (EFI_MMRAM_DESCRIPTOR *)(UINTN)gMmCorePrivate->MmramRanges;
-    MmramRangeCount = gMmCorePrivate->MmramRangeCount;
+    MmramRangeCount = (UINTN) gMmCorePrivate->MmramRangeCount;
   }
 
   //
-- 
2.28.0.windows.1



-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#71536): https://edk2.groups.io/g/devel/message/71536
Mute This Topic: https://groups.io/mt/80346365/1813853
Group Owner: devel+owner at edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [edk2-devel-archive at redhat.com]
-=-=-=-=-=-=-=-=-=-=-=-






More information about the edk2-devel-archive mailing list