mbox series

[XEN,00/11] address some violations of MISRA C Rule 20.7

Message ID cover.1711118582.git.nicola.vetrini@bugseng.com (mailing list archive)
Headers show
Series address some violations of MISRA C Rule 20.7 | expand

Message

Nicola Vetrini March 22, 2024, 4:01 p.m. UTC
Hi all,

this series aims to refactor some macros that cause violations of MISRA C Rule
20.7 ("Expressions resulting from the expansion of macro parameters shall be
enclosed in parentheses"). All the macros touched by these patches are in some
way involved in violations, and the strategy adopted to bring them into
compliance is to add parentheses around macro arguments where needed.

Given that the community has previously requested a deviation from the rule, as
stated in docs/misra/deviations.rst, and reported below for convenience [1],
some macro parameters do not need any adjusting (e.g., when used as lhs to
an assignment in statement expressions).

Patch 1 is taken, with adjustments, from [2]. Patches 2 and 3 are taken from [3]
without any modifications. All other patches are new in this series and are
pairwise indipendent.

[1] - Code violating Rule 20.7 is safe when macro parameters are used:
       (1) as function arguments;
       (2) as macro arguments;
       (3) as array indices;
       (4) as lhs in assignments.

[2] https://lore.kernel.org/xen-devel/b93a64b93ef4210f5fe96368c2522e5e71e9c87c.1709896401.git.nicola.vetrini@bugseng.com/
[3] https://lore.kernel.org/xen-devel/cover.1710762555.git.nicola.vetrini@bugseng.com/

Nicola Vetrini (11):
  xen/list: address violations of MISRA C Rule 20.7
  xen/xsm: add parentheses to comply with MISRA C Rule 20.7
  xen/efi: efibind: address violations of MISRA C Rule 20.7
  xentrace: address violation of MISRA C Rule 20.7
  xen: address MISRA C Rule 20.7 violation in generated hypercall
  xen/efi: address violations of MISRA C Rule 20.7
  xen/page_alloc: address violations of MISRA C Rule 20.7
  x86/altcall: address violations of MISRA C Rule 20.7
  x86/msi: address violation of MISRA C Rule 20.7 and coding style
  x86/hvm: address violations of Rule 20.7
  x86/public: hvm: address violations of MISRA C Rule 20.7

 xen/arch/arm/include/asm/arm64/efibind.h  |   4 +-
 xen/arch/x86/hvm/hvm.c                    |   6 +-
 xen/arch/x86/include/asm/alternative.h    |  76 ++++++------
 xen/arch/x86/include/asm/hvm/save.h       |   4 +-
 xen/arch/x86/include/asm/msi.h            |  47 +++----
 xen/arch/x86/include/asm/x86_64/efibind.h |   4 +-
 xen/common/page_alloc.c                   |   2 +-
 xen/include/efi/efiapi.h                  |   3 +-
 xen/include/public/arch-x86/xen.h         |   2 +-
 xen/include/public/trace.h                |   2 +-
 xen/include/xen/list.h                    | 143 +++++++++++-----------
 xen/include/xsm/dummy.h                   |   4 +-
 xen/scripts/gen_hypercall.awk             |   4 +-
 13 files changed, 151 insertions(+), 150 deletions(-)

Comments

Jan Beulich March 25, 2024, 8 a.m. UTC | #1
On 22.03.2024 17:01, Nicola Vetrini wrote:
> Hi all,
> 
> this series aims to refactor some macros that cause violations of MISRA C Rule
> 20.7 ("Expressions resulting from the expansion of macro parameters shall be
> enclosed in parentheses"). All the macros touched by these patches are in some
> way involved in violations, and the strategy adopted to bring them into
> compliance is to add parentheses around macro arguments where needed.
> 
> Given that the community has previously requested a deviation from the rule, as
> stated in docs/misra/deviations.rst, and reported below for convenience [1],
> some macro parameters do not need any adjusting (e.g., when used as lhs to
> an assignment in statement expressions).
> 
> Patch 1 is taken, with adjustments, from [2]. Patches 2 and 3 are taken from [3]
> without any modifications. All other patches are new in this series and are
> pairwise indipendent.
> 
> [1] - Code violating Rule 20.7 is safe when macro parameters are used:
>        (1) as function arguments;
>        (2) as macro arguments;
>        (3) as array indices;
>        (4) as lhs in assignments.
> 
> [2] https://lore.kernel.org/xen-devel/b93a64b93ef4210f5fe96368c2522e5e71e9c87c.1709896401.git.nicola.vetrini@bugseng.com/
> [3] https://lore.kernel.org/xen-devel/cover.1710762555.git.nicola.vetrini@bugseng.com/
> 
> Nicola Vetrini (11):
>   xen/list: address violations of MISRA C Rule 20.7
>   xen/xsm: add parentheses to comply with MISRA C Rule 20.7
>   xen/efi: efibind: address violations of MISRA C Rule 20.7
>   xentrace: address violation of MISRA C Rule 20.7
>   xen: address MISRA C Rule 20.7 violation in generated hypercall
>   xen/efi: address violations of MISRA C Rule 20.7
>   xen/page_alloc: address violations of MISRA C Rule 20.7
>   x86/altcall: address violations of MISRA C Rule 20.7
>   x86/msi: address violation of MISRA C Rule 20.7 and coding style
>   x86/hvm: address violations of Rule 20.7
>   x86/public: hvm: address violations of MISRA C Rule 20.7

Just to clarify: While most of the patches here are new, two(?) I think
were submitted before. As such, to indicate that, the series as a whole
would want to be tagged v2.

Jan
Nicola Vetrini March 25, 2024, 8:07 a.m. UTC | #2
On 2024-03-25 09:00, Jan Beulich wrote:
> On 22.03.2024 17:01, Nicola Vetrini wrote:
>> Hi all,
>> 
>> this series aims to refactor some macros that cause violations of 
>> MISRA C Rule
>> 20.7 ("Expressions resulting from the expansion of macro parameters 
>> shall be
>> enclosed in parentheses"). All the macros touched by these patches are 
>> in some
>> way involved in violations, and the strategy adopted to bring them 
>> into
>> compliance is to add parentheses around macro arguments where needed.
>> 
>> Given that the community has previously requested a deviation from the 
>> rule, as
>> stated in docs/misra/deviations.rst, and reported below for 
>> convenience [1],
>> some macro parameters do not need any adjusting (e.g., when used as 
>> lhs to
>> an assignment in statement expressions).
>> 
>> Patch 1 is taken, with adjustments, from [2]. Patches 2 and 3 are 
>> taken from [3]
>> without any modifications. All other patches are new in this series 
>> and are
>> pairwise indipendent.
>> 
>> [1] - Code violating Rule 20.7 is safe when macro parameters are used:
>>        (1) as function arguments;
>>        (2) as macro arguments;
>>        (3) as array indices;
>>        (4) as lhs in assignments.
>> 
>> [2] 
>> https://lore.kernel.org/xen-devel/b93a64b93ef4210f5fe96368c2522e5e71e9c87c.1709896401.git.nicola.vetrini@bugseng.com/
>> [3] 
>> https://lore.kernel.org/xen-devel/cover.1710762555.git.nicola.vetrini@bugseng.com/
>> 
>> Nicola Vetrini (11):
>>   xen/list: address violations of MISRA C Rule 20.7
>>   xen/xsm: add parentheses to comply with MISRA C Rule 20.7
>>   xen/efi: efibind: address violations of MISRA C Rule 20.7
>>   xentrace: address violation of MISRA C Rule 20.7
>>   xen: address MISRA C Rule 20.7 violation in generated hypercall
>>   xen/efi: address violations of MISRA C Rule 20.7
>>   xen/page_alloc: address violations of MISRA C Rule 20.7
>>   x86/altcall: address violations of MISRA C Rule 20.7
>>   x86/msi: address violation of MISRA C Rule 20.7 and coding style
>>   x86/hvm: address violations of Rule 20.7
>>   x86/public: hvm: address violations of MISRA C Rule 20.7
> 
> Just to clarify: While most of the patches here are new, two(?) I think
> were submitted before. As such, to indicate that, the series as a whole
> would want to be tagged v2.
> 
> Jan

Ok, that was an oversight. Technically the list.h patch makes this a v3, 
then.