summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTaticharla Venkata Sai <venkatasai.taticharla@amd.com>2025-09-09 17:07:47 +0530
committerVenkata Sai Taticharla <venkatasai.taticharla@amd.com>2026-01-08 16:31:27 +0000
commit3b9016d683c49378ecd56f9647932a9d042ca4f1 (patch)
tree7f3968d85cb2e5fdadceea7dfa4a7c4c5cb26fbf
parent6de7520a3b997a246d341b7df465844d5574a08d (diff)
downloadarm-trusted-firmware-3b9016d683c49378ecd56f9647932a9d042ca4f1.tar.gz
arm-trusted-firmware-3b9016d683c49378ecd56f9647932a9d042ca4f1.zip
fix(optee): typecast operands to match data type
This corrects the MISRA violation C2012-10.1: Operands of different essential types were used in bitwise, arithmetic, or logical operations, violating type uniformity. The fix suffixes integer literals with 'U' to specify them as unsigned constants, ensuring operands in bitwise, arithmetic, or logical operations have consistent unsigned types. This approach avoids implicit type promotions and maintains type safety by properly declaring the intended type of literals. Change-Id: Iead89348f107772175bbf7768554258b0095a922 Signed-off-by: Taticharla Venkata Sai <venkatasai.taticharla@amd.com>
-rw-r--r--services/spd/opteed/opteed_main.c4
-rw-r--r--services/spd/opteed/opteed_private.h12
-rw-r--r--services/spd/opteed/teesmc_opteed.h18
-rw-r--r--services/spd/opteed/teesmc_opteed_macros.h2
4 files changed, 18 insertions, 18 deletions
diff --git a/services/spd/opteed/opteed_main.c b/services/spd/opteed/opteed_main.c
index b682a698d..cf3a5dce4 100644
--- a/services/spd/opteed/opteed_main.c
+++ b/services/spd/opteed/opteed_main.c
@@ -177,7 +177,7 @@ static int32_t opteed_setup(void)
* conditionally include the SPD service
*/
optee_ep_info = bl31_plat_get_next_image_ep_info(SECURE);
- if (!optee_ep_info) {
+ if (optee_ep_info == NULL) {
WARN("No OPTEE provided by BL2 boot loader, Booting device"
" without OPTEE initialization. SMC`s destined for OPTEE"
" will return SMC_UNK\n");
@@ -189,7 +189,7 @@ static int32_t opteed_setup(void)
* signalling failure initializing the service. We bail out without
* registering any handlers
*/
- if (!optee_ep_info->pc)
+ if (optee_ep_info->pc == 0U)
return 1;
#if TRANSFER_LIST
diff --git a/services/spd/opteed/opteed_private.h b/services/spd/opteed/opteed_private.h
index c484516d3..22fcacdd7 100644
--- a/services/spd/opteed/opteed_private.h
+++ b/services/spd/opteed/opteed_private.h
@@ -18,12 +18,12 @@
* OPTEE PM state information e.g. OPTEE is suspended, uninitialised etc
* and macros to access the state information in the per-cpu 'state' flags
******************************************************************************/
-#define OPTEE_PSTATE_OFF 1
-#define OPTEE_PSTATE_ON 2
-#define OPTEE_PSTATE_SUSPEND 3
-#define OPTEE_PSTATE_UNKNOWN 0
-#define OPTEE_PSTATE_SHIFT 0
-#define OPTEE_PSTATE_MASK 0x3
+#define OPTEE_PSTATE_OFF 1U
+#define OPTEE_PSTATE_ON 2U
+#define OPTEE_PSTATE_SUSPEND 3U
+#define OPTEE_PSTATE_UNKNOWN 0U
+#define OPTEE_PSTATE_SHIFT 0U
+#define OPTEE_PSTATE_MASK 0x3U
#define get_optee_pstate(state) ((state >> OPTEE_PSTATE_SHIFT) & \
OPTEE_PSTATE_MASK)
#define clr_optee_pstate(state) (state &= ~(OPTEE_PSTATE_MASK \
diff --git a/services/spd/opteed/teesmc_opteed.h b/services/spd/opteed/teesmc_opteed.h
index 4026fa4da..254261a72 100644
--- a/services/spd/opteed/teesmc_opteed.h
+++ b/services/spd/opteed/teesmc_opteed.h
@@ -30,7 +30,7 @@
* r0/x0 SMC Function ID, TEESMC_OPTEED_RETURN_ENTRY_DONE
* r1/x1 Pointer to entry vector
*/
-#define TEESMC_OPTEED_FUNCID_RETURN_ENTRY_DONE 0
+#define TEESMC_OPTEED_FUNCID_RETURN_ENTRY_DONE 0U
#define TEESMC_OPTEED_RETURN_ENTRY_DONE \
TEESMC_OPTEED_RV(TEESMC_OPTEED_FUNCID_RETURN_ENTRY_DONE)
@@ -43,7 +43,7 @@
* r0/x0 SMC Function ID, TEESMC_OPTEED_RETURN_ON_DONE
* r1/x1 0 on success and anything else to indicate error condition
*/
-#define TEESMC_OPTEED_FUNCID_RETURN_ON_DONE 1
+#define TEESMC_OPTEED_FUNCID_RETURN_ON_DONE 1U
#define TEESMC_OPTEED_RETURN_ON_DONE \
TEESMC_OPTEED_RV(TEESMC_OPTEED_FUNCID_RETURN_ON_DONE)
@@ -54,7 +54,7 @@
* r0/x0 SMC Function ID, TEESMC_OPTEED_RETURN_OFF_DONE
* r1/x1 0 on success and anything else to indicate error condition
*/
-#define TEESMC_OPTEED_FUNCID_RETURN_OFF_DONE 2
+#define TEESMC_OPTEED_FUNCID_RETURN_OFF_DONE 2U
#define TEESMC_OPTEED_RETURN_OFF_DONE \
TEESMC_OPTEED_RV(TEESMC_OPTEED_FUNCID_RETURN_OFF_DONE)
@@ -65,7 +65,7 @@
* r0/x0 SMC Function ID, TEESMC_OPTEED_RETURN_SUSPEND_DONE
* r1/x1 0 on success and anything else to indicate error condition
*/
-#define TEESMC_OPTEED_FUNCID_RETURN_SUSPEND_DONE 3
+#define TEESMC_OPTEED_FUNCID_RETURN_SUSPEND_DONE 3U
#define TEESMC_OPTEED_RETURN_SUSPEND_DONE \
TEESMC_OPTEED_RV(TEESMC_OPTEED_FUNCID_RETURN_SUSPEND_DONE)
@@ -76,7 +76,7 @@
* r0/x0 SMC Function ID, TEESMC_OPTEED_RETURN_RESUME_DONE
* r1/x1 0 on success and anything else to indicate error condition
*/
-#define TEESMC_OPTEED_FUNCID_RETURN_RESUME_DONE 4
+#define TEESMC_OPTEED_FUNCID_RETURN_RESUME_DONE 4U
#define TEESMC_OPTEED_RETURN_RESUME_DONE \
TEESMC_OPTEED_RV(TEESMC_OPTEED_FUNCID_RETURN_RESUME_DONE)
@@ -88,7 +88,7 @@
* r1-4/x1-4 Return value 0-3 which will passed to normal world in
* r0-3/x0-3
*/
-#define TEESMC_OPTEED_FUNCID_RETURN_CALL_DONE 5
+#define TEESMC_OPTEED_FUNCID_RETURN_CALL_DONE 5U
#define TEESMC_OPTEED_RETURN_CALL_DONE \
TEESMC_OPTEED_RV(TEESMC_OPTEED_FUNCID_RETURN_CALL_DONE)
@@ -98,7 +98,7 @@
* Register usage:
* r0/x0 SMC Function ID, TEESMC_OPTEED_RETURN_FIQ_DONE
*/
-#define TEESMC_OPTEED_FUNCID_RETURN_FIQ_DONE 6
+#define TEESMC_OPTEED_FUNCID_RETURN_FIQ_DONE 6U
#define TEESMC_OPTEED_RETURN_FIQ_DONE \
TEESMC_OPTEED_RV(TEESMC_OPTEED_FUNCID_RETURN_FIQ_DONE)
@@ -108,7 +108,7 @@
* Register usage:
* r0/x0 SMC Function ID, TEESMC_OPTEED_RETURN_SYSTEM_OFF_DONE
*/
-#define TEESMC_OPTEED_FUNCID_RETURN_SYSTEM_OFF_DONE 7
+#define TEESMC_OPTEED_FUNCID_RETURN_SYSTEM_OFF_DONE 7U
#define TEESMC_OPTEED_RETURN_SYSTEM_OFF_DONE \
TEESMC_OPTEED_RV(TEESMC_OPTEED_FUNCID_RETURN_SYSTEM_OFF_DONE)
@@ -118,7 +118,7 @@
* Register usage:
* r0/x0 SMC Function ID, TEESMC_OPTEED_RETURN_SYSTEM_RESET_DONE
*/
-#define TEESMC_OPTEED_FUNCID_RETURN_SYSTEM_RESET_DONE 8
+#define TEESMC_OPTEED_FUNCID_RETURN_SYSTEM_RESET_DONE 8U
#define TEESMC_OPTEED_RETURN_SYSTEM_RESET_DONE \
TEESMC_OPTEED_RV(TEESMC_OPTEED_FUNCID_RETURN_SYSTEM_RESET_DONE)
diff --git a/services/spd/opteed/teesmc_opteed_macros.h b/services/spd/opteed/teesmc_opteed_macros.h
index 721914063..f87faa88b 100644
--- a/services/spd/opteed/teesmc_opteed_macros.h
+++ b/services/spd/opteed/teesmc_opteed_macros.h
@@ -11,7 +11,7 @@
#define TEESMC_OPTEED_RV(func_num) \
((SMC_TYPE_FAST << FUNCID_TYPE_SHIFT) | \
((SMC_32) << FUNCID_CC_SHIFT) | \
- (62 << FUNCID_OEN_SHIFT) | \
+ (62U << FUNCID_OEN_SHIFT) | \
((func_num) & FUNCID_NUM_MASK))
#define NSSMC_OPTEED_CALL(func_num) \