]> git.proxmox.com Git - mirror_edk2.git/commitdiff
ArmPkg/ArmMmuLib: Explicitly cast UINT32 data conversions
authorMichael Kubacki <michael.kubacki@microsoft.com>
Mon, 19 Oct 2020 22:02:50 +0000 (15:02 -0700)
committermergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
Thu, 22 Oct 2020 14:48:12 +0000 (14:48 +0000)
REF:https://bugzilla.tianocore.org/show_bug.cgi?id=2835

There's several occurrences of a UINT64 or an EFI_PHYSICAL_ADDRESS
being assigned to a UINT32 value in ArmMmuLib. These result in
warning C4244 in VS2019:

warning C4244: '=': conversion from 'UINT64' to 'UINT32', possible
loss of data

warning C4244: '=': conversion from 'EFI_PHYSICAL_ADDRESS' to
'UINT32', possible loss of data

This change explicitly casts the values to UINT32.

These can be reproduced with the following build command:
build -b DEBUG -a ARM -t VS2019 -p ArmPkg/ArmPkg.dsc
-m ArmPkg/Library/ArmMmuLib/ArmMmuBaseLib.inf

Signed-off-by: Michael Kubacki <michael.kubacki@microsoft.com>
Reviewed-by: Ard Biesheuvel <ard.biesheuvel@arm.com>
ArmPkg/Library/ArmMmuLib/Arm/ArmMmuLibCore.c
ArmPkg/Library/ArmMmuLib/Arm/ArmMmuLibUpdate.c

index 15e836e75e8eb9144326ded83ea6ab01742302d6..b4fffed9ae49027fdaec52dd5f3f69cfbbddb373 100644 (file)
@@ -225,7 +225,7 @@ FillTranslationTable (
     return;\r
   }\r
 \r
-  PhysicalBase = MemoryRegion->PhysicalBase;\r
+  PhysicalBase = (UINT32)MemoryRegion->PhysicalBase;\r
   RemainLength = MIN(MemoryRegion->Length, SIZE_4GB - PhysicalBase);\r
 \r
   switch (MemoryRegion->Attributes) {\r
@@ -291,7 +291,7 @@ FillTranslationTable (
       PhysicalBase += TT_DESCRIPTOR_SECTION_SIZE;\r
       RemainLength -= TT_DESCRIPTOR_SECTION_SIZE;\r
     } else {\r
-      PageMapLength = MIN (RemainLength, TT_DESCRIPTOR_SECTION_SIZE -\r
+      PageMapLength = MIN ((UINT32)RemainLength, TT_DESCRIPTOR_SECTION_SIZE -\r
                                          (PhysicalBase % TT_DESCRIPTOR_SECTION_SIZE));\r
 \r
       // Case: Physical address aligned on the Section Size (1MB) && the length\r
index 1ec734deab180af7e4a5b24e5aa413624fb97e76..6f18604f799f21a9a581ba033b4b69f353cda7a0 100644 (file)
@@ -152,7 +152,7 @@ UpdatePageEntries (
   FirstLevelTable = (ARM_FIRST_LEVEL_DESCRIPTOR *)ArmGetTTBR0BaseAddress ();\r
 \r
   // Calculate number of 4KB page table entries to change\r
-  NumPageEntries = Length / TT_DESCRIPTOR_PAGE_SIZE;\r
+  NumPageEntries = (UINT32)(Length / TT_DESCRIPTOR_PAGE_SIZE);\r
 \r
   // Iterate for the number of 4KB pages to change\r
   Offset = 0;\r
@@ -288,7 +288,7 @@ UpdateSectionEntries (
   ASSERT (FirstLevelIdx < TRANSLATION_TABLE_SECTION_COUNT);\r
 \r
   // calculate number of 1MB first level entries this applies to\r
-  NumSections = Length / TT_DESCRIPTOR_SECTION_SIZE;\r
+  NumSections = (UINT32)(Length / TT_DESCRIPTOR_SECTION_SIZE);\r
 \r
   // iterate through each descriptor\r
   for(i=0; i<NumSections; i++) {\r