automation/eclair: generalize the noreturn function-pointer deviation

The R11.1 safe cast only matched void noreturn (*)(void *). Accept a
conversion where noreturn is omitted and the signature is otherwise
compatible. canonical() covers typeof destinations, and
compatible_deep_unqualified keeps the parameter and return types aligned.

Discarding noreturn does not change the calling convention. Code after
the call is unreachable when every possible callee is noreturn. Leaving
that code in place is a tolerated Rule 2.1 violation. The full rationale
is in docs/misra/deviations.rst.

Signed-off-by: Dmytro Prokopchuk <dmytro_prokopchuk1@epam.com>
Acked-by: Nicola Vetrini <nicola.vetrini@bugseng.com> # automation/eclair_analysis/.*
Acked-by: Jan Beulich <jbeulich@suse.com>
This commit is contained in:
Dmytro Prokopchuk authored and Jan Beulich committed 2026-10-27 09:03:28 +01:00
1 parent 65f523e546
commit b07838dc46
3 files changed
+18 -11

No files matched your search

+8 -4
View File
@@ -392,10 +392,14 @@ Deviations related to MISRA C:2012 Rules:
- Tagged as `safe` for ECLAIR.
* - R11.1
- The conversion from 'void noreturn (*)(...)' to 'void (*)(...)' is safe
because the semantics of the 'noreturn' attribute do not alter the calling
convention or behavior of the resulting code, parameters handling remain
consistent.
- The conversion from a noreturn function pointer to a function pointer
with noreturn omitted but an otherwise compatible signature does not
alter the calling convention. The callee does not return, so code
following a call through the resulting pointer is unreachable. The
compiler may delete that unreachable code when it can see that all
of the possible callees are noreturn, or it may leave the code in
place. Xen's behavior is the same in either case. Code left in place
is a tolerated violation of Rule 2.1.
- Tagged as `safe` for ECLAIR.
* - R11.2
+5 -3
View File
@@ -435,9 +435,11 @@ maintainers if you want to suggest a change.
and any other type
- All conversions to integer types are permitted if the destination
type has enough bits to hold the entire value. Conversions to bool
and void* are permitted. Conversions from 'void noreturn (*)(...)'
to 'void (*)(...)' are permitted. Conversions from [unsigned] long
or '(void *)' to a function pointer are permitted.
and '(void *)' are permitted. Conversions from a noreturn function
pointer to a function pointer with noreturn omitted but an otherwise
compatible signature are permitted.
Conversions from [unsigned] long or '(void *)' to a function pointer
are permitted.
Example::
unsigned long func_addr = (unsigned long)&some_function;
Reference in new issue
Block a user
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.