public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
From: "Laszlo Ersek" <lersek@redhat.com>
To: Bob Feng <bob.c.feng@intel.com>, devel@edk2.groups.io
Cc: Ard Biesheuvel <ard.biesheuvel@linaro.org>
Subject: Re: [Patch 1/1] OvmfPkg/LinuxInitrdDynamicShellCommand: Cast UNIT64 to UNITN in assignment
Date: Tue, 10 Mar 2020 11:36:10 +0100	[thread overview]
Message-ID: <f5e47fc3-af07-d4a7-e4b7-98054ef63aec@redhat.com> (raw)
In-Reply-To: <20200310084426.29044-1-bob.c.feng@intel.com>

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


      reply	other threads:[~2020-03-10 10:36 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
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 message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-list from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=f5e47fc3-af07-d4a7-e4b7-98054ef63aec@redhat.com \
    --to=devel@edk2.groups.io \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox