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/secure_fw/spm/spm_api.h b/secure_fw/spm/spm_api.h
index d707346..565e708 100644
--- a/secure_fw/spm/spm_api.h
+++ b/secure_fw/spm/spm_api.h
@@ -28,21 +28,17 @@
SPM_ERR_INVALID_CONFIG,
};
-enum spm_part_state_t {
- SPM_PARTITION_STATE_UNINIT = 0,
- SPM_PARTITION_STATE_IDLE,
- SPM_PARTITION_STATE_RUNNING,
- SPM_PARTITION_STATE_HANDLING_IRQ,
- SPM_PARTITION_STATE_SUSPENDED,
- SPM_PARTITION_STATE_BLOCKED,
- SPM_PARTITION_STATE_CLOSED
-};
+#define SPM_PARTITION_STATE_UNINIT 0
+#define SPM_PARTITION_STATE_IDLE 1
+#define SPM_PARTITION_STATE_RUNNING 2
+#define SPM_PARTITION_STATE_HANDLING_IRQ 3
+#define SPM_PARTITION_STATE_SUSPENDED 4
+#define SPM_PARTITION_STATE_BLOCKED 5
+#define SPM_PARTITION_STATE_CLOSED 6
-enum spm_part_flag_mask_t {
- SPM_PART_FLAG_APP_ROT = 0x01,
- SPM_PART_FLAG_PSA_ROT = 0x02,
- SPM_PART_FLAG_IPC = 0x04
-};
+#define SPM_PART_FLAG_APP_ROT 0x01
+#define SPM_PART_FLAG_PSA_ROT 0x02
+#define SPM_PART_FLAG_IPC 0x04
/**
* \brief Holds the iovec parameters that are passed to a service
@@ -339,7 +335,12 @@
* \return Error code \ref spm_err_t
*
* \note This function doesn't check if partition_idx is valid.
- * \note share has to have the value set of \ref tfm_buffer_share_region_e
+ * \note share has to have one of the buffer share values:
+ * - TFM_BUFFER_SHARE_DISABLE
+ * - TFM_BUFFER_SHARE_NS_CODE
+ * - TFM_BUFFER_SHARE_SCRATCH
+ * - TFM_BUFFER_SHARE_PRIV
+ * - TFM_BUFFER_SHARE_DEFAULT
*/
enum spm_err_t tfm_spm_partition_set_share(uint32_t partition_idx,
uint32_t share);