On 08/13/12 23:23, Jordan Justen wrote:
> Contributed-under: TianoCore Contribution Agreement 1.0
> Signed-off-by: Jordan Justen <[email protected]>
> ---
>  OvmfPkg/AcpiPlatformDxe/Qemu.c | 18 +++++++++---------
>  1 file changed, 9 insertions(+), 9 deletions(-)
> 
> diff --git a/OvmfPkg/AcpiPlatformDxe/Qemu.c b/OvmfPkg/AcpiPlatformDxe/Qemu.c
> index 1ac443f..5ab89aa 100644
> --- a/OvmfPkg/AcpiPlatformDxe/Qemu.c
> +++ b/OvmfPkg/AcpiPlatformDxe/Qemu.c
> @@ -100,8 +100,8 @@ QemuInstallAcpiMadtTable (
>      return EFI_OUT_OF_RESOURCES;
>    }
>  
> -  Madt->Header           = *(EFI_ACPI_DESCRIPTION_HEADER *) AcpiTableBuffer;
> -  Madt->Header.Length    = NewBufferSize;
> +  CopyMem (&(Madt->Header), AcpiTableBuffer, sizeof 
> (EFI_ACPI_DESCRIPTION_HEADER));

Yes, normally I would not write something like this, but here I actively
didn't care about alignment issues.

> +  Madt->Header.Length    = (UINT32) NewBufferSize;

I guess the compiler warned about possible truncation (UINTN is UINT64
on X64).


>    Madt->LocalApicAddress = PcdGet32 (PcdCpuLocalApicBaseAddress);
>    Madt->Flags            = EFI_ACPI_1_0_PCAT_COMPAT;
>    Ptr = Madt + 1;
> @@ -110,8 +110,8 @@ QemuInstallAcpiMadtTable (
>    for (Loop = 0; Loop < CpuCount; ++Loop) {
>      LocalApic->Type            = EFI_ACPI_1_0_PROCESSOR_LOCAL_APIC;
>      LocalApic->Length          = sizeof (*LocalApic);
> -    LocalApic->AcpiProcessorId = Loop;
> -    LocalApic->ApicId          = Loop;
> +    LocalApic->AcpiProcessorId = (UINT8) Loop;
> +    LocalApic->ApicId          = (UINT8) Loop;

Same here.

>      LocalApic->Flags           = 1; // enabled
>      ++LocalApic;
>    }
> @@ -120,7 +120,7 @@ QemuInstallAcpiMadtTable (
>    IoApic = Ptr;
>    IoApic->Type             = EFI_ACPI_1_0_IO_APIC;
>    IoApic->Length           = sizeof (*IoApic);
> -  IoApic->IoApicId         = CpuCount;
> +  IoApic->IoApicId         = (UINT8) CpuCount;
>    IoApic->Reserved         = EFI_ACPI_RESERVED_BYTE;
>    IoApic->IoApicAddress    = 0xFEC00000;
>    IoApic->SystemVectorBase = 0x00000000;
> @@ -148,13 +148,13 @@ QemuInstallAcpiMadtTable (
>      Iso->Type                        = 
> EFI_ACPI_1_0_INTERRUPT_SOURCE_OVERRIDE;
>      Iso->Length                      = sizeof (*Iso);
>      Iso->Bus                         = 0x00; // ISA
> -    Iso->Source                      = Loop;
> -    Iso->GlobalSystemInterruptVector = Loop;
> +    Iso->Source                      = (UINT8) Loop;
> +    Iso->GlobalSystemInterruptVector = (UINT32) Loop;
>      Iso->Flags                       = 0x000D; // Level-tiggered, Active High
>      ++Iso;
>    }
>    ASSERT (
> -    Iso - (EFI_ACPI_1_0_INTERRUPT_SOURCE_OVERRIDE_STRUCTURE *)Ptr ==
> +    (UINTN) (Iso - (EFI_ACPI_1_0_INTERRUPT_SOURCE_OVERRIDE_STRUCTURE *)Ptr) 
> ==
>        1 + PciLinkIsoCount

ptrdiff_t is signed, the result type of 1 + PciLinkIsoCount is UINTN;
that probably elicited another warning

>      );
>    Ptr = Iso;
> @@ -174,7 +174,7 @@ QemuInstallAcpiMadtTable (
>    LocalApicNmi->LocalApicInti   = 0x01;
>    Ptr = LocalApicNmi + 1;
>  
> -  ASSERT ((UINT8 *)Ptr - (UINT8 *)Madt == NewBufferSize);
> +  ASSERT ((UINTN) ((UINT8 *)Ptr - (UINT8 *)Madt) == NewBufferSize);

Ditto.

>    Status = InstallAcpiTable (AcpiProtocol, Madt, NewBufferSize, TableKey);
>  
>    FreePool (Madt);

I am aware of these conversions whenever I code them -- I'll try to add
the casts in the future so you don't have to keep MSVC silent for me.

Reviewed-by: Laszlo Ersek <[email protected]>

Thanks!
Laszlo

------------------------------------------------------------------------------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and 
threat landscape has changed and how IT managers can respond. Discussions 
will include endpoint security, mobile security and the latest in malware 
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
_______________________________________________
edk2-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/edk2-devel

Reply via email to