diff mbox

[edk2,13/19] ArmVirtPkg/ArmVirtPlatformLib: eliminate unchecked PcdSetXX() calls

Message ID 20161021212737.15974-14-lersek@redhat.com
State Accepted
Commit a9f63d697f6959772618691eda252d99c207b6c0
Headers show

Commit Message

Laszlo Ersek Oct. 21, 2016, 9:27 p.m. UTC
These are deprecated / disabled under the
DISABLE_NEW_DEPRECATED_INTERFACES feature test macro.

Introduce a variable called PcdStatus, and use it to assert the success of
these operations (there is no reason for them to fail here).

Cc: Ard Biesheuvel <ard.biesheuvel@linaro.org>
Ref: https://bugzilla.tianocore.org/show_bug.cgi?id=165
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Laszlo Ersek <lersek@redhat.com>

---
 ArmVirtPkg/Library/ArmVirtPlatformLib/Virt.c | 18 ++++++++++--------
 1 file changed, 10 insertions(+), 8 deletions(-)

-- 
2.9.2


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

Comments

Ard Biesheuvel Oct. 24, 2016, 7:59 a.m. UTC | #1
On 21 October 2016 at 22:27, Laszlo Ersek <lersek@redhat.com> wrote:
> These are deprecated / disabled under the

> DISABLE_NEW_DEPRECATED_INTERFACES feature test macro.

>

> Introduce a variable called PcdStatus, and use it to assert the success of

> these operations (there is no reason for them to fail here).

>

> Cc: Ard Biesheuvel <ard.biesheuvel@linaro.org>

> Ref: https://bugzilla.tianocore.org/show_bug.cgi?id=165

> Contributed-under: TianoCore Contribution Agreement 1.0

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


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


> ---

>  ArmVirtPkg/Library/ArmVirtPlatformLib/Virt.c | 18 ++++++++++--------

>  1 file changed, 10 insertions(+), 8 deletions(-)

>

> diff --git a/ArmVirtPkg/Library/ArmVirtPlatformLib/Virt.c b/ArmVirtPkg/Library/ArmVirtPlatformLib/Virt.c

> index 7a0fc0e75e37..fcaf3c681a97 100644

> --- a/ArmVirtPkg/Library/ArmVirtPlatformLib/Virt.c

> +++ b/ArmVirtPkg/Library/ArmVirtPlatformLib/Virt.c

> @@ -70,13 +70,14 @@ ArmPlatformInitializeSystemMemory (

>    VOID

>    )

>  {

> -  VOID         *DeviceTreeBase;

> -  INT32        Node, Prev;

> -  UINT64       NewBase, CurBase;

> -  UINT64       NewSize, CurSize;

> -  CONST CHAR8  *Type;

> -  INT32        Len;

> -  CONST UINT64 *RegProp;

> +  VOID          *DeviceTreeBase;

> +  INT32         Node, Prev;

> +  UINT64        NewBase, CurBase;

> +  UINT64        NewSize, CurSize;

> +  CONST CHAR8   *Type;

> +  INT32         Len;

> +  CONST UINT64  *RegProp;

> +  RETURN_STATUS PcdStatus;

>

>    NewBase = 0;

>    NewSize = 0;

> @@ -131,7 +132,8 @@ ArmPlatformInitializeSystemMemory (

>    // Make sure the start of DRAM matches our expectation

>    //

>    ASSERT (FixedPcdGet64 (PcdSystemMemoryBase) == NewBase);

> -  PcdSet64 (PcdSystemMemorySize, NewSize);

> +  PcdStatus = PcdSet64S (PcdSystemMemorySize, NewSize);

> +  ASSERT_RETURN_ERROR (PcdStatus);

>

>    //

>    // We need to make sure that the machine we are running on has at least

> --

> 2.9.2

>

>

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

Patch

diff --git a/ArmVirtPkg/Library/ArmVirtPlatformLib/Virt.c b/ArmVirtPkg/Library/ArmVirtPlatformLib/Virt.c
index 7a0fc0e75e37..fcaf3c681a97 100644
--- a/ArmVirtPkg/Library/ArmVirtPlatformLib/Virt.c
+++ b/ArmVirtPkg/Library/ArmVirtPlatformLib/Virt.c
@@ -70,13 +70,14 @@  ArmPlatformInitializeSystemMemory (
   VOID
   )
 {
-  VOID         *DeviceTreeBase;
-  INT32        Node, Prev;
-  UINT64       NewBase, CurBase;
-  UINT64       NewSize, CurSize;
-  CONST CHAR8  *Type;
-  INT32        Len;
-  CONST UINT64 *RegProp;
+  VOID          *DeviceTreeBase;
+  INT32         Node, Prev;
+  UINT64        NewBase, CurBase;
+  UINT64        NewSize, CurSize;
+  CONST CHAR8   *Type;
+  INT32         Len;
+  CONST UINT64  *RegProp;
+  RETURN_STATUS PcdStatus;
 
   NewBase = 0;
   NewSize = 0;
@@ -131,7 +132,8 @@  ArmPlatformInitializeSystemMemory (
   // Make sure the start of DRAM matches our expectation
   //
   ASSERT (FixedPcdGet64 (PcdSystemMemoryBase) == NewBase);
-  PcdSet64 (PcdSystemMemorySize, NewSize);
+  PcdStatus = PcdSet64S (PcdSystemMemorySize, NewSize);
+  ASSERT_RETURN_ERROR (PcdStatus);
 
   //
   // We need to make sure that the machine we are running on has at least