public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
* [Patch 1/1] OvmfPkg/LinuxInitrdDynamicShellCommand: Cast UNIT64 to UNITN in assignment
@ 2020-03-10  8:44 Bob Feng
  2020-03-10 10:36 ` Laszlo Ersek
  0 siblings, 1 reply; 2+ messages in thread
From: Bob Feng @ 2020-03-10  8:44 UTC (permalink / raw)
  To: devel; +Cc: Ard Biesheuvel, Laszlo Ersek

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@intel.com>
Cc: Ard Biesheuvel <ard.biesheuvel@linaro.org>
Cc: Laszlo Ersek <lersek@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;
-- 
2.20.1.windows.1


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [Patch 1/1] OvmfPkg/LinuxInitrdDynamicShellCommand: Cast UNIT64 to UNITN in assignment
  2020-03-10  8:44 [Patch 1/1] OvmfPkg/LinuxInitrdDynamicShellCommand: Cast UNIT64 to UNITN in assignment Bob Feng
@ 2020-03-10 10:36 ` Laszlo Ersek
  0 siblings, 0 replies; 2+ messages in thread
From: Laszlo Ersek @ 2020-03-10 10:36 UTC (permalink / raw)
  To: Bob Feng, devel; +Cc: Ard Biesheuvel

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@intel.com>
> Cc: Ard Biesheuvel <ard.biesheuvel@linaro.org>
> Cc: Laszlo Ersek <lersek@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@redhat.com>

Thank you very much for the patch!
Laszlo


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2020-03-10 10:36 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2020-03-10  8:44 [Patch 1/1] OvmfPkg/LinuxInitrdDynamicShellCommand: Cast UNIT64 to UNITN in assignment Bob Feng
2020-03-10 10:36 ` Laszlo Ersek

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox