Explicitly cast 'halt_this_cpu' when passing it to 'smp_call_function' to match the required function pointer type '(void (*)(void *info))'.
Document and justify a MISRA C R11.1 deviation (explicit cast). Signed-off-by: Dmytro Prokopchuk <dmytro_prokopch...@epam.com> --- docs/misra/safe.json | 8 ++++++++ xen/arch/arm/shutdown.c | 6 ++++-- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/docs/misra/safe.json b/docs/misra/safe.json index 3584cb90c6..26a04ec521 100644 --- a/docs/misra/safe.json +++ b/docs/misra/safe.json @@ -124,6 +124,14 @@ }, { "id": "SAF-15-safe", + "analyser": { + "eclair": "MC3A2.R11.1" + }, + "name": "Rule 11.1: conversions shall not be performed between a pointer to a function and any other type", + "text": "The explicit cast from 'void noreturn (*)(void *)' to 'void (*)(void *)' is safe because the semantics of the 'noreturn' attribute do not alter the calling convention or behavior of the resulting code." + }, + { + "id": "SAF-16-safe", "analyser": {}, "name": "Sentinel", "text": "Next ID to be used" diff --git a/xen/arch/arm/shutdown.c b/xen/arch/arm/shutdown.c index c9778e5786..57a5583820 100644 --- a/xen/arch/arm/shutdown.c +++ b/xen/arch/arm/shutdown.c @@ -25,7 +25,8 @@ void machine_halt(void) watchdog_disable(); console_start_sync(); local_irq_enable(); - smp_call_function(halt_this_cpu, NULL, 0); + /* SAF-15-safe */ + smp_call_function((void (*)(void *))halt_this_cpu, NULL, 0); local_irq_disable(); /* Wait at most another 10ms for all other CPUs to go offline. */ @@ -50,7 +51,8 @@ void machine_restart(unsigned int delay_millisecs) spin_debug_disable(); local_irq_enable(); - smp_call_function(halt_this_cpu, NULL, 0); + /* SAF-15-safe */ + smp_call_function((void (*)(void *))halt_this_cpu, NULL, 0); local_irq_disable(); mdelay(delay_millisecs); -- 2.43.0