From 845db72261658ec8f1f3c10b0f7408b19fb91a7e Mon Sep 17 00:00:00 2001 From: Louis Mayencourt Date: Mon, 24 Feb 2020 14:37:25 +0000 Subject: [PATCH] fconf: Fix misra issues MISRA C-2012 Rule 20.7: Macro parameter expands into an expression without being wrapped by parentheses. MISRA C-2012 Rule 12.1: Missing explicit parentheses on sub-expression. MISRA C-2012 Rule 18.4: Essential type of the left hand operand is not the same as that of the right operand. Include does not provide any needed symbols. Change-Id: Ie1c6451cfbc8f519146c28b2cf15c50b1f36adc8 Signed-off-by: Louis Mayencourt --- include/lib/fconf/fconf.h | 6 +++--- include/lib/object_pool.h | 6 +++--- plat/arm/common/arm_dyn_cfg.c | 1 - plat/arm/common/arm_fconf_io_storage.c | 1 - plat/arm/common/fconf/arm_fconf_io.c | 4 ++-- 5 files changed, 8 insertions(+), 10 deletions(-) diff --git a/include/lib/fconf/fconf.h b/include/lib/fconf/fconf.h index f58ff5710..0401e5c06 100644 --- a/include/lib/fconf/fconf.h +++ b/include/lib/fconf/fconf.h @@ -14,9 +14,9 @@ #define FCONF_REGISTER_POPULATOR(name, callback) \ __attribute__((used, section(".fconf_populator"))) \ - const struct fconf_populator name##__populator = { \ - .info = #name, \ - .populate = callback \ + const struct fconf_populator (name##__populator) = { \ + .info = (#name), \ + .populate = (callback) \ }; /* diff --git a/include/lib/object_pool.h b/include/lib/object_pool.h index 0f85331a8..66e8c4780 100644 --- a/include/lib/object_pool.h +++ b/include/lib/object_pool.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, ARM Limited and Contributors. All rights reserved. + * Copyright (c) 2018-2020, ARM Limited and Contributors. All rights reserved. * * SPDX-License-Identifier: BSD-3-Clause */ @@ -56,13 +56,13 @@ struct object_pool { */ static inline void *pool_alloc_n(struct object_pool *pool, size_t count) { - if (pool->used + count > pool->capacity) { + if ((pool->used + count) > pool->capacity) { ERROR("Cannot allocate %zu objects out of pool (%zu objects left).\n", count, pool->capacity - pool->used); panic(); } - void *obj = (char *)(pool->objects) + pool->obj_size * pool->used; + void *obj = (char *)(pool->objects) + (pool->obj_size * pool->used); pool->used += count; return obj; } diff --git a/plat/arm/common/arm_dyn_cfg.c b/plat/arm/common/arm_dyn_cfg.c index 443d40fe8..df7530733 100644 --- a/plat/arm/common/arm_dyn_cfg.c +++ b/plat/arm/common/arm_dyn_cfg.c @@ -21,7 +21,6 @@ #include #include #include -#include #if TRUSTED_BOARD_BOOT diff --git a/plat/arm/common/arm_fconf_io_storage.c b/plat/arm/common/arm_fconf_io_storage.c index 341622a0b..6fcfbd6fb 100644 --- a/plat/arm/common/arm_fconf_io_storage.c +++ b/plat/arm/common/arm_fconf_io_storage.c @@ -12,7 +12,6 @@ #include #include #include -#include #include #include diff --git a/plat/arm/common/fconf/arm_fconf_io.c b/plat/arm/common/fconf/arm_fconf_io.c index 3c0586fd0..cfcddc2b2 100644 --- a/plat/arm/common/fconf/arm_fconf_io.c +++ b/plat/arm/common/fconf/arm_fconf_io.c @@ -59,9 +59,9 @@ struct plat_io_policy policies[MAX_NUMBER_IDS] = { #ifdef IMAGE_BL2 #if TRUSTED_BOARD_BOOT -#define FCONF_ARM_IO_UUID_NUMBER 19 +#define FCONF_ARM_IO_UUID_NUMBER U(19) #else -#define FCONF_ARM_IO_UUID_NUMBER 10 +#define FCONF_ARM_IO_UUID_NUMBER U(10) #endif static io_uuid_spec_t fconf_arm_uuids[FCONF_ARM_IO_UUID_NUMBER]; -- 2.39.5