fix(xilinx): typecast expressions to match data type

This corrects the MISRA violation C2012-10.4:
Both operands of an operator in which the usual arithmetic conversions
are performed shall have the same essential type category.
The condition is explicitly checked against 0U, appending 'U' and
typecasting for unsigned comparison.

Change-Id: I9110ea86f5ee49af0b21be78fd0890742ef95ddf
Signed-off-by: Nithin G <nithing@amd.com>
Signed-off-by: Maheedhar Bollapalli <maheedharsai.bollapalli@amd.com>
This commit is contained in:
Maheedhar Bollapalli 2024-04-23 17:27:03 +05:30
parent 895e8029aa
commit 83bcef3f50
5 changed files with 26 additions and 26 deletions

View file

@ -110,7 +110,7 @@ uint64_t ipi_smc_handler(uint32_t smc_fid, uint64_t x1, uint64_t x2,
disable_interrupt = (x3 & IPI_SMC_ENQUIRY_DIRQ_MASK) ? 1 : 0;
ret = ipi_mb_enquire_status(ipi_local_id, ipi_remote_id);
if ((ret & IPI_MB_STATUS_RECV_PENDING) && disable_interrupt)
if ((((uint32_t)ret & IPI_MB_STATUS_RECV_PENDING) > 0U) && disable_interrupt)
ipi_mb_disable_irq(ipi_local_id, ipi_remote_id);
SMC_RET1(handle, ret);
}

View file

