diff mbox

[edk2,14/19] ArmVirtPkg/ArmVirtTimerFdtClientLib: eliminate unchecked PcdSetXX() calls

Message ID 20161021212737.15974-15-lersek@redhat.com
State Accepted
Commit 537eb0722b205671237b22e7e8785ce47e93c4d4
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/ArmVirtTimerFdtClientLib/ArmVirtTimerFdtClientLib.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, 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/ArmVirtTimerFdtClientLib/ArmVirtTimerFdtClientLib.c | 13 +++++++++----

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

>

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

> index 6e7461c6b2e7..c40838632352 100644

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

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

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

>    CONST INTERRUPT_PROPERTY      *InterruptProp;

>    UINT32                        PropSize;

>    INT32                         SecIntrNum, IntrNum, VirtIntrNum, HypIntrNum;

> +  RETURN_STATUS                 PcdStatus;

>

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

>                    (VOID **)&FdtClient);

> @@ -78,10 +79,14 @@ ArmVirtTimerFdtClientLibConstructor (

>    DEBUG ((EFI_D_INFO, "Found Timer interrupts %d, %d, %d, %d\n",

>      SecIntrNum, IntrNum, VirtIntrNum, HypIntrNum));

>

> -  PcdSet32 (PcdArmArchTimerSecIntrNum, SecIntrNum);

> -  PcdSet32 (PcdArmArchTimerIntrNum, IntrNum);

> -  PcdSet32 (PcdArmArchTimerVirtIntrNum, VirtIntrNum);

> -  PcdSet32 (PcdArmArchTimerHypIntrNum, HypIntrNum);

> +  PcdStatus = PcdSet32S (PcdArmArchTimerSecIntrNum, SecIntrNum);

> +  ASSERT_RETURN_ERROR (PcdStatus);

> +  PcdStatus = PcdSet32S (PcdArmArchTimerIntrNum, IntrNum);

> +  ASSERT_RETURN_ERROR (PcdStatus);

> +  PcdStatus = PcdSet32S (PcdArmArchTimerVirtIntrNum, VirtIntrNum);

> +  ASSERT_RETURN_ERROR (PcdStatus);

> +  PcdStatus = PcdSet32S (PcdArmArchTimerHypIntrNum, HypIntrNum);

> +  ASSERT_RETURN_ERROR (PcdStatus);

>

>    return EFI_SUCCESS;

>  }

> --

> 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/ArmVirtTimerFdtClientLib/ArmVirtTimerFdtClientLib.c b/ArmVirtPkg/Library/ArmVirtTimerFdtClientLib/ArmVirtTimerFdtClientLib.c
index 6e7461c6b2e7..c40838632352 100644
--- a/ArmVirtPkg/Library/ArmVirtTimerFdtClientLib/ArmVirtTimerFdtClientLib.c
+++ b/ArmVirtPkg/Library/ArmVirtTimerFdtClientLib/ArmVirtTimerFdtClientLib.c
@@ -41,6 +41,7 @@  ArmVirtTimerFdtClientLibConstructor (
   CONST INTERRUPT_PROPERTY      *InterruptProp;
   UINT32                        PropSize;
   INT32                         SecIntrNum, IntrNum, VirtIntrNum, HypIntrNum;
+  RETURN_STATUS                 PcdStatus;
 
   Status = gBS->LocateProtocol (&gFdtClientProtocolGuid, NULL,
                   (VOID **)&FdtClient);
@@ -78,10 +79,14 @@  ArmVirtTimerFdtClientLibConstructor (
   DEBUG ((EFI_D_INFO, "Found Timer interrupts %d, %d, %d, %d\n",
     SecIntrNum, IntrNum, VirtIntrNum, HypIntrNum));
 
-  PcdSet32 (PcdArmArchTimerSecIntrNum, SecIntrNum);
-  PcdSet32 (PcdArmArchTimerIntrNum, IntrNum);
-  PcdSet32 (PcdArmArchTimerVirtIntrNum, VirtIntrNum);
-  PcdSet32 (PcdArmArchTimerHypIntrNum, HypIntrNum);
+  PcdStatus = PcdSet32S (PcdArmArchTimerSecIntrNum, SecIntrNum);
+  ASSERT_RETURN_ERROR (PcdStatus);
+  PcdStatus = PcdSet32S (PcdArmArchTimerIntrNum, IntrNum);
+  ASSERT_RETURN_ERROR (PcdStatus);
+  PcdStatus = PcdSet32S (PcdArmArchTimerVirtIntrNum, VirtIntrNum);
+  ASSERT_RETURN_ERROR (PcdStatus);
+  PcdStatus = PcdSet32S (PcdArmArchTimerHypIntrNum, HypIntrNum);
+  ASSERT_RETURN_ERROR (PcdStatus);
 
   return EFI_SUCCESS;
 }