SPM: Improve code quality

This patch fixes the following things:
* avoid implicit casting by using matching types or casting when it is
safe.
* check the returning value of functions
* add const keyword when mutability is not required
* cast unused parameters to void to be more explicit
* add parenthesis around amcro parameters
* encapsulate function-like macros into a function to avoid name clashes

Change-Id: Ia23e859a9008be705df4424d9cc7d09e45537994
Signed-off-by: Hugues de Valon <hugues.devalon@arm.com>
diff --git a/secure_fw/spm/spm_db_setup.h b/secure_fw/spm/spm_db_setup.h
index d79fed9..57da372 100644
--- a/secure_fw/spm/spm_db_setup.h
+++ b/secure_fw/spm/spm_db_setup.h
@@ -111,21 +111,21 @@
         ++g_spm_partition_db.partition_count;                                \
     } while (0)
 
-#define PARTITION_ADD_INIT_FUNC(partition, init_func)                 \
-    do {                                                              \
-        extern int32_t init_func(void);                               \
-        uint32_t partition_idx = get_partition_idx(partition##_ID);   \
-        struct spm_partition_desc_t *part_ptr =                       \
-            &(g_spm_partition_db.partitions[partition_idx]);          \
-        part_ptr->static_data.partition_init = init_func;             \
+#define PARTITION_ADD_INIT_FUNC(partition, init_func)                     \
+    do {                                                                  \
+        extern int32_t init_func(void);                                   \
+        uint32_t partition_idx = get_partition_idx(partition##_ID);       \
+        struct spm_partition_desc_t *part_ptr =                           \
+            &(g_spm_partition_db.partitions[partition_idx]);              \
+        part_ptr->static_data.partition_init = init_func;                 \
     } while (0)
 
-#define PARTITION_ADD_PERIPHERAL(partition, peripheral)               \
-    do {                                                               \
-        uint32_t partition_idx = get_partition_idx(partition##_ID);    \
-        struct spm_partition_desc_t *part_ptr =                        \
-            &(g_spm_partition_db.partitions[partition_idx]);           \
-        part_ptr->platform_data = peripheral;                          \
+#define PARTITION_ADD_PERIPHERAL(partition, peripheral)                    \
+    do {                                                                   \
+        uint32_t partition_idx = get_partition_idx(partition##_ID);        \
+        struct spm_partition_desc_t *part_ptr =                            \
+            &(g_spm_partition_db.partitions[partition_idx]);               \
+        part_ptr->platform_data = peripheral;                              \
     } while (0)
 
 #endif /* __SPM_DB_SETUP_H__ */