@ -181,10 +181,10 @@ enum xbl_handoff xbl_handover(entry_point_info_t *bl32,
}
HandoffParams = (struct xbl_handoff_params *)handoff_addr;
if ((HandoffParams->magic[0] != 'X') ||
(HandoffParams->magic[1] != 'L') ||
(HandoffParams->magic[2] != 'N') ||
(HandoffParams->magic[3] != 'X')) {
if ((HandoffParams->magic[0] != (uint8_t)'X') ||
(HandoffParams->magic[1] != (uint8_t)'L') ||
(HandoffParams->magic[2] != (uint8_t)'N') ||
(HandoffParams->magic[3] != (uint8_t)'X')) {
ERROR("BL31: invalid handoff structure at %" PRIx64 "\n", handoff_addr);
return XBL_HANDOFF_INVAL_STRUCT;
}
@ -223,7 +223,7 @@ enum xbl_handoff xbl_handover(entry_point_info_t *bl32,
#endif /* PLAT_versal_net */
target_cpu = get_xbl_cpu(&HandoffParams->partition[i]);
if (target_cpu != XBL_FLAGS_A53_0) {
if (target_cpu != (int32_t)XBL_FLAGS_A53_0) {
WARN("BL31: invalid target CPU (%i)\n", target_cpu);
continue;
}
@ -236,8 +236,8 @@ enum xbl_handoff xbl_handover(entry_point_info_t *bl32,
continue;
}
target_secure = get_xbl_ss(&HandoffParams->partition[i]);
if ((target_secure == XBL_FLAGS_SECURE) &&
target_secure = (int32_t)get_xbl_ss(&HandoffParams->partition[i]);
if ((target_secure == (int32_t)XBL_FLAGS_SECURE) &&
(target_el == XBL_FLAGS_EL2)) {
WARN("BL31: invalid security state (%i) for exception level (%i)\n",
target_secure, target_el);
@ -247,10 +247,10 @@ enum xbl_handoff xbl_handover(entry_point_info_t *bl32,
target_estate = get_xbl_estate(&HandoffParams->partition[i]);
target_endianness = get_xbl_endian(&HandoffParams->partition[i]);
if (target_secure == XBL_FLAGS_SECURE) {
if (target_secure == (int32_t)XBL_FLAGS_SECURE) {
image = bl32;
if (target_estate == XBL_FLAGS_ESTATE_A32) {
if (target_estate == (int32_t)XBL_FLAGS_ESTATE_A32) {
bl32->spsr = SPSR_MODE32(MODE32_svc, SPSR_T_ARM,
target_endianness,
DISABLE_ALL_EXCEPTIONS);
@ -261,7 +261,7 @@ enum xbl_handoff xbl_handover(entry_point_info_t *bl32,
} else {
image = bl33;
if (target_estate == XBL_FLAGS_ESTATE_A32) {
if (target_estate == (int32_t)XBL_FLAGS_ESTATE_A32) {
if (target_el == XBL_FLAGS_EL2) {
target_el = MODE32_hyp;
} else {
@ -284,7 +284,7 @@ enum xbl_handoff xbl_handover(entry_point_info_t *bl32,
}
VERBOSE("Setting up %s entry point to:%" PRIx64 ", el:%x\n",
(target_secure == XBL_FLAGS_SECURE) ? "BL32" : "BL33",
(target_secure == (int32_t)XBL_FLAGS_SECURE) ? "BL32" : "BL33",
HandoffParams->partition[i].entry_point,
target_el);
image->pc = HandoffParams->partition[i].entry_point;

View file

@ -118,7 +118,7 @@ enum pm_ret_status pm_handle_eemi_call(uint32_t flag, uint32_t x0, uint32_t x1,
module_id = (x0 & MODULE_ID_MASK) >> 8U;
//default module id is for LIBPM
if (module_id == 0) {
if (module_id == 0U) {
module_id = LIBPM_MODULE_ID;
}
@ -219,7 +219,7 @@ enum pm_ret_status pm_req_suspend(uint32_t target, uint8_t ack,
/* Send request to the PMU */
PM_PACK_PAYLOAD4(payload, LIBPM_MODULE_ID, flag, PM_REQ_SUSPEND, target,
latency, state);
if (ack == IPI_BLOCKING) {
if (ack == (uint32_t)IPI_BLOCKING) {
return pm_ipi_send_sync(primary_proc, payload, NULL, 0);
} else {
return pm_ipi_send(primary_proc, payload);
@ -274,7 +274,7 @@ enum pm_ret_status pm_get_callbackdata(uint32_t *data, size_t count, uint32_t fl
{
enum pm_ret_status ret = PM_RET_SUCCESS;
/* Return if interrupt is not from PMU */
if (pm_ipi_irq_status(primary_proc) == 0) {
if (pm_ipi_irq_status(primary_proc) == 0U) {
return ret;
}
@ -307,7 +307,7 @@ enum pm_ret_status pm_force_powerdown(uint32_t target, uint8_t ack,
PM_PACK_PAYLOAD3(payload, LIBPM_MODULE_ID, flag, PM_FORCE_POWERDOWN,
target, ack);
if (ack == IPI_BLOCKING) {
if (ack == (uint32_t)IPI_BLOCKING) {
return pm_ipi_send_sync(primary_proc, payload, NULL, 0);
} else {
return pm_ipi_send(primary_proc, payload);
@ -432,7 +432,7 @@ enum pm_ret_status pm_feature_check(uint32_t api_id, uint32_t *ret_payload,
* feature check should be done only for LIBPM module
* If module_id is 0, then we consider it LIBPM module as default id
*/
if ((module_id > 0) && (module_id != LIBPM_MODULE_ID)) {
if ((module_id > 0U) && (module_id != LIBPM_MODULE_ID)) {
return PM_RET_SUCCESS;
}

View file

@ -226,7 +226,7 @@ enum pm_ret_status pm_ipi_buff_read_callb(uint32_t *value, size_t count)
IPI_BUFFER_REQ_OFFSET;
enum pm_ret_status ret = PM_RET_SUCCESS;
if (local_count > IPI_BUFFER_MAX_WORDS) {
if (local_count > (uint32_t)IPI_BUFFER_MAX_WORDS) {
local_count = IPI_BUFFER_MAX_WORDS;
}
@ -273,7 +273,7 @@ enum pm_ret_status pm_ipi_send_sync(const struct pm_proc *proc,
goto unlock;
}
ret = ERROR_CODE_MASK & (pm_ipi_buff_read(proc, value, count));
ret = ERROR_CODE_MASK & (uint32_t)(pm_ipi_buff_read(proc, value, count));
unlock:
pm_ipi_lock_release();
@ -297,7 +297,7 @@ uint32_t pm_ipi_irq_status(const struct pm_proc *proc)
ret = ipi_mb_enquire_status(proc->ipi->local_ipi_id,
proc->ipi->remote_ipi_id);
if (ret & IPI_MB_STATUS_RECV_PENDING) {
if (((uint32_t)ret & IPI_MB_STATUS_RECV_PENDING) != 0U) {
return 1;
} else {
return 0;

View file

@ -113,7 +113,7 @@ void request_cpu_pwrdwn(void)
/* Send powerdown request to online secondary core(s) */
ret = psci_stop_other_cores(PWRDWN_WAIT_TIMEOUT, raise_pwr_down_interrupt);
if (ret != PSCI_E_SUCCESS) {
if (ret != (uint32_t)PSCI_E_SUCCESS) {
ERROR("Failed to powerdown secondary core(s)\n");
}
@ -140,11 +140,11 @@ static uint64_t ipi_fiq_handler(uint32_t id, uint32_t flags, void *handle,
(void)plat_ic_acknowledge_interrupt();
/* Check status register for each IPI except PMC */
for (i = IPI_ID_APU; i <= IPI_ID_5; i++) {
for (i = (int32_t)IPI_ID_APU; i <= IPI_ID_5; i++) {
ipi_status = ipi_mb_enquire_status(IPI_ID_APU, i);
/* If any agent other than PMC has generated IPI FIQ then send SGI to mbox driver */
if (ipi_status & IPI_MB_STATUS_RECV_PENDING) {
if ((uint32_t)ipi_status & IPI_MB_STATUS_RECV_PENDING) {
plat_ic_raise_ns_sgi(MBOX_SGI_SHARED_IPI, read_mpidr_el1());
break;
}
@ -152,7 +152,7 @@ static uint64_t ipi_fiq_handler(uint32_t id, uint32_t flags, void *handle,
/* If PMC has not generated interrupt then end ISR */
ipi_status = ipi_mb_enquire_status(IPI_ID_APU, IPI_ID_PMC);
if ((ipi_status & IPI_MB_STATUS_RECV_PENDING) == 0) {
if (((uint32_t)ipi_status & IPI_MB_STATUS_RECV_PENDING) == 0U) {
plat_ic_end_of_interrupt(id);
return 0;
}
@ -478,8 +478,8 @@ static uintptr_t eemi_handler(uint32_t api_id, uint32_t *pm_arg,
* than other eemi calls.
*/
if (api_id == (uint32_t)PM_QUERY_DATA) {
if (((pm_arg[0] == XPM_QID_CLOCK_GET_NAME) ||
(pm_arg[0] == XPM_QID_PINCTRL_GET_FUNCTION_NAME)) &&
if (((pm_arg[0] == (uint32_t)XPM_QID_CLOCK_GET_NAME) ||
(pm_arg[0] == (uint32_t)XPM_QID_PINCTRL_GET_FUNCTION_NAME)) &&
(ret == PM_RET_SUCCESS)) {
SMC_RET2(handle, (uint64_t)buf[0] | ((uint64_t)buf[1] << 32U),
(uint64_t)buf[2] | ((uint64_t)buf[3] << 32U));