[edk2-devel] [Patch 1/1] OvmfPkg/LinuxInitrdDynamicShellCommand: Cast UNIT64 to UNITN in assignment
Laszlo Ersek
lersek at redhat.com
Tue Mar 10 10:36:10 UTC 2020
On 03/10/20 09:44, Bob Feng wrote:
> REF: https://bugzilla.tianocore.org/show_bug.cgi?id=2580
>
> Ovmf build failed on Windows with VS2017 tool chain.
> The error message like:
>
> OvmfPkg\LinuxInitrdDynamicShellCommand\LinuxInitr
> dDynamicShellCommand.c(199): error C2220: warning treated as error -
> no 'object' file generated
> OvmfPkg\LinuxInitrdDynamicShellCommand\LinuxInitrdDynamicShellCommand.c(199):
> warning C4244: '=': conversion from 'UINT64' to 'UINTN',
> possible loss of data
>
> This patch is to cast UINT64 type to UINTN type
> when doing the variable assignment.
>
> Signed-off-by: Bob Feng <bob.c.feng at intel.com>
> Cc: Ard Biesheuvel <ard.biesheuvel at linaro.org>
> Cc: Laszlo Ersek <lersek at redhat.com>
> ---
> .../LinuxInitrdDynamicShellCommand.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/OvmfPkg/LinuxInitrdDynamicShellCommand/LinuxInitrdDynamicShellCommand.c b/OvmfPkg/LinuxInitrdDynamicShellCommand/LinuxInitrdDynamicShellCommand.c
> index 021b072826a9..07baa0e8d100 100644
> --- a/OvmfPkg/LinuxInitrdDynamicShellCommand/LinuxInitrdDynamicShellCommand.c
> +++ b/OvmfPkg/LinuxInitrdDynamicShellCommand/LinuxInitrdDynamicShellCommand.c
> @@ -194,11 +194,11 @@ CacheInitrdFile (
> &gEfiLoadFile2ProtocolGuid, &mInitrdLoadFile2,
> NULL);
> ASSERT_EFI_ERROR (Status);
> }
>
> - mInitrdFileSize = FileSize;
> + mInitrdFileSize = (UINTN)FileSize;
> return EFI_SUCCESS;
>
> FreeMemory:
> gBS->FreePages (mInitrdFileAddress, EFI_SIZE_TO_PAGES ((UINTN)FileSize));
> return Status;
>
Yes, this patch is safe; the function catches (FileSize > MAX_UINTN)
gracefully, near the top.
Reviewed-by: Laszlo Ersek <lersek at redhat.com>
Thank you very much for the patch!
Laszlo
-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#55713): https://edk2.groups.io/g/devel/message/55713
Mute This Topic: https://groups.io/mt/71853177/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