fix(arm): typecast operands to match data type
This corrects the MISRA violation C2012-10.3:
The value of an expression shall not be assigned to an object with a
narrower essential type or of a different essential type category.
The condition is explicitly checked against 0U, appending 'U' and
typecasting for unsigned comparison.
Change-Id: I7a2565ce6b8beb71dc9c711327ab72ce825111cc
Signed-off-by: Nithin G <nithing@amd.com>
Signed-off-by: Maheedhar Bollapalli <maheedharsai.bollapalli@amd.com>
diff --git a/drivers/arm/cci/cci.c b/drivers/arm/cci/cci.c
index ae2b9bb..8381c0d 100644
--- a/drivers/arm/cci/cci.c
+++ b/drivers/arm/cci/cci.c
@@ -31,14 +31,14 @@
static const int *cci_slave_if_map;
#if ENABLE_ASSERTIONS
-static unsigned int max_master_id;
+static size_t max_master_id;
static int cci_num_slave_ports;
static bool validate_cci_map(const int *map)
{
unsigned int valid_cci_map = 0U;
int slave_if_id;
- unsigned int i;
+ size_t i;
/* Validate the map */
for (i = 0U; i <= max_master_id; i++) {
@@ -109,7 +109,7 @@
#endif /* ENABLE_ASSERTIONS */
void __init cci_init(uintptr_t base, const int *map,
- unsigned int num_cci_masters)
+ size_t num_cci_masters)
{
assert(map != NULL);
assert(base != 0U);
@@ -130,7 +130,7 @@
assert(validate_cci_map(map));
}
-void cci_enable_snoop_dvm_reqs(unsigned int master_id)
+void cci_enable_snoop_dvm_reqs(size_t master_id)
{
int slave_if_id = cci_slave_if_map[master_id];
@@ -158,7 +158,7 @@
}
}
-void cci_disable_snoop_dvm_reqs(unsigned int master_id)
+void cci_disable_snoop_dvm_reqs(size_t master_id)
{
int slave_if_id = cci_slave_if_map[master_id];
diff --git a/include/drivers/arm/cci.h b/include/drivers/arm/cci.h
index 5aea95a..d48b3d6 100644
--- a/include/drivers/arm/cci.h
+++ b/include/drivers/arm/cci.h
@@ -102,6 +102,7 @@
#ifndef __ASSEMBLER__
+#include <stddef.h>
#include <stdint.h>
/* Function declarations */
@@ -116,10 +117,10 @@
* SLAVE_IF_UNUSED should be used in the map to represent no AMBA 4 master exists
* for that interface.
*/
-void cci_init(uintptr_t base, const int *map, unsigned int num_cci_masters);
+void cci_init(uintptr_t base, const int *map, size_t num_cci_masters);
-void cci_enable_snoop_dvm_reqs(unsigned int master_id);
-void cci_disable_snoop_dvm_reqs(unsigned int master_id);
+void cci_enable_snoop_dvm_reqs(size_t master_id);
+void cci_disable_snoop_dvm_reqs(size_t master_id);
#endif /* __ASSEMBLER__ */
#endif /* CCI_H */