Core: Improve code quality
This patch fixes the following things:
* avoid implicit casting by using matching types or casting
* avoid implicit casting between enum tfm_buffer_share_region_e and
uint32_t types by replacing the enumerated type with uint32_t and its
constants with preprocessor constants
* make explicit that the return value of a function is not used
* remove function return type if not needed
* replace preprocessor if condition by ifdef if only definition is
checked
* replace enumerated types not used by preprocessor constants
Change-Id: Ib718937f89631cae2212de1fc748c48461b683d0
Signed-off-by: Hugues de Valon <hugues.devalon@arm.com>
diff --git a/platform/ext/target/mps2/an519/spm_hal.c b/platform/ext/target/mps2/an519/spm_hal.c
index 1c07116..d25f30f 100644
--- a/platform/ext/target/mps2/an519/spm_hal.c
+++ b/platform/ext/target/mps2/an519/spm_hal.c
@@ -282,8 +282,7 @@
/**
* Set share region to which the partition needs access
*/
-enum spm_err_t tfm_spm_hal_set_share_region(
- enum tfm_buffer_share_region_e share)
+enum spm_err_t tfm_spm_hal_set_share_region(uint32_t share)
{
struct mpu_armv8m_region_cfg_t region_cfg;
enum spm_err_t res = SPM_ERR_INVALID_CONFIG;
diff --git a/platform/ext/target/mps2/an521/spm_hal.c b/platform/ext/target/mps2/an521/spm_hal.c
index bc91d41..183d448 100644
--- a/platform/ext/target/mps2/an521/spm_hal.c
+++ b/platform/ext/target/mps2/an521/spm_hal.c
@@ -282,8 +282,7 @@
/**
* Set share region to which the partition needs access
*/
-enum spm_err_t tfm_spm_hal_set_share_region(
- enum tfm_buffer_share_region_e share)
+enum spm_err_t tfm_spm_hal_set_share_region(uint32_t share)
{
struct mpu_armv8m_region_cfg_t region_cfg;
enum spm_err_t res = SPM_ERR_INVALID_CONFIG;
diff --git a/platform/ext/target/musca_a/spm_hal.c b/platform/ext/target/musca_a/spm_hal.c
index 5637aaf..7bb8159 100644
--- a/platform/ext/target/musca_a/spm_hal.c
+++ b/platform/ext/target/musca_a/spm_hal.c
@@ -282,8 +282,7 @@
/**
* Set share region to which the partition needs access
*/
-enum spm_err_t tfm_spm_hal_set_share_region(
- enum tfm_buffer_share_region_e share)
+enum spm_err_t tfm_spm_hal_set_share_region(uint32_t share)
{
struct mpu_armv8m_region_cfg_t region_cfg;
enum spm_err_t res = SPM_ERR_INVALID_CONFIG;
diff --git a/platform/ext/target/musca_b1/spm_hal.c b/platform/ext/target/musca_b1/spm_hal.c
index 84fc144..2ab6f68 100644
--- a/platform/ext/target/musca_b1/spm_hal.c
+++ b/platform/ext/target/musca_b1/spm_hal.c
@@ -282,8 +282,7 @@
/**
* Set share region to which the partition needs access
*/
-enum spm_err_t tfm_spm_hal_set_share_region(
- enum tfm_buffer_share_region_e share)
+enum spm_err_t tfm_spm_hal_set_share_region(uint32_t share)
{
struct mpu_armv8m_region_cfg_t region_cfg;
enum spm_err_t res = SPM_ERR_INVALID_CONFIG;
diff --git a/platform/include/tfm_spm_hal.h b/platform/include/tfm_spm_hal.h
index cb54186..9f1e7a6 100644
--- a/platform/include/tfm_spm_hal.h
+++ b/platform/include/tfm_spm_hal.h
@@ -237,8 +237,7 @@
*
* \return Returns the result operation as per \ref spm_err_t
*/
-enum spm_err_t tfm_spm_hal_set_share_region(
- enum tfm_buffer_share_region_e share);
+enum spm_err_t tfm_spm_hal_set_share_region(uint32_t share);
#endif
#endif /* __TFM_SPM_HAL_H__ */