diff mbox

[edk2,12/19] ArmVirtPkg/ArmVirtPL031FdtClientLib: eliminate unchecked PcdSetXX() calls

Message ID 20161021212737.15974-13-lersek@redhat.com
State Accepted
Commit a79d29b6d340529029630af05c44a904827b2b63
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/ArmVirtPL031FdtClientLib/ArmVirtPL031FdtClientLib.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

-- 
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/ArmVirtPL031FdtClientLib/ArmVirtPL031FdtClientLib.c | 4 +++-

>  1 file changed, 3 insertions(+), 1 deletion(-)

>

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

> index 3c4e44caa2f4..82de7a51b32e 100644

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

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

> @@ -34,6 +34,7 @@ ArmVirtPL031FdtClientLibConstructor (

>    CONST UINT64                  *Reg;

>    UINT32                        RegSize;

>    UINT64                        RegBase;

> +  RETURN_STATUS                 PcdStatus;

>

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

>                    (VOID **)&FdtClient);

> @@ -60,7 +61,8 @@ ArmVirtPL031FdtClientLibConstructor (

>    RegBase = SwapBytes64 (Reg[0]);

>    ASSERT (RegBase < MAX_UINT32);

>

> -  PcdSet32 (PcdPL031RtcBase, (UINT32)RegBase);

> +  PcdStatus = PcdSet32S (PcdPL031RtcBase, (UINT32)RegBase);

> +  ASSERT_RETURN_ERROR (PcdStatus);

>

>    DEBUG ((EFI_D_INFO, "Found PL031 RTC @ 0x%Lx\n", RegBase));

>

> --

> 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/ArmVirtPL031FdtClientLib/ArmVirtPL031FdtClientLib.c b/ArmVirtPkg/Library/ArmVirtPL031FdtClientLib/ArmVirtPL031FdtClientLib.c
index 3c4e44caa2f4..82de7a51b32e 100644
--- a/ArmVirtPkg/Library/ArmVirtPL031FdtClientLib/ArmVirtPL031FdtClientLib.c
+++ b/ArmVirtPkg/Library/ArmVirtPL031FdtClientLib/ArmVirtPL031FdtClientLib.c
@@ -34,6 +34,7 @@  ArmVirtPL031FdtClientLibConstructor (
   CONST UINT64                  *Reg;
   UINT32                        RegSize;
   UINT64                        RegBase;
+  RETURN_STATUS                 PcdStatus;
 
   Status = gBS->LocateProtocol (&gFdtClientProtocolGuid, NULL,
                   (VOID **)&FdtClient);
@@ -60,7 +61,8 @@  ArmVirtPL031FdtClientLibConstructor (
   RegBase = SwapBytes64 (Reg[0]);
   ASSERT (RegBase < MAX_UINT32);
 
-  PcdSet32 (PcdPL031RtcBase, (UINT32)RegBase);
+  PcdStatus = PcdSet32S (PcdPL031RtcBase, (UINT32)RegBase);
+  ASSERT_RETURN_ERROR (PcdStatus);
 
   DEBUG ((EFI_D_INFO, "Found PL031 RTC @ 0x%Lx\n", RegBase));