[edk2] OvmfPkg/PlatformPei: add missing auto variable initialization

Message ID 1468421727-7025-1-git-send-email-ard.biesheuvel@linaro.org
State Accepted
Commit 7ffced92a7b6e5a0eb4433123b3973c635da7355
Headers show

Commit Message

Ard Biesheuvel July 13, 2016, 2:55 p.m.
The E820EntriesCount variable in XenPublishRamRegions() may be
referenced without being initialized on RELEASE builds, since the
ASSERT that fires if the call to XenGetE820Map() fails is compiled
out in that case. So initialize it to 0.

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>

---

Just something that was caught by GCC when building OVMF with O2
optimization.

 OvmfPkg/PlatformPei/Xen.c | 1 +
 1 file changed, 1 insertion(+)

-- 
2.7.4

_______________________________________________
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel

Comments

Laszlo Ersek July 13, 2016, 3 p.m. | #1
On 07/13/16 16:55, Ard Biesheuvel wrote:
> The E820EntriesCount variable in XenPublishRamRegions() may be

> referenced without being initialized on RELEASE builds, since the

> ASSERT that fires if the call to XenGetE820Map() fails is compiled

> out in that case. So initialize it to 0.

> 

> Contributed-under: TianoCore Contribution Agreement 1.0

> Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>

> ---

> 

> Just something that was caught by GCC when building OVMF with O2

> optimization.

> 

>  OvmfPkg/PlatformPei/Xen.c | 1 +

>  1 file changed, 1 insertion(+)

> 

> diff --git a/OvmfPkg/PlatformPei/Xen.c b/OvmfPkg/PlatformPei/Xen.c

> index 3a4358251e38..223908a4f529 100644

> --- a/OvmfPkg/PlatformPei/Xen.c

> +++ b/OvmfPkg/PlatformPei/Xen.c

> @@ -171,6 +171,7 @@ XenPublishRamRegions (

>    //

>    // Parse RAM in E820 map

>    //

> +  E820EntriesCount = 0;

>    Status = XenGetE820Map (&E820Map, &E820EntriesCount);

>  

>    ASSERT_EFI_ERROR (Status);

> 


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


Thanks!
Laszlo
_______________________________________________
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel
Ard Biesheuvel July 13, 2016, 3:07 p.m. | #2
On 13 July 2016 at 17:00, Laszlo Ersek <lersek@redhat.com> wrote:
> On 07/13/16 16:55, Ard Biesheuvel wrote:

>> The E820EntriesCount variable in XenPublishRamRegions() may be

>> referenced without being initialized on RELEASE builds, since the

>> ASSERT that fires if the call to XenGetE820Map() fails is compiled

>> out in that case. So initialize it to 0.

>>

>> Contributed-under: TianoCore Contribution Agreement 1.0

>> Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>

>> ---

>>

>> Just something that was caught by GCC when building OVMF with O2

>> optimization.

>>

>>  OvmfPkg/PlatformPei/Xen.c | 1 +

>>  1 file changed, 1 insertion(+)

>>

>> diff --git a/OvmfPkg/PlatformPei/Xen.c b/OvmfPkg/PlatformPei/Xen.c

>> index 3a4358251e38..223908a4f529 100644

>> --- a/OvmfPkg/PlatformPei/Xen.c

>> +++ b/OvmfPkg/PlatformPei/Xen.c

>> @@ -171,6 +171,7 @@ XenPublishRamRegions (

>>    //

>>    // Parse RAM in E820 map

>>    //

>> +  E820EntriesCount = 0;

>>    Status = XenGetE820Map (&E820Map, &E820EntriesCount);

>>

>>    ASSERT_EFI_ERROR (Status);

>>

>

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

>


Pushed, thanks
_______________________________________________
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel

Patch

diff --git a/OvmfPkg/PlatformPei/Xen.c b/OvmfPkg/PlatformPei/Xen.c
index 3a4358251e38..223908a4f529 100644
--- a/OvmfPkg/PlatformPei/Xen.c
+++ b/OvmfPkg/PlatformPei/Xen.c
@@ -171,6 +171,7 @@  XenPublishRamRegions (
   //
   // Parse RAM in E820 map
   //
+  E820EntriesCount = 0;
   Status = XenGetE820Map (&E820Map, &E820EntriesCount);
 
   ASSERT_EFI_ERROR (Status);