|
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [PATCH] misra: deviate MISRA C Rule 18.3 for linker symbols
MISRA C Rule 18.3 states: "The relational operators >, >=, < and <= shall not be applied to objects of pointer type except where they point into the same object". Comparisons against symbols defined by the linker (e.g. _stext/_etext in is_kernel_text()) are used to check whether an address lies within a given section. Such comparisons are safe, as section boundaries are laid out by the linker. Deviate the rule for relational operators where at least one operand refers to a linker symbol, in the same way as already done for Rule 18.2. Signed-off-by: Dmytro Prokopchuk <dmytro_prokopchuk1@xxxxxxxx> --- Test CI pipeline: https://gitlab.com/xen-project/people/dimaprkp4k/xen/-/pipelines/3139308713 --- automation/eclair_analysis/ECLAIR/deviations.ecl | 5 +++++ docs/misra/deviations.rst | 5 +++++ 2 files changed, 10 insertions(+) diff --git a/automation/eclair_analysis/ECLAIR/deviations.ecl b/automation/eclair_analysis/ECLAIR/deviations.ecl index cdcdb4622c..d45af2f895 100644 --- a/automation/eclair_analysis/ECLAIR/deviations.ecl +++ b/automation/eclair_analysis/ECLAIR/deviations.ecl @@ -626,6 +626,11 @@ C99 Undefined Behaviour 45: Pointers that do not point into, or just beyond, the -config=MC3A2.R18.2,reports+={safe, "any_area(stmt(operator(sub)&&child(lhs||rhs, skip(__non_syntactic_paren_stmts, ref(linker_symbols)))))"} -doc_end +-doc_begin="Relational comparisons between pointers involving at least one of the linker symbols (see the linker_symbols selector above) +are safe, as such symbols mark section boundaries laid out by the linker." +-config=MC3A2.R18.3,reports+={safe, "any_area(stmt(operator(lt||gt||le||ge)&&child(lhs||rhs, skip(__non_syntactic_paren_stmts, ref(linker_symbols)))))"} +-doc_end + -doc_begin="The following macro performs a subtraction between pointers to obtain the mfn, but does not lead to undefined behaviour." -config=MC3A2.R18.2,reports+={safe, "any_area(any_loc(any_exp(macro(^page_to_mfn$))))"} -doc_end diff --git a/docs/misra/deviations.rst b/docs/misra/deviations.rst index eb5817f88b..6adec8ca29 100644 --- a/docs/misra/deviations.rst +++ b/docs/misra/deviations.rst @@ -644,6 +644,11 @@ Deviations related to MISRA C:2012 Rules: are safe. - Tagged as `safe` for ECLAIR. + * - R18.3 + - Relational comparisons between pointers where at least one of the + operands is a pointer to a symbol defined by the linker are safe. + - Tagged as `safe` for ECLAIR. + * - R20.4 - The override of the keyword \"inline\" in xen/compiler.h is present so that section contents checks pass when the compiler chooses not to -- 2.43.0
|
![]() |
Lists.xenproject.org is hosted with RackSpace, monitoring our |