From 2790da4f24b453fd09d820eaff6d2b2ad7b0bd43 Mon Sep 17 00:00:00 2001 From: Tuvshinzaya Erdenekhuu Date: Thu, 8 Jul 2021 20:33:41 +0100 Subject: [PATCH 1/4] scmi: Fix violation of required MISRAC 2012 rule 17.7 Violations of MISRAC 2012 rule 17.7 related to scmi files are fixed in this patch. For some functions, the returned value is not used and therefore it should be cast to void. Signed-off-by: Tuvshinzaya Erdenekhuu Change-Id: Ide89ea7642a7cd83817059f0d5d0c567ce1d5a62 Signed-off-by: Nicola Mazzucato --- module/scmi/src/mod_scmi.c | 35 ++++++++++--------- module/scmi_clock/src/mod_scmi_clock.c | 6 ++-- module/scmi_perf/src/mod_scmi_perf.c | 2 +- .../src/mod_scmi_power_domain.c | 2 +- module/scmi_sensor/src/mod_scmi_sensor.c | 2 +- .../src/mod_scmi_system_power.c | 4 +-- 6 files changed, 27 insertions(+), 24 deletions(-) diff --git a/module/scmi/src/mod_scmi.c b/module/scmi/src/mod_scmi.c index 735068a4b..5e3b59d48 100644 --- a/module/scmi/src/mod_scmi.c +++ b/module/scmi/src/mod_scmi.c @@ -471,7 +471,8 @@ static void scmi_notify(fwk_id_t id, int protocol_id, int message_id, (uint8_t)protocol_id, 0); - p2a_ctx->transmit(p2a_ctx->transport_id, message_header, payload, size); + (void)p2a_ctx->transmit( + p2a_ctx->transport_id, message_header, payload, size); } static const struct mod_scmi_from_protocol_api mod_scmi_from_protocol_api = { @@ -831,9 +832,10 @@ static int scmi_base_discover_vendor_handler(fwk_id_t service_id, }; if (scmi_ctx.config->vendor_identifier != NULL) { - strncpy(return_values.vendor_identifier, - scmi_ctx.config->vendor_identifier, - sizeof(return_values.vendor_identifier) - 1); + (void)strncpy( + return_values.vendor_identifier, + scmi_ctx.config->vendor_identifier, + sizeof(return_values.vendor_identifier) - 1); } respond(service_id, &return_values, sizeof(return_values)); @@ -852,9 +854,10 @@ static int scmi_base_discover_sub_vendor_handler(fwk_id_t service_id, }; if (scmi_ctx.config->sub_vendor_identifier != NULL) { - strncpy(return_values.sub_vendor_identifier, - scmi_ctx.config->sub_vendor_identifier, - sizeof(return_values.sub_vendor_identifier) - 1); + (void)strncpy( + return_values.sub_vendor_identifier, + scmi_ctx.config->sub_vendor_identifier, + sizeof(return_values.sub_vendor_identifier) - 1); } respond(service_id, &return_values, sizeof(return_values)); @@ -1103,7 +1106,7 @@ static int scmi_base_discover_agent_handler(fwk_id_t service_id, sizeof(return_values.name) >= sizeof(name), "return_values.name is not large enough to contain name"); - memcpy(return_values.name, name, sizeof(name)); + (void)memcpy(return_values.name, name, sizeof(name)); #if (SCMI_PROTOCOL_VERSION_BASE >= UINT32_C(0x20000)) return_values.agent_id = MOD_SCMI_PLATFORM_ID; @@ -1127,7 +1130,7 @@ static int scmi_base_discover_agent_handler(fwk_id_t service_id, return_values.agent_id = (uint32_t)agent_id; - strncpy( + (void)strncpy( &return_values.name[0], fwk_module_get_element_name(service_id), sizeof(return_values.name) - 1); @@ -1146,10 +1149,10 @@ static int scmi_base_discover_agent_handler(fwk_id_t service_id, agent = &scmi_ctx.config->agent_table[parameters->agent_id]; - strncpy(return_values.name, - (agent->name != NULL) ? agent->name : - default_agent_names[agent->type], - sizeof(return_values.name) - 1); + (void)strncpy( + return_values.name, + (agent->name != NULL) ? agent->name : default_agent_names[agent->type], + sizeof(return_values.name) - 1); exit: respond(service_id, &return_values, @@ -1709,8 +1712,8 @@ static int scmi_process_event(const struct fwk_event *event, ctx->scmi_protocol_id, ctx->scmi_message_id); #endif - ctx->respond(transport_id, &(int32_t) { SCMI_NOT_SUPPORTED }, - sizeof(int32_t)); + (void)ctx->respond( + transport_id, &(int32_t){ SCMI_NOT_SUPPORTED }, sizeof(int32_t)); return FWK_SUCCESS; } @@ -1752,7 +1755,7 @@ static int scmi_process_event(const struct fwk_event *event, ctx->scmi_protocol_id, ctx->scmi_message_id); # endif - ctx->respond( + (void)ctx->respond( transport_id, &(int32_t){ SCMI_DENIED }, sizeof(int32_t)); return FWK_SUCCESS; } diff --git a/module/scmi_clock/src/mod_scmi_clock.c b/module/scmi_clock/src/mod_scmi_clock.c index 341eca43c..6811bd033 100644 --- a/module/scmi_clock/src/mod_scmi_clock.c +++ b/module/scmi_clock/src/mod_scmi_clock.c @@ -322,7 +322,7 @@ static void clock_ops_update_state(unsigned int clock_dev_idx, int status) if ((status == FWK_SUCCESS) && (scmi_clock_ctx.clock_ops[clock_dev_idx].request == SCMI_CLOCK_REQUEST_SET_STATE)) { - mod_scmi_clock_config_set_policy( + (void)mod_scmi_clock_config_set_policy( &policy_status, &scmi_clock_ctx.clock_ops[clock_dev_idx].state, MOD_SCMI_CLOCK_POST_MESSAGE_HANDLER, @@ -362,7 +362,7 @@ static void get_state_respond(fwk_id_t clock_dev_id, return_values.attributes = SCMI_CLOCK_ATTRIBUTES( (uint32_t)(*clock_state == MOD_CLOCK_STATE_RUNNING)); - strncpy( + (void)strncpy( return_values.clock_name, fwk_module_get_element_name(clock_dev_id), sizeof(return_values.clock_name) - 1); @@ -561,7 +561,7 @@ FWK_WEAK int mod_scmi_clock_config_set_policy( /* error to try and stop a stopped clock */ if (clock_count[clock_dev_id] == 0) { - scmi_clock_ctx.scmi_api->get_agent_id(service_id, &agent_id); + (void)scmi_clock_ctx.scmi_api->get_agent_id(service_id, &agent_id); FWK_LOG_WARN( "[SCMI-CLK] Invalid STOP request agent:" " %d clock_id: %d state:%d\n", diff --git a/module/scmi_perf/src/mod_scmi_perf.c b/module/scmi_perf/src/mod_scmi_perf.c index 3d96e8759..47103eb66 100644 --- a/module/scmi_perf/src/mod_scmi_perf.c +++ b/module/scmi_perf/src/mod_scmi_perf.c @@ -677,7 +677,7 @@ static int scmi_perf_domain_attributes_handler(fwk_id_t service_id, }; /* Copy the domain name into the mailbox */ - strncpy( + (void)strncpy( (char *)return_values.name, fwk_module_get_element_name(domain_id), sizeof(return_values.name) - 1); diff --git a/module/scmi_power_domain/src/mod_scmi_power_domain.c b/module/scmi_power_domain/src/mod_scmi_power_domain.c index c8803ed2e..6ffdb700c 100644 --- a/module/scmi_power_domain/src/mod_scmi_power_domain.c +++ b/module/scmi_power_domain/src/mod_scmi_power_domain.c @@ -398,7 +398,7 @@ static int scmi_pd_power_domain_attributes_handler(fwk_id_t service_id, goto exit; } - strncpy( + (void)strncpy( (char *)return_values.name, fwk_module_get_element_name(pd_id), sizeof(return_values.name) - 1); diff --git a/module/scmi_sensor/src/mod_scmi_sensor.c b/module/scmi_sensor/src/mod_scmi_sensor.c index be76dd4bc..7722cfb27 100644 --- a/module/scmi_sensor/src/mod_scmi_sensor.c +++ b/module/scmi_sensor/src/mod_scmi_sensor.c @@ -332,7 +332,7 @@ static int scmi_sensor_protocol_desc_get_handler(fwk_id_t service_id, * Copy sensor name into description struct. Copy n-1 chars to ensure a * NULL terminator at the end. (struct has been zeroed out) */ - strncpy( + (void)strncpy( desc.sensor_name, fwk_module_get_element_name(sensor_id), sizeof(desc.sensor_name) - 1); diff --git a/module/scmi_system_power/src/mod_scmi_system_power.c b/module/scmi_system_power/src/mod_scmi_system_power.c index cb6e4b29e..58e1e784c 100644 --- a/module/scmi_system_power/src/mod_scmi_system_power.c +++ b/module/scmi_system_power/src/mod_scmi_system_power.c @@ -182,7 +182,7 @@ static void graceful_timer_callback(uintptr_t scmi_system_state) if (scmi_system_state == SCMI_SYSTEM_STATE_SHUTDOWN) { system_shutdown = system_state2system_shutdown[scmi_system_state]; - scmi_sys_power_ctx.pd_api->system_shutdown(system_shutdown); + (void)scmi_sys_power_ctx.pd_api->system_shutdown(system_shutdown); } } @@ -546,7 +546,7 @@ FWK_WEAK int scmi_sys_power_state_set_policy( #endif if (scmi_sys_power_ctx.alarm_api != NULL) { - scmi_sys_power_ctx.alarm_api->start( + (void)scmi_sys_power_ctx.alarm_api->start( scmi_sys_power_ctx.config->alarm_id, scmi_sys_power_ctx.config->graceful_timeout, MOD_TIMER_ALARM_TYPE_ONCE, -- GitLab From 659331b46751f82943d8965ff638608f7ce46111 Mon Sep 17 00:00:00 2001 From: Tuvshinzaya Erdenekhuu Date: Mon, 12 Jul 2021 10:17:02 +0100 Subject: [PATCH 2/4] product/juno: Fix violation of required MISRAC 2012 rule 17.7 Violations of MISRAC 2012 rule 17.7 related to juno file is fixed in this patch. For some functions, the returned value is not used and therefore it should be cast to void. Signed-off-by: Tuvshinzaya Erdenekhuu Change-Id: Ife29de2cd187471e831094ae4ba699ab2d09bf3f Signed-off-by: Nicola Mazzucato --- .../module/juno_cdcel937/src/mod_juno_cdcel937.c | 2 +- .../juno/module/juno_dmc400/src/mod_juno_dmc400.c | 14 +++++++------- product/juno/module/juno_rom/src/juno_debug_rom.c | 12 ++++++------ product/juno/module/juno_rom/src/mod_juno_rom.c | 3 ++- .../juno/module/juno_system/src/mod_juno_system.c | 2 +- .../module/juno_xrp7724/src/mod_juno_xrp7724.c | 4 ++-- product/juno/scp_ramfw/config_sensor.c | 9 +++++---- 7 files changed, 24 insertions(+), 22 deletions(-) diff --git a/product/juno/module/juno_cdcel937/src/mod_juno_cdcel937.c b/product/juno/module/juno_cdcel937/src/mod_juno_cdcel937.c index 2c905ca23..19c293c3a 100644 --- a/product/juno/module/juno_cdcel937/src/mod_juno_cdcel937.c +++ b/product/juno/module/juno_cdcel937/src/mod_juno_cdcel937.c @@ -149,7 +149,7 @@ static int write_configuration(struct juno_cdcel937_dev_ctx *ctx, * field at the beginning. This was used earlier because the chip sends * the transaction length (in bytes) at the beginning of each read. */ - memcpy(&i2c_transmit[2], &(config->reg[1]), 8); + (void)memcpy(&i2c_transmit[2], &(config->reg[1]), 8); status = module_ctx.i2c_api->transmit_as_master(module_config->i2c_hal_id, ctx->config->slave_address, i2c_transmit, 10); diff --git a/product/juno/module/juno_dmc400/src/mod_juno_dmc400.c b/product/juno/module/juno_dmc400/src/mod_juno_dmc400.c index 834a2ce18..4921cd409 100644 --- a/product/juno/module/juno_dmc400/src/mod_juno_dmc400.c +++ b/product/juno/module/juno_dmc400/src/mod_juno_dmc400.c @@ -662,7 +662,7 @@ static int ddr_retraining(fwk_id_t id) element_config = fwk_module_get_data(id); dmc = (struct mod_juno_dmc400_reg *)element_config->dmc; - fwk_interrupt_global_disable(); + (void)fwk_interrupt_global_disable(); dmc->MEMC_CMD = DMC400_CMD_CONFIG; status = ctx.timer_api->wait(module_config->timer_id, @@ -680,9 +680,9 @@ static int ddr_retraining(fwk_id_t id) dmc->MEMC_CMD = DMC400_CMD_GO; - fwk_interrupt_global_enable(); + (void)fwk_interrupt_global_enable(); - fwk_interrupt_enable((unsigned int)PHY_TRAINING_IRQ); + (void)fwk_interrupt_enable((unsigned int)PHY_TRAINING_IRQ); FWK_LOG_INFO("[DMC] Re-training done"); @@ -876,7 +876,7 @@ static void ddr_phy_irq_handler(void) */ fwk_assert(revision == JUNO_IDX_REVISION_R0); - fwk_interrupt_disable((unsigned int)PHY_TRAINING_IRQ); + (void)fwk_interrupt_disable((unsigned int)PHY_TRAINING_IRQ); req_event = (struct fwk_event) { .source_id = id, @@ -992,14 +992,14 @@ static int juno_dmc400_start(fwk_id_t id) return status; } - fwk_interrupt_global_disable(); + (void)fwk_interrupt_global_disable(); status = ddr_training(id); if (status != FWK_SUCCESS) { return status; } - fwk_interrupt_global_enable(); + (void)fwk_interrupt_global_enable(); status = fwk_interrupt_set_isr( (unsigned int)PHY_TRAINING_IRQ, ddr_phy_irq_handler); @@ -1012,7 +1012,7 @@ static int juno_dmc400_start(fwk_id_t id) return FWK_E_STATE; } - fwk_interrupt_enable((unsigned int)PHY_TRAINING_IRQ); + (void)fwk_interrupt_enable((unsigned int)PHY_TRAINING_IRQ); /* Configure Integration Tests */ dmc->INTEG_CFG = 0x00000000; diff --git a/product/juno/module/juno_rom/src/juno_debug_rom.c b/product/juno/module/juno_rom/src/juno_debug_rom.c index 5756b86dd..0060bc678 100644 --- a/product/juno/module/juno_rom/src/juno_debug_rom.c +++ b/product/juno/module/juno_rom/src/juno_debug_rom.c @@ -213,9 +213,9 @@ int juno_debug_rom_init(const struct mod_juno_ppu_rom_api *rom_ppu_api) SCP_CONFIG_DEBUG_CONTROL_CDBGPWRUPACK) != 0); } - fwk_interrupt_clear_pending((unsigned int)CDBG_PWR_UP_REQ_IRQ); - fwk_interrupt_clear_pending((unsigned int)CDBG_RST_REQ_IRQ); - fwk_interrupt_clear_pending((unsigned int)CSYS_PWR_UP_REQ_IRQ); + (void)fwk_interrupt_clear_pending((unsigned int)CDBG_PWR_UP_REQ_IRQ); + (void)fwk_interrupt_clear_pending((unsigned int)CDBG_RST_REQ_IRQ); + (void)fwk_interrupt_clear_pending((unsigned int)CSYS_PWR_UP_REQ_IRQ); status = fwk_interrupt_set_isr( (unsigned int)CDBG_PWR_UP_REQ_IRQ, juno_debug_cdbg_pwr_up_req_isr); @@ -235,9 +235,9 @@ int juno_debug_rom_init(const struct mod_juno_ppu_rom_api *rom_ppu_api) return status; } - fwk_interrupt_enable((unsigned int)CDBG_PWR_UP_REQ_IRQ); - fwk_interrupt_enable((unsigned int)CDBG_RST_REQ_IRQ); - fwk_interrupt_enable((unsigned int)CSYS_PWR_UP_REQ_IRQ); + (void)fwk_interrupt_enable((unsigned int)CDBG_PWR_UP_REQ_IRQ); + (void)fwk_interrupt_enable((unsigned int)CDBG_RST_REQ_IRQ); + (void)fwk_interrupt_enable((unsigned int)CSYS_PWR_UP_REQ_IRQ); return FWK_SUCCESS; } diff --git a/product/juno/module/juno_rom/src/mod_juno_rom.c b/product/juno/module/juno_rom/src/mod_juno_rom.c index e75a7c691..4ffc42610 100644 --- a/product/juno/module/juno_rom/src/mod_juno_rom.c +++ b/product/juno/module/juno_rom/src/mod_juno_rom.c @@ -368,7 +368,8 @@ static int juno_rom_process_event( SCP_CONFIG_LITTLE_STATIC_CONFIG_BARRIERDISABLE; /* Zero the AP context area */ - memset((void *)ctx.config->ap_context_base, 0, ctx.config->ap_context_size); + (void)memset( + (void *)ctx.config->ap_context_base, 0, ctx.config->ap_context_size); /* Send SYSTOP ON notification */ systop_on_event = diff --git a/product/juno/module/juno_system/src/mod_juno_system.c b/product/juno/module/juno_system/src/mod_juno_system.c index 322984d1b..7c8f06a03 100644 --- a/product/juno/module/juno_system/src/mod_juno_system.c +++ b/product/juno/module/juno_system/src/mod_juno_system.c @@ -321,7 +321,7 @@ static int juno_system_process_notification(const struct fwk_event *event, if ((scmi_notification_count == FWK_ARRAY_SIZE(scmi_notification_table)) && sds_notification_received) { - messaging_stack_ready(); + (void)messaging_stack_ready(); scmi_notification_count = 0; sds_notification_received = false; diff --git a/product/juno/module/juno_xrp7724/src/mod_juno_xrp7724.c b/product/juno/module/juno_xrp7724/src/mod_juno_xrp7724.c index 32987598f..d13c3f14e 100644 --- a/product/juno/module/juno_xrp7724/src/mod_juno_xrp7724.c +++ b/product/juno/module/juno_xrp7724/src/mod_juno_xrp7724.c @@ -677,7 +677,7 @@ static int juno_xrp7724_gpio_process_request(fwk_id_t id, int response_status) * The shutdown assert command is delayed to ensure that the mode change * has been applied by the hardware device. */ - module_ctx.timer_api->delay(config->timer_hal_id, GPIO_DELAY_US); + (void)module_ctx.timer_api->delay(config->timer_hal_id, GPIO_DELAY_US); /* Send the assert command */ status = set_gpio(config->gpio_assert_id, ctx); @@ -711,7 +711,7 @@ static int juno_xrp7724_gpio_process_request(fwk_id_t id, int response_status) * Allow some time to the hardware to apply the reset or shutdown * command */ - module_ctx.timer_api->delay(config->timer_hal_id, GPIO_DELAY_US); + (void)module_ctx.timer_api->delay(config->timer_hal_id, GPIO_DELAY_US); /* The board should have been reset or shut down at this point */ diff --git a/product/juno/scp_ramfw/config_sensor.c b/product/juno/scp_ramfw/config_sensor.c index 534058666..5009df9b3 100644 --- a/product/juno/scp_ramfw/config_sensor.c +++ b/product/juno/scp_ramfw/config_sensor.c @@ -374,10 +374,11 @@ static const struct fwk_element *get_sensor_element_table(fwk_id_t module_id) return NULL; } - memcpy(element_table, - sensor_element_table_r0, - sizeof(sensor_element_table_r0)); - #endif + (void)memcpy( + element_table, + sensor_element_table_r0, + sizeof(sensor_element_table_r0)); +#endif return element_table; } -- GitLab From 3cf49ef77aa14afef9dec7d5e6abd77f74a8ed48 Mon Sep 17 00:00:00 2001 From: Tuvshinzaya Erdenekhuu Date: Mon, 12 Jul 2021 10:52:26 +0100 Subject: [PATCH 3/4] module: Fix violation of required MISRAC 2012 rule 17.7 Violations of MISRAC 2012 rule 17.7 related to module file is fixed in this patch. For some functions, the returned value is not used and therefore it should be cast to void. Signed-off-by: Tuvshinzaya Erdenekhuu Change-Id: Ifbeaa20a92e3b8915e93dea7d5a7f55ff01093b7 Signed-off-by: Nicola Mazzucato --- module/bootloader/src/mod_bootloader.c | 3 +- module/clock/src/mod_clock.c | 2 +- module/dvfs/src/mod_dvfs.c | 10 +++---- module/dw_apb_i2c/src/mod_dw_apb_i2c.c | 8 +++--- module/gtimer/src/mod_gtimer.c | 2 +- module/mhu/src/mod_mhu.c | 2 +- module/mock_clock/src/mod_mock_clock.c | 2 +- module/power_domain/src/mod_power_domain.c | 28 ++++++++++--------- module/power_domain/src/power_domain_utils.c | 7 +++-- module/psu/src/mod_psu.c | 2 +- module/smt/src/mod_smt.c | 22 ++++++++------- module/system_power/src/mod_system_power.c | 15 +++++----- module/timer/src/mod_timer.c | 29 ++++++++++---------- 13 files changed, 68 insertions(+), 64 deletions(-) diff --git a/module/bootloader/src/mod_bootloader.c b/module/bootloader/src/mod_bootloader.c index e7ffa5170..ae2cb97de 100644 --- a/module/bootloader/src/mod_bootloader.c +++ b/module/bootloader/src/mod_bootloader.c @@ -171,7 +171,8 @@ static int load_image(void) } } - fwk_interrupt_global_disable(); /* We are relocating the vector table */ + (void) + fwk_interrupt_global_disable(); /* We are relocating the vector table */ FWK_LOG_INFO("[BOOTLOADER] Booting RAM firmware..."); FWK_LOG_FLUSH(); diff --git a/module/clock/src/mod_clock.c b/module/clock/src/mod_clock.c index 1ee531719..a36c05923 100644 --- a/module/clock/src/mod_clock.c +++ b/module/clock/src/mod_clock.c @@ -656,7 +656,7 @@ static int clock_process_notification_response( *)pd_response_event.params; pd_resp_params->status = (int)ctx->pd_notif.transition_pending_response_status; - fwk_thread_put_event(&pd_response_event); + (void)fwk_thread_put_event(&pd_response_event); } return FWK_SUCCESS; diff --git a/module/dvfs/src/mod_dvfs.c b/module/dvfs/src/mod_dvfs.c index 124a3db47..d9864645e 100644 --- a/module/dvfs/src/mod_dvfs.c +++ b/module/dvfs/src/mod_dvfs.c @@ -279,7 +279,7 @@ static void dvfs_flush_pending_request(struct mod_dvfs_domain_ctx *ctx) { if (ctx->request_pending) { ctx->request_pending = false; - dvfs_set_level_start( + (void)dvfs_set_level_start( ctx, ctx->pending_request.cookie, &ctx->pending_request.new_opp, @@ -301,7 +301,7 @@ static void alarm_callback(uintptr_t param) .response_requested = ctx->pending_request.response_required, }; - fwk_thread_put_event(&req); + (void)fwk_thread_put_event(&req); } static int dvfs_handle_pending_request(struct mod_dvfs_domain_ctx *ctx) @@ -606,7 +606,7 @@ static void dvfs_complete_respond( if (return_opp) { resp_params->performance_level = ctx->current_opp.level; } - fwk_thread_put_event(&read_req_event); + (void)fwk_thread_put_event(&read_req_event); } ctx->cookie = 0; } else if (resp_event != NULL) { @@ -663,7 +663,7 @@ static int dvfs_complete( * here to prevent another request being processed ahead of this one. */ if (ctx->request_pending) { - dvfs_handle_pending_request(ctx); + (void)dvfs_handle_pending_request(ctx); } else { /* * The request has completed and there are no pending requests. @@ -1046,7 +1046,7 @@ static int dvfs_start(fwk_id_t id) if (status == FWK_SUCCESS) { ctx = get_domain_ctx(id); ctx->request.set_source_id = true; - dvfs_set_level_start(ctx, 0, &sustained_opp, true, 0); + (void)dvfs_set_level_start(ctx, 0, &sustained_opp, true, 0); } return status; diff --git a/module/dw_apb_i2c/src/mod_dw_apb_i2c.c b/module/dw_apb_i2c/src/mod_dw_apb_i2c.c index 1335c0a9d..256a037d9 100644 --- a/module/dw_apb_i2c/src/mod_dw_apb_i2c.c +++ b/module/dw_apb_i2c/src/mod_dw_apb_i2c.c @@ -163,14 +163,14 @@ static int transmit_as_master(fwk_id_t dev_id, } /* The program of the I2C controller cannot be interrupted. */ - fwk_interrupt_global_disable(); + (void)fwk_interrupt_global_disable(); for (sent_bytes = 0; sent_bytes < transmit_request->transmit_byte_count; sent_bytes++) { ctx->i2c_reg->IC_DATA_CMD = transmit_request->transmit_data[sent_bytes]; } - fwk_interrupt_global_enable(); + (void)fwk_interrupt_global_enable(); /* * The data has been pushed to the I2C FIFO for transmission to the @@ -208,14 +208,14 @@ static int receive_as_master(fwk_id_t dev_id, } /* The program of the I2C controller cannot be interrupted. */ - fwk_interrupt_global_disable(); + (void)fwk_interrupt_global_disable(); /* Program the I2C controller with the expected reply length in bytes. */ for (i = 0; i < receive_request->receive_byte_count; i++) { ctx->i2c_reg->IC_DATA_CMD = IC_DATA_CMD_READ; } - fwk_interrupt_global_enable(); + (void)fwk_interrupt_global_enable(); /* * The command has been sent to the I2C for requesting data from diff --git a/module/gtimer/src/mod_gtimer.c b/module/gtimer/src/mod_gtimer.c index 9fbb2c771..a0a63886b 100644 --- a/module/gtimer/src/mod_gtimer.c +++ b/module/gtimer/src/mod_gtimer.c @@ -206,7 +206,7 @@ static int gtimer_device_init(fwk_id_t element_id, unsigned int unused, ctx->hw_counter = (struct cntctl_reg *)ctx->config->hw_counter; ctx->control = (struct cntcontrol_reg *)ctx->config->control; - disable(element_id); + (void)disable(element_id); ctx->hw_counter->ACR = CNTCTL_ACR_RPCT | CNTCTL_ACR_RVCT | diff --git a/module/mhu/src/mod_mhu.c b/module/mhu/src/mod_mhu.c index bdb96b2ef..eae82e60c 100644 --- a/module/mhu/src/mod_mhu.c +++ b/module/mhu/src/mod_mhu.c @@ -100,7 +100,7 @@ static void mhu_isr(void) */ if ((device_ctx->bound_slots & (uint32_t)(1U << slot)) != (uint32_t)0) { smt_channel = &device_ctx->smt_channel_table[slot]; - smt_channel->api->signal_message(smt_channel->id); + (void)smt_channel->api->signal_message(smt_channel->id); } /* Acknowledge the interrupt */ diff --git a/module/mock_clock/src/mod_mock_clock.c b/module/mock_clock/src/mod_mock_clock.c index 3cd6f4fed..45e424574 100644 --- a/module/mock_clock/src/mod_mock_clock.c +++ b/module/mock_clock/src/mod_mock_clock.c @@ -209,7 +209,7 @@ static int mod_mock_clock_update_input_rate( ctx->current_rate_index = (unsigned int)(rate_entry - ctx->config->rate_table); - mod_mock_clock_get_rate(clock_id, output_rate); + (void)mod_mock_clock_get_rate(clock_id, output_rate); return FWK_SUCCESS; } diff --git a/module/power_domain/src/mod_power_domain.c b/module/power_domain/src/mod_power_domain.c index 0c85f2479..697d2c582 100644 --- a/module/power_domain/src/mod_power_domain.c +++ b/module/power_domain/src/mod_power_domain.c @@ -670,7 +670,8 @@ static bool initiate_power_state_pre_transition_notification(struct pd_ctx *pd) params->target_state = state; notification_event.source_id = pd->id; - fwk_notification_notify(¬ification_event, + (void)fwk_notification_notify( + ¬ification_event, &pd->power_state_pre_transition_notification_ctx.pending_responses); pd->power_state_pre_transition_notification_ctx.state = state; @@ -766,7 +767,7 @@ static void respond(struct pd_ctx *pd, int resp_status) resp_params->composite_state = req_params->composite_state; resp_params->status = resp_status; - fwk_thread_put_event(&resp_event); + (void)fwk_thread_put_event(&resp_event); } /* @@ -1118,7 +1119,7 @@ static void process_power_state_transition_report_deeper_state( } if (!initiate_power_state_pre_transition_notification(parent)) { - initiate_power_state_transition(parent); + (void)initiate_power_state_transition(parent); } } @@ -1148,7 +1149,7 @@ static void process_power_state_transition_report_shallower_state( } if (!initiate_power_state_pre_transition_notification(child)) { - initiate_power_state_transition(child); + (void)initiate_power_state_transition(child); } } } @@ -1184,14 +1185,15 @@ static void process_power_state_transition_report(struct pd_ctx *pd, notification_event.params; params->state = new_state; pd->power_state_transition_notification_ctx.state = new_state; - fwk_notification_notify(¬ification_event, + (void)fwk_notification_notify( + ¬ification_event, &pd->power_state_transition_notification_ctx.pending_responses); } if ((mod_pd_ctx.system_suspend.last_core_off_ongoing) && (pd == mod_pd_ctx.system_suspend.last_core_pd)) { mod_pd_ctx.system_suspend.last_core_off_ongoing = false; - complete_system_suspend(pd); + (void)complete_system_suspend(pd); return; } @@ -1388,9 +1390,8 @@ static bool check_and_notify_system_shutdown( params = (struct mod_pd_pre_shutdown_notif_params *)notification.params; params->system_shutdown = system_shutdown; - fwk_notification_notify( - ¬ification, - &mod_pd_ctx.system_shutdown.notifications_count); + (void)fwk_notification_notify( + ¬ification, &mod_pd_ctx.system_shutdown.notifications_count); return (mod_pd_ctx.system_shutdown.notifications_count != 0); } @@ -1918,7 +1919,7 @@ static int pd_start(fwk_id_t id) continue; } - report_power_state_transition(pd, state); + (void)report_power_state_transition(pd, state); } } @@ -2086,7 +2087,7 @@ static int process_power_state_pre_transition_notification_response( */ if (pd->power_state_pre_transition_notification_ctx.response_status == FWK_SUCCESS) { - initiate_power_state_transition(pd); + (void)initiate_power_state_transition(pd); } } else { /* @@ -2100,7 +2101,7 @@ static int process_power_state_pre_transition_notification_response( } if (!initiate_power_state_pre_transition_notification(pd)) { - initiate_power_state_transition(pd); + (void)initiate_power_state_transition(pd); } } @@ -2156,7 +2157,8 @@ static int process_power_state_transition_notification_response( params->state = pd->current_state; pd->power_state_transition_notification_ctx.state = pd->current_state; - fwk_notification_notify(¬ification_event, + (void)fwk_notification_notify( + ¬ification_event, &pd->power_state_transition_notification_ctx.pending_responses); return FWK_SUCCESS; diff --git a/module/power_domain/src/power_domain_utils.c b/module/power_domain/src/power_domain_utils.c index 4adbcbf3a..87a4df3b4 100644 --- a/module/power_domain/src/power_domain_utils.c +++ b/module/power_domain/src/power_domain_utils.c @@ -55,7 +55,7 @@ static int create_core_cluster_pd_element_table( element = &element_table[core_element_counter]; pd_config = &pd_config_table[core_element_counter]; element->name = fwk_mm_alloc(PD_NAME_SIZE, 1); - snprintf( + (void)snprintf( (char *)element->name, PD_NAME_SIZE, "CLUS%uCORE%u", @@ -75,7 +75,8 @@ static int create_core_cluster_pd_element_table( element = &element_table[cluster_idx + core_count]; pd_config = &pd_config_table[cluster_idx + core_count]; element->name = fwk_mm_alloc(PD_NAME_SIZE, 1); - snprintf((char *)element->name, PD_NAME_SIZE, "CLUS%u", cluster_idx); + (void)snprintf( + (char *)element->name, PD_NAME_SIZE, "CLUS%u", cluster_idx); element->data = pd_config; pd_config->attributes.pd_type = MOD_PD_TYPE_CLUSTER; pd_config->driver_id = @@ -133,7 +134,7 @@ const struct fwk_element *create_power_domain_element_table( return NULL; } - memcpy( + (void)memcpy( element_table + (core_count + cluster_count), static_table, static_table_size * sizeof(struct fwk_element)); diff --git a/module/psu/src/mod_psu.c b/module/psu/src/mod_psu.c index 5fc101bbc..d13fe5edd 100644 --- a/module/psu/src/mod_psu.c +++ b/module/psu/src/mod_psu.c @@ -275,7 +275,7 @@ static void mod_psu_respond( .target_id = element_id, }; - memcpy(event.params, &response, sizeof(response)); + (void)memcpy(event.params, &response, sizeof(response)); status = fwk_thread_put_event(&event); if (!fwk_expect(status == FWK_SUCCESS)) { diff --git a/module/smt/src/mod_smt.c b/module/smt/src/mod_smt.c index 7109975b5..111de0a51 100644 --- a/module/smt/src/mod_smt.c +++ b/module/smt/src/mod_smt.c @@ -183,7 +183,8 @@ static int smt_write_payload(fwk_id_t channel_id, return FWK_E_ACCESS; } - memcpy(((uint8_t*)channel_ctx->out->payload) + offset, payload, size); + (void)memcpy( + ((uint8_t *)channel_ctx->out->payload) + offset, payload, size); return FWK_SUCCESS; } @@ -201,9 +202,10 @@ static int smt_respond(fwk_id_t channel_id, const void *payload, size_t size) *memory = *channel_ctx->out; /* Copy the payload from either the write buffer or the payload parameter */ - memcpy(memory->payload, - (payload == NULL ? channel_ctx->out->payload : payload), - size); + (void)memcpy( + memory->payload, + (payload == NULL ? channel_ctx->out->payload : payload), + size); /* * NOTE: Disable interrupts for a brief period to ensure interrupts are not @@ -212,17 +214,17 @@ static int smt_respond(fwk_id_t channel_id, const void *payload, size_t size) * period anyway, but this guard is included to protect against a * misbehaving agent. */ - fwk_interrupt_global_disable(); + (void)fwk_interrupt_global_disable(); channel_ctx->locked = false; memory->length = (volatile uint32_t)(sizeof(memory->message_header) + size); memory->status |= MOD_SMT_MAILBOX_STATUS_FREE_MASK; - fwk_interrupt_global_enable(); + (void)fwk_interrupt_global_enable(); if (memory->flags & MOD_SMT_MAILBOX_FLAGS_IENABLED_MASK) { - channel_ctx->driver_api->raise_interrupt(channel_ctx->driver_id); + (void)channel_ctx->driver_api->raise_interrupt(channel_ctx->driver_id); } return FWK_SUCCESS; @@ -263,13 +265,13 @@ static int smt_transmit(fwk_id_t channel_id, uint32_t message_header, memory->flags = 0; /* Copy the payload */ - memcpy(memory->payload, payload, size); + (void)memcpy(memory->payload, payload, size); memory->length = (volatile uint32_t)(sizeof(memory->message_header) + size); memory->status &= ~MOD_SMT_MAILBOX_STATUS_FREE_MASK; /* Notify the agent */ - channel_ctx->driver_api->raise_interrupt(channel_ctx->driver_id); + (void)channel_ctx->driver_api->raise_interrupt(channel_ctx->driver_id); return FWK_SUCCESS; } @@ -360,7 +362,7 @@ static int smt_slave_handler(struct smt_channel_ctx *channel_ctx) /* Copy payload from shared memory to read buffer */ payload_size = in->length - sizeof(in->message_header); - memcpy(in->payload, memory->payload, payload_size); + (void)memcpy(in->payload, memory->payload, payload_size); /* Let subscribed service handle the message */ if (channel_ctx->is_scmi_channel) { diff --git a/module/system_power/src/mod_system_power.c b/module/system_power/src/mod_system_power.c index ddf6ba195..720efa8ad 100644 --- a/module/system_power/src/mod_system_power.c +++ b/module/system_power/src/mod_system_power.c @@ -91,9 +91,8 @@ static void ext_ppus_set_state(enum mod_pd_state state) unsigned int i; for (i = 0; i < system_power_ctx.config->ext_ppus_count; i++) { - system_power_ctx.ext_ppu_apis[i]->set_state( - system_power_ctx.config->ext_ppus[i].ppu_id, - state); + (void)system_power_ctx.ext_ppu_apis[i]->set_state( + system_power_ctx.config->ext_ppus[i].ppu_id, state); } } @@ -109,9 +108,9 @@ static void ext_ppus_shutdown(enum mod_pd_system_shutdown system_shutdown) ppu_id = system_power_ctx.config->ext_ppus[i].ppu_id; if (api->shutdown != NULL) { - api->shutdown(ppu_id, system_shutdown); + (void)api->shutdown(ppu_id, system_shutdown); } else { - api->set_state(ppu_id, MOD_PD_STATE_OFF); + (void)api->set_state(ppu_id, MOD_PD_STATE_OFF); } } } @@ -173,7 +172,7 @@ static int disable_all_irqs(void) { int status = FWK_SUCCESS; - fwk_interrupt_disable(system_power_ctx.config->soc_wakeup_irq); + (void)fwk_interrupt_disable(system_power_ctx.config->soc_wakeup_irq); if (system_power_ctx.driver_api->platform_interrupts != NULL) { status = system_power_ctx.driver_api->platform_interrupts( @@ -247,7 +246,7 @@ static int system_power_set_state(fwk_id_t pd_id, unsigned int state) case (unsigned int)MOD_SYSTEM_POWER_POWER_STATE_SLEEP0: ext_ppus_set_state(MOD_PD_STATE_OFF); - fwk_interrupt_clear_pending(soc_wakeup_irq); + (void)fwk_interrupt_clear_pending(soc_wakeup_irq); if (system_power_ctx.driver_api->platform_interrupts != NULL) { status = @@ -270,7 +269,7 @@ static int system_power_set_state(fwk_id_t pd_id, unsigned int state) return status; } - fwk_interrupt_enable(soc_wakeup_irq); + (void)fwk_interrupt_enable(soc_wakeup_irq); if (system_power_ctx.driver_api->platform_interrupts != NULL) { status = system_power_ctx.driver_api->platform_interrupts( diff --git a/module/timer/src/mod_timer.c b/module/timer/src/mod_timer.c index 0368aee24..00a4f166e 100644 --- a/module/timer/src/mod_timer.c +++ b/module/timer/src/mod_timer.c @@ -154,8 +154,8 @@ static void _configure_timer_with_next_alarm(struct dev_ctx *ctx) alarm_head = (struct alarm_ctx *)fwk_list_head(&ctx->alarms_active); if (alarm_head != NULL) { /* Configure timer device */ - ctx->driver->set_timer(ctx->driver_dev_id, alarm_head->timestamp); - ctx->driver->enable(ctx->driver_dev_id); + (void)ctx->driver->set_timer(ctx->driver_dev_id, alarm_head->timestamp); + (void)ctx->driver->enable(ctx->driver_dev_id); } } @@ -335,7 +335,7 @@ static int get_next_alarm_remaining(fwk_id_t dev_id, * The timer interrupt is disabled to ensure that the alarm list is not * modified while we are trying to read it below. */ - ctx->driver->disable(ctx->driver_dev_id); + (void)ctx->driver->disable(ctx->driver_dev_id); *has_alarm = !fwk_list_is_empty(&ctx->alarms_active); @@ -346,7 +346,7 @@ static int get_next_alarm_remaining(fwk_id_t dev_id, status = _remaining(ctx, alarm_ctx->timestamp, remaining_ticks); } - ctx->driver->enable(ctx->driver_dev_id); + (void)ctx->driver->enable(ctx->driver_dev_id); return status; } @@ -401,10 +401,10 @@ static int alarm_stop(fwk_id_t alarm_id) alarm = &ctx->alarm_pool[fwk_id_get_sub_element_idx(alarm_id)]; /* Prevent possible data races with the timer interrupt */ - ctx->driver->disable(ctx->driver_dev_id); + (void)ctx->driver->disable(ctx->driver_dev_id); if (!alarm->started) { - ctx->driver->enable(ctx->driver_dev_id); + (void)ctx->driver->enable(ctx->driver_dev_id); return FWK_E_STATE; } @@ -423,7 +423,7 @@ static int alarm_stop(fwk_id_t alarm_id) * cleared here. If the interrupt was triggered by another alarm, it will be * re-triggered when the timer interrupt is re-enabled. */ - fwk_interrupt_clear_pending(ctx->config->timer_irq); + (void)fwk_interrupt_clear_pending(ctx->config->timer_irq); fwk_list_remove(&ctx->alarms_active, (struct fwk_dlist_node *)alarm); alarm->activated = false; @@ -459,7 +459,7 @@ static int alarm_start(fwk_id_t alarm_id, alarm = &ctx->alarm_pool[fwk_id_get_sub_element_idx(alarm_id)]; if (alarm->started) { - alarm_stop(alarm_id); + (void)alarm_stop(alarm_id); } alarm->started = true; @@ -481,7 +481,7 @@ static int alarm_start(fwk_id_t alarm_id, } /* Disable timer interrupts to work with the active queue */ - ctx->driver->disable(ctx->driver_dev_id); + (void)ctx->driver->disable(ctx->driver_dev_id); _insert_alarm_ctx_into_active_queue(ctx, alarm); @@ -505,8 +505,8 @@ static void timer_isr(uintptr_t ctx_ptr) fwk_assert(ctx != NULL); /* Disable timer interrupts to work with the active queue */ - ctx->driver->disable(ctx->driver_dev_id); - fwk_interrupt_clear_pending(ctx->config->timer_irq); + (void)ctx->driver->disable(ctx->driver_dev_id); + (void)fwk_interrupt_clear_pending(ctx->config->timer_irq); alarm = (struct alarm_ctx *)fwk_list_pop_head(&ctx->alarms_active); @@ -658,10 +658,9 @@ static int timer_start(fwk_id_t id) fwk_list_init(&ctx->alarms_active); - fwk_interrupt_set_isr_param(ctx->config->timer_irq, - timer_isr, - (uintptr_t)ctx); - fwk_interrupt_enable(ctx->config->timer_irq); + (void)fwk_interrupt_set_isr_param( + ctx->config->timer_irq, timer_isr, (uintptr_t)ctx); + (void)fwk_interrupt_enable(ctx->config->timer_irq); return FWK_SUCCESS; } -- GitLab From e20fbd39571aefc621cc92d93a3d8d9b7b497213 Mon Sep 17 00:00:00 2001 From: Tuvshinzaya Erdenekhuu Date: Thu, 26 Aug 2021 14:25:51 +0100 Subject: [PATCH 4/4] framework: Fix violation of required MISRAC 2012 rule 17.7 Violations of MISRAC 2012 rule 17.7 related to framework files is fixed in this patch. For this function, the returned value is not used and therefore it should be cast to void. Signed-off-by: Tuvshinzaya Erdenekhuu Change-Id: I0479136a295ce341a7fc0c5429538d67a6947345 Signed-off-by: Nicola Mazzucato --- framework/src/fwk_thread.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/framework/src/fwk_thread.c b/framework/src/fwk_thread.c index 1a97051a3..a652b3c6b 100644 --- a/framework/src/fwk_thread.c +++ b/framework/src/fwk_thread.c @@ -212,7 +212,7 @@ static void process_next_event(void) module->process_event; if (event->response_requested) { - memset(&async_response_event, 0, sizeof(async_response_event)); + (void)memset(&async_response_event, 0, sizeof(async_response_event)); async_response_event = *event; async_response_event.source_id = event->target_id; async_response_event.target_id = event->source_id; -- GitLab