[edk2-devel] [PATCH v1 04/12] ArmPkg: Fix Non-Boolean comparison in ArmGicEnableDistributor
Ard Biesheuvel
ardb at kernel.org
Tue May 23 13:32:21 UTC 2023
On Tue, 23 May 2023 at 15:04, Sami Mujawar <sami.mujawar at arm.com> wrote:
>
> According to edk2 coding standard specification, Non-Boolean
> comparisons must use a compare operator (==, !=, >, < >=, <=).
> See Section 5.7.2.1 at https://edk2-docs.gitbook.io/
> edk-ii-c-coding-standards-specification/5_source_files/
> 57_c_programming
>
> Therefore, fix the comparison in ArmGicEnableDistributor()
>
> Signed-off-by: Sami Mujawar <sami.mujawar at arm.com>
> ---
> ArmPkg/Drivers/ArmGic/ArmGicNonSecLib.c | 5 ++++-
> 1 file changed, 4 insertions(+), 1 deletion(-)
>
> diff --git a/ArmPkg/Drivers/ArmGic/ArmGicNonSecLib.c b/ArmPkg/Drivers/ArmGic/ArmGicNonSecLib.c
> index c17cbe041e8a9ceb8c8c3a6b953ff88b75f6f206..1ca66a40940434d6d89e243650f3e81aa3f588b5 100644
> --- a/ArmPkg/Drivers/ArmGic/ArmGicNonSecLib.c
> +++ b/ArmPkg/Drivers/ArmGic/ArmGicNonSecLib.c
> @@ -26,7 +26,10 @@ ArmGicEnableDistributor (
> if (Revision == ARM_GIC_ARCH_REVISION_2) {
> MmioWrite32 (GicDistributorBase + ARM_GIC_ICDDCR, 0x1);
> } else {
> - if (MmioRead32 (GicDistributorBase + ARM_GIC_ICDDCR) & ARM_GIC_ICDDCR_ARE) {
> + if ((MmioRead32 (
> + GicDistributorBase + ARM_GIC_ICDDCR
> + ) & ARM_GIC_ICDDCR_ARE) != 0)
> + {
This coding style is terrible. Mind using a temporary variable for the
result of the MmioRead32() instead?
> MmioOr32 (GicDistributorBase + ARM_GIC_ICDDCR, 0x2);
> } else {
> MmioOr32 (GicDistributorBase + ARM_GIC_ICDDCR, 0x1);
> --
> 'Guid(CE165669-3EF3-493F-B85D-6190EE5B9759)'
>
-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#105189): https://edk2.groups.io/g/devel/message/105189
Mute This Topic: https://groups.io/mt/99086468/1813853
Group Owner: devel+owner at edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [edk2-devel-archive at redhat.com]
-=-=-=-=-=-=-=-=-=-=-=-
More information about the edk2-devel-archive
mailing list