[edk2-devel] [PATCH] OvmfPkg/GenericQemuLoadImageLib: Fix VS2019 UINT32 conversion error

Ard Biesheuvel posted 1 patch 4 years ago
Failed in applying to current master (apply log)
OvmfPkg/Library/GenericQemuLoadImageLib/GenericQemuLoadImageLib.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
[edk2-devel] [PATCH] OvmfPkg/GenericQemuLoadImageLib: Fix VS2019 UINT32 conversion error
Posted by Ard Biesheuvel 4 years ago
Building OVMF for X64 with secure boot enabled on VS2019 results in
the following error:

  d:\a\1\s\OvmfPkg\Library\GenericQemuLoadImageLib\GenericQemuLoadImageLib.c(154):
    error C2220: the following warning is treated as an error
  d:\a\1\s\OvmfPkg\Library\GenericQemuLoadImageLib\GenericQemuLoadImageLib.c(154):
    warning C4244: '=': conversion from 'UINTN' to 'UINT32', possible loss of data

Suppress the error by making the cast explicit.

Link: https://bugzilla.tianocore.org/show_bug.cgi?id=2636
Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
---
 OvmfPkg/Library/GenericQemuLoadImageLib/GenericQemuLoadImageLib.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/OvmfPkg/Library/GenericQemuLoadImageLib/GenericQemuLoadImageLib.c b/OvmfPkg/Library/GenericQemuLoadImageLib/GenericQemuLoadImageLib.c
index f7f9a205f99d..14c8417d43e7 100644
--- a/OvmfPkg/Library/GenericQemuLoadImageLib/GenericQemuLoadImageLib.c
+++ b/OvmfPkg/Library/GenericQemuLoadImageLib/GenericQemuLoadImageLib.c
@@ -151,7 +151,7 @@ QemuLoadKernelImage (
     //
     // Drop the terminating NUL, convert to UTF-16.
     //
-    KernelLoadedImage->LoadOptionsSize = (CommandLineSize - 1) * 2;
+    KernelLoadedImage->LoadOptionsSize = (UINT32)((CommandLineSize - 1) * 2);
   }
 
   QemuFwCfgSelectItem (QemuFwCfgItemInitrdSize);
-- 
2.17.1


-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.

View/Reply Online (#56560): https://edk2.groups.io/g/devel/message/56560
Mute This Topic: https://groups.io/mt/72629862/1787277
Group Owner: devel+owner@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub  [importer@patchew.org]
-=-=-=-=-=-=-=-=-=-=-=-

Re: [edk2-devel] [PATCH] OvmfPkg/GenericQemuLoadImageLib: Fix VS2019 UINT32 conversion error
Posted by Laszlo Ersek 4 years ago
On 03/29/20 15:51, Ard Biesheuvel wrote:
> Building OVMF for X64 with secure boot enabled on VS2019 results in
> the following error:
> 
>   d:\a\1\s\OvmfPkg\Library\GenericQemuLoadImageLib\GenericQemuLoadImageLib.c(154):
>     error C2220: the following warning is treated as an error
>   d:\a\1\s\OvmfPkg\Library\GenericQemuLoadImageLib\GenericQemuLoadImageLib.c(154):
>     warning C4244: '=': conversion from 'UINTN' to 'UINT32', possible loss of data
> 
> Suppress the error by making the cast explicit.
> 
> Link: https://bugzilla.tianocore.org/show_bug.cgi?id=2636
> Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
> ---
>  OvmfPkg/Library/GenericQemuLoadImageLib/GenericQemuLoadImageLib.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/OvmfPkg/Library/GenericQemuLoadImageLib/GenericQemuLoadImageLib.c b/OvmfPkg/Library/GenericQemuLoadImageLib/GenericQemuLoadImageLib.c
> index f7f9a205f99d..14c8417d43e7 100644
> --- a/OvmfPkg/Library/GenericQemuLoadImageLib/GenericQemuLoadImageLib.c
> +++ b/OvmfPkg/Library/GenericQemuLoadImageLib/GenericQemuLoadImageLib.c
> @@ -151,7 +151,7 @@ QemuLoadKernelImage (
>      //
>      // Drop the terminating NUL, convert to UTF-16.
>      //
> -    KernelLoadedImage->LoadOptionsSize = (CommandLineSize - 1) * 2;
> +    KernelLoadedImage->LoadOptionsSize = (UINT32)((CommandLineSize - 1) * 2);
>    }
>  
>    QemuFwCfgSelectItem (QemuFwCfgItemInitrdSize);
> 

Reviewed-by: Laszlo Ersek <lersek@redhat.com>

Thank you very much!
Laszlo


-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.

View/Reply Online (#56626): https://edk2.groups.io/g/devel/message/56626
Mute This Topic: https://groups.io/mt/72629862/1787277
Group Owner: devel+owner@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub  [importer@patchew.org]
-=-=-=-=-=-=-=-=-=-=-=-

Re: [edk2-devel] [PATCH] OvmfPkg/GenericQemuLoadImageLib: Fix VS2019 UINT32 conversion error
Posted by Ard Biesheuvel 4 years ago
On Mon, 30 Mar 2020 at 13:39, Laszlo Ersek <lersek@redhat.com> wrote:
>
> On 03/29/20 15:51, Ard Biesheuvel wrote:
> > Building OVMF for X64 with secure boot enabled on VS2019 results in
> > the following error:
> >
> >   d:\a\1\s\OvmfPkg\Library\GenericQemuLoadImageLib\GenericQemuLoadImageLib.c(154):
> >     error C2220: the following warning is treated as an error
> >   d:\a\1\s\OvmfPkg\Library\GenericQemuLoadImageLib\GenericQemuLoadImageLib.c(154):
> >     warning C4244: '=': conversion from 'UINTN' to 'UINT32', possible loss of data
> >
> > Suppress the error by making the cast explicit.
> >
> > Link: https://bugzilla.tianocore.org/show_bug.cgi?id=2636
> > Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
> > ---
> >  OvmfPkg/Library/GenericQemuLoadImageLib/GenericQemuLoadImageLib.c | 2 +-
> >  1 file changed, 1 insertion(+), 1 deletion(-)
> >
> > diff --git a/OvmfPkg/Library/GenericQemuLoadImageLib/GenericQemuLoadImageLib.c b/OvmfPkg/Library/GenericQemuLoadImageLib/GenericQemuLoadImageLib.c
> > index f7f9a205f99d..14c8417d43e7 100644
> > --- a/OvmfPkg/Library/GenericQemuLoadImageLib/GenericQemuLoadImageLib.c
> > +++ b/OvmfPkg/Library/GenericQemuLoadImageLib/GenericQemuLoadImageLib.c
> > @@ -151,7 +151,7 @@ QemuLoadKernelImage (
> >      //
> >      // Drop the terminating NUL, convert to UTF-16.
> >      //
> > -    KernelLoadedImage->LoadOptionsSize = (CommandLineSize - 1) * 2;
> > +    KernelLoadedImage->LoadOptionsSize = (UINT32)((CommandLineSize - 1) * 2);
> >    }
> >
> >    QemuFwCfgSelectItem (QemuFwCfgItemInitrdSize);
> >
>
> Reviewed-by: Laszlo Ersek <lersek@redhat.com>
>

Thanks. Pushed as 3000c2963db319d055f474c394b062af910bbb2f

-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.

View/Reply Online (#56628): https://edk2.groups.io/g/devel/message/56628
Mute This Topic: https://groups.io/mt/72629862/1787277
Group Owner: devel+owner@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub  [importer@patchew.org]
-=-=-=-=-=-=-=-=-=-=-=-