Skip to content

xen: address violations of MISRA C:2012 Rule 11.8

Simone Ballarin xen-devel 2 versions – In review

Get series with b4
b4 am [email protected]

Versions newest first · linked by author and title

  1. v2 Latest6 patches 11 repliesIn review
  2. v19 patches 22 repliesSuperseded

Changes in v2 from the cover letter

- reword SAF-3-safe text;
- merge comments on __hvm_copy;
- add SAF-3-safe comment in x86/hvm.c:3433;
- add SAF-3-safe comment on arm/guestcopy.c raw_copy_to_guest and raw_copy_to_guest_flush_dcache;
- remove deviation for function ERR_CAST;
- remove function ERR_CAST;
- move common/version.c to patch xen/common;
- change cast type from const void* to uintptr_t in common/version.c;
- drop redundant cast on fdt.

Patches in v2 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/6xen/arm: address violations of MISRA C:2012 Rule 11.8xen/arch/arm/bootfdt.c xen/arch/arm/include/asm/alternative.h+4 -41 reply
2/6xen/ppc: address violations of MISRA C:2012 Rule 11.8.xen/arch/ppc/include/asm/atomic.h+1 -12 replies
3/6xen: add deviations for Rule 11.8automation/eclair_analysis/ECLAIR/deviations.ecl docs/misra/deviations.rst+14 -03 replies
4/6xen: add SAF deviation for safe cast removaldocs/misra/safe.json xen/arch/arm/guestcopy.c xen/arch/x86/hvm/hvm.c+14 -22 replies
5/6xen: remove unused function ERR_CASTxen/include/xen/err.h+0 -132 replies
6/6xen/common: address violations of MISRA C:2012 Rule 11.8xen/common/version.c+1 -11 reply

Reviews trailers per patch

5 of 6 patches have a Reviewed-by or Acked-by.

PatchStefano StabelliniJan BeulichShawn Anastasio
1/6R-b
2/6R-b A-b
3/6R-b
4/6
5/6R-b A-b
6/6A-b

Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes. Scroll the table sideways for all 3 reviewers.

Read the v2 thread

Cover letter [PATCH v2 0/6] xen: address violations of MISRA C:2012 Rule 11.8

From: Maria Celeste Cesario <[email protected]>

The xen sources contain violations of MISRA C:2012 Rule 11.8 whose headline states:
"A conversion shall not remove any const, volatile or _Atomic qualification from the type pointed to by a pointer".

This patch amends or drops casts that unnecessarily drop const qualifiers.

Example:

int device_tree_for_each_node(const void *fdt);

size_t __init boot_fdt_info(const void *fdt)
{
int ret = device_tree_for_each_node((void *)fdt); /* Non-compliant */
int ret = device_tree_for_each_node(fdt); /* Compliant, proposed change */
}

In this example, the const qualifier is unnecessarily cast away from the original object, therefore making it non-compliant.

Deviate the following violations:

- removal of const qualifier to comply with function signatures A single function could either read or write through a passed in pointer, depending on how it is called. It is deemed safe to cast away a const qualifier when passing a pointer to such a function, when the other parameters guarantee read-only operation.
A SAF-3-safe comment was added to deviate these violations.

- violations in macro container_of
Violations caused by this macro are due to pointer arithmetic operations with the provided offset. The resulting pointer is then immediately cast back to its original type, which preserves the qualifier. This use is deemed safe.

Changes in v2:
- reword SAF-3-safe text;
- merge comments on __hvm_copy;
- add SAF-3-safe comment in x86/hvm.c:3433;
- add SAF-3-safe comment on arm/guestcopy.c raw_copy_to_guest and raw_copy_to_guest_flush_dcache;
- remove deviation for function ERR_CAST;
- remove function ERR_CAST;
- move common/version.c to patch xen/common;
- change cast type from const void* to uintptr_t in common/version.c;
- drop redundant cast on fdt.

Maria Celeste Cesario (6):
xen/arm: address violations of MISRA C:2012 Rule 11.8 xen/ppc: address violations of MISRA C:2012 Rule 11.8.
xen: add deviations for Rule 11.8
xen: add SAF deviation for safe cast removal
xen: remove unused function ERR_CAST xen/common: address violations of MISRA C:2012 Rule 11.8

 automation/eclair_analysis/ECLAIR/deviations.ecl |  7 +++++++
 docs/misra/deviations.rst                        |  7 +++++++
 docs/misra/safe.json                             |  8 ++++++++
 xen/arch/arm/bootfdt.c                           |  6 +++---
 xen/arch/arm/guestcopy.c                         |  2 ++
 xen/arch/arm/include/asm/alternative.h           |  2 +-
 xen/arch/ppc/include/asm/atomic.h                |  2 +-
 xen/arch/x86/hvm/hvm.c                           |  6 ++++--
 xen/common/version.c                             |  2 +-
 xen/include/xen/err.h                            | 13 -------------
 10 files changed, 34 insertions(+), 21 deletions(-)
Signature · 1 line
2.40.0