IO Driver Misra Cleanup
This patch cleans up MISRA C violations in the IO driver files. Some
things did not make sense to fix or would require sweeping changes
but the simple issues have been resolved.
Defects Fixed
File Line Rule
drivers/io/io_fip.c 39 MISRA C-2012 Rule 5.6 (required)
drivers/io/io_fip.c 52 MISRA C-2012 Rule 8.9 (advisory)
drivers/io/io_fip.c 60 MISRA C-2012 Rule 5.9 (advisory)
drivers/io/io_fip.c 285 MISRA C-2012 Rule 8.9 (advisory)
drivers/io/io_fip.c 336 MISRA C-2012 Rule 15.4 (advisory)
drivers/io/io_fip.c 340 MISRA C-2012 Rule 15.4 (advisory)
drivers/io/io_fip.c 342 MISRA C-2012 Rule 15.4 (advisory)
drivers/io/io_memmap.c 30 MISRA C-2012 Rule 5.6 (required)
drivers/io/io_memmap.c 32 MISRA C-2012 Rule 5.9 (advisory)
drivers/io/io_memmap.c 85 MISRA C-2012 Rule 11.8 (required)
drivers/io/io_semihosting.c 66 MISRA C-2012 Rule 11.8 (required)
drivers/io/io_storage.c 73 MISRA C-2012 Rule 5.9 (advisory)
drivers/io/io_storage.c 116 MISRA C-2012 Rule 13.4 (advisory)
Signed-off-by: John Powell <john.powell@arm.com>
Change-Id: Id9b1b2b684588d4eaab674ed4ed04f3950dd21f4
diff --git a/drivers/io/io_storage.c b/drivers/io/io_storage.c
index ba6f094..0534268 100644
--- a/drivers/io/io_storage.c
+++ b/drivers/io/io_storage.c
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2014-2017, ARM Limited and Contributors. All rights reserved.
+ * Copyright (c) 2014-2020, ARM Limited and Contributors. All rights reserved.
*
* SPDX-License-Identifier: BSD-3-Clause
*/
@@ -32,14 +32,13 @@
#if ENABLE_ASSERTIONS
/* Return a boolean value indicating whether a device connector is valid */
-static int is_valid_dev_connector(const io_dev_connector_t *dev_con)
+static bool is_valid_dev_connector(const io_dev_connector_t *dev_con)
{
return (dev_con != NULL) && (dev_con->dev_open != NULL);
}
-
/* Return a boolean value indicating whether a device handle is valid */
-static int is_valid_dev(const uintptr_t dev_handle)
+static bool is_valid_dev(const uintptr_t dev_handle)
{
const io_dev_info_t *dev = (io_dev_info_t *)dev_handle;
@@ -50,7 +49,7 @@
/* Return a boolean value indicating whether an IO entity is valid */
-static int is_valid_entity(const uintptr_t handle)
+static bool is_valid_entity(const uintptr_t handle)
{
const io_entity_t *entity = (io_entity_t *)handle;
@@ -60,7 +59,7 @@
/* Return a boolean value indicating whether a seek mode is valid */
-static int is_valid_seek_mode(io_seek_mode_t mode)
+static bool is_valid_seek_mode(io_seek_mode_t mode)
{
return ((mode != IO_SEEK_INVALID) && (mode < IO_SEEK_MAX));
}
@@ -70,7 +69,8 @@
/* Open a connection to a specific device */
-static int dev_open(const io_dev_connector_t *dev_con, const uintptr_t dev_spec,
+static int io_storage_dev_open(const io_dev_connector_t *dev_con,
+ const uintptr_t dev_spec,
io_dev_info_t **dev_info)
{
assert(dev_info != NULL);
@@ -113,7 +113,8 @@
unsigned int index = 0;
result = find_first_entity(NULL, &index);
assert(result == 0);
- *entity = entity_map[index] = &entity_pool[index];
+ *entity = &entity_pool[index];
+ entity_map[index] = &entity_pool[index];
++entity_count;
}
@@ -161,8 +162,7 @@
uintptr_t *handle)
{
assert(handle != NULL);
-
- return dev_open(dev_con, dev_spec, (io_dev_info_t **)handle);
+ return io_storage_dev_open(dev_con, dev_spec, (io_dev_info_t **)handle);
}