diff mbox

[edk2,11/19] ArmVirtPkg/ArmVirtGicArchLib: eliminate unchecked PcdSetXX() calls

Message ID 20161021212737.15974-12-lersek@redhat.com
State Accepted
Commit 65ebe6e6c9789e36be6d1adb1105469a189f23ab
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/ArmVirtGicArchLib/ArmVirtGicArchLib.c | 13 +++++++++----
 1 file changed, 9 insertions(+), 4 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, 8 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/ArmVirtGicArchLib/ArmVirtGicArchLib.c | 13 +++++++++----

>  1 file changed, 9 insertions(+), 4 deletions(-)

>

> diff --git a/ArmVirtPkg/Library/ArmVirtGicArchLib/ArmVirtGicArchLib.c b/ArmVirtPkg/Library/ArmVirtGicArchLib/ArmVirtGicArchLib.c

> index 648806126e78..dc1f5155f1fc 100644

> --- a/ArmVirtPkg/Library/ArmVirtGicArchLib/ArmVirtGicArchLib.c

> +++ b/ArmVirtPkg/Library/ArmVirtGicArchLib/ArmVirtGicArchLib.c

> @@ -41,6 +41,7 @@ ArmVirtGicArchLibConstructor (

>    UINTN                 GicRevision;

>    EFI_STATUS            Status;

>    UINT64                DistBase, CpuBase, RedistBase;

> +  RETURN_STATUS         PcdStatus;

>

>    Status = gBS->LocateProtocol (&gFdtClientProtocolGuid, NULL,

>                    (VOID **)&FdtClient);

> @@ -85,8 +86,10 @@ ArmVirtGicArchLibConstructor (

>      RedistBase = SwapBytes64 (Reg[2]);

>      ASSERT (RedistBase < MAX_UINTN);

>

> -    PcdSet64 (PcdGicDistributorBase, DistBase);

> -    PcdSet64 (PcdGicRedistributorsBase, RedistBase);

> +    PcdStatus = PcdSet64S (PcdGicDistributorBase, DistBase);

> +    ASSERT_RETURN_ERROR (PcdStatus);

> +    PcdStatus = PcdSet64S (PcdGicRedistributorsBase, RedistBase);

> +    ASSERT_RETURN_ERROR (PcdStatus);

>

>      DEBUG ((EFI_D_INFO, "Found GIC v3 (re)distributor @ 0x%Lx (0x%Lx)\n",

>        DistBase, RedistBase));

> @@ -120,8 +123,10 @@ ArmVirtGicArchLibConstructor (

>      ASSERT (DistBase < MAX_UINTN);

>      ASSERT (CpuBase < MAX_UINTN);

>

> -    PcdSet64 (PcdGicDistributorBase, DistBase);

> -    PcdSet64 (PcdGicInterruptInterfaceBase, CpuBase);

> +    PcdStatus = PcdSet64S (PcdGicDistributorBase, DistBase);

> +    ASSERT_RETURN_ERROR (PcdStatus);

> +    PcdStatus = PcdSet64S (PcdGicInterruptInterfaceBase, CpuBase);

> +    ASSERT_RETURN_ERROR (PcdStatus);

>

>      DEBUG ((EFI_D_INFO, "Found GIC @ 0x%Lx/0x%Lx\n", DistBase, CpuBase));

>

> --

> 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/ArmVirtGicArchLib/ArmVirtGicArchLib.c b/ArmVirtPkg/Library/ArmVirtGicArchLib/ArmVirtGicArchLib.c
index 648806126e78..dc1f5155f1fc 100644
--- a/ArmVirtPkg/Library/ArmVirtGicArchLib/ArmVirtGicArchLib.c
+++ b/ArmVirtPkg/Library/ArmVirtGicArchLib/ArmVirtGicArchLib.c
@@ -41,6 +41,7 @@  ArmVirtGicArchLibConstructor (
   UINTN                 GicRevision;
   EFI_STATUS            Status;
   UINT64                DistBase, CpuBase, RedistBase;
+  RETURN_STATUS         PcdStatus;
 
   Status = gBS->LocateProtocol (&gFdtClientProtocolGuid, NULL,
                   (VOID **)&FdtClient);
@@ -85,8 +86,10 @@  ArmVirtGicArchLibConstructor (
     RedistBase = SwapBytes64 (Reg[2]);
     ASSERT (RedistBase < MAX_UINTN);
 
-    PcdSet64 (PcdGicDistributorBase, DistBase);
-    PcdSet64 (PcdGicRedistributorsBase, RedistBase);
+    PcdStatus = PcdSet64S (PcdGicDistributorBase, DistBase);
+    ASSERT_RETURN_ERROR (PcdStatus);
+    PcdStatus = PcdSet64S (PcdGicRedistributorsBase, RedistBase);
+    ASSERT_RETURN_ERROR (PcdStatus);
 
     DEBUG ((EFI_D_INFO, "Found GIC v3 (re)distributor @ 0x%Lx (0x%Lx)\n",
       DistBase, RedistBase));
@@ -120,8 +123,10 @@  ArmVirtGicArchLibConstructor (
     ASSERT (DistBase < MAX_UINTN);
     ASSERT (CpuBase < MAX_UINTN);
 
-    PcdSet64 (PcdGicDistributorBase, DistBase);
-    PcdSet64 (PcdGicInterruptInterfaceBase, CpuBase);
+    PcdStatus = PcdSet64S (PcdGicDistributorBase, DistBase);
+    ASSERT_RETURN_ERROR (PcdStatus);
+    PcdStatus = PcdSet64S (PcdGicInterruptInterfaceBase, CpuBase);
+    ASSERT_RETURN_ERROR (PcdStatus);
 
     DEBUG ((EFI_D_INFO, "Found GIC @ 0x%Lx/0x%Lx\n", DistBase, CpuBase));