All of lore.kernel.org
 help / color / mirror / Atom feed
* [XEN PATCH v2 0/2] automation/eclair: update configuration of Rule 20.7
@ 2024-09-10 10:50 Federico Serafini
  2024-09-10 10:50 ` [XEN PATCH v2 1/2] " Federico Serafini
  2024-09-10 10:50 ` [XEN PATCH v2 2/2] xen/bitmap: remove redundant deviations Federico Serafini
  0 siblings, 2 replies; 5+ messages in thread
From: Federico Serafini @ 2024-09-10 10:50 UTC (permalink / raw)
  To: xen-devel
  Cc: consulting, Federico Serafini, Simone Ballarin, Doug Goldstein,
	Stefano Stabellini, Andrew Cooper, Jan Beulich, Julien Grall

Update ECLAIR configuration to deviate some safe violations of Rule 20.7.
Remove redundant comment-based deviations.

Federico Serafini (2):
  automation/eclair: update configuration of Rule 20.7
  xen/bitmap: remove redundant deviations

 automation/eclair_analysis/ECLAIR/deviations.ecl | 4 ++++
 docs/misra/deviations.rst                        | 5 +++++
 xen/include/xen/bitmap.h                         | 3 ---
 3 files changed, 9 insertions(+), 3 deletions(-)

-- 
2.34.1



^ permalink raw reply	[flat|nested] 5+ messages in thread

* [XEN PATCH v2 1/2] automation/eclair: update configuration of Rule 20.7
  2024-09-10 10:50 [XEN PATCH v2 0/2] automation/eclair: update configuration of Rule 20.7 Federico Serafini
@ 2024-09-10 10:50 ` Federico Serafini
  2024-09-12  0:35   ` Stefano Stabellini
  2024-09-10 10:50 ` [XEN PATCH v2 2/2] xen/bitmap: remove redundant deviations Federico Serafini
  1 sibling, 1 reply; 5+ messages in thread
From: Federico Serafini @ 2024-09-10 10:50 UTC (permalink / raw)
  To: xen-devel
  Cc: consulting, Federico Serafini, Simone Ballarin, Doug Goldstein,
	Stefano Stabellini, Andrew Cooper, Jan Beulich, Julien Grall

MISRA C:2012 Rule 20.7 states that "Expressions resulting from the
expansion of macro parameters shall be enclosed in parentheses".
The rational of the rule is that if a macro argument expands to an
expression, there may be problems related to operator precedence, e.g.,

define M(A, B) A * B

M(1+1, 2+2) will expand to: 1+1 * 2+2

Update ECLAIR configuration to tag as 'safe' the expansions of macro
arguments surrounded tokens '{', '}' and ';', since in their presence
problems related to operator precedence can not occur.

Signed-off-by: Federico Serafini <federico.serafini@bugseng.com>
---
Changes from v1:
- more details to justify the deviation;
- split modifications in two patches.
---
 automation/eclair_analysis/ECLAIR/deviations.ecl | 4 ++++
 docs/misra/deviations.rst                        | 5 +++++
 2 files changed, 9 insertions(+)

diff --git a/automation/eclair_analysis/ECLAIR/deviations.ecl b/automation/eclair_analysis/ECLAIR/deviations.ecl
index 9051f41602..e0d9426b7a 100644
--- a/automation/eclair_analysis/ECLAIR/deviations.ecl
+++ b/automation/eclair_analysis/ECLAIR/deviations.ecl
@@ -581,6 +581,10 @@ of this macro do not lead to developer confusion, and can thus be deviated."
 -config=MC3R1.R20.7,reports+={safe, "any_area(any_loc(any_exp(macro(^count_args_$))))"}
 -doc_end
 
+-doc_begin="Problems related to operator precedence can not occur if the expansion of the macro argument is surrounded by tokens '{', '}' and ';'."
+-config=MC3R1.R20.7,expansion_context+={safe, "left_right(^[\\{;]$,^[;\\}]$)"}
+-doc_end
+
 -doc_begin="Uses of variadic macros that have one of their arguments defined as
 a macro and used within the body for both ordinary parameter expansion and as an
 operand to the # or ## operators have a behavior that is well-understood and
diff --git a/docs/misra/deviations.rst b/docs/misra/deviations.rst
index b66c271c4e..69f93a6a91 100644
--- a/docs/misra/deviations.rst
+++ b/docs/misra/deviations.rst
@@ -534,6 +534,11 @@ Deviations related to MISRA C:2012 Rules:
        refactoring it to add parentheses breaks its functionality.
      - Tagged as `safe` for ECLAIR.
 
+   * - R20.7
+     - Problems related to operator precedence can not occur if the expansion
+       of the macro argument is surrounded by tokens '{', '}' and ';'.
+     - Tagged as `safe` for ECLAIR.
+
    * - R20.12
      - Variadic macros that use token pasting often employ the gcc extension
        `ext_paste_comma`, as detailed in `C-language-toolchain.rst`, which is
-- 
2.34.1



^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [XEN PATCH v2 2/2] xen/bitmap: remove redundant deviations
  2024-09-10 10:50 [XEN PATCH v2 0/2] automation/eclair: update configuration of Rule 20.7 Federico Serafini
  2024-09-10 10:50 ` [XEN PATCH v2 1/2] " Federico Serafini
@ 2024-09-10 10:50 ` Federico Serafini
  2024-09-12  0:35   ` Stefano Stabellini
  1 sibling, 1 reply; 5+ messages in thread
From: Federico Serafini @ 2024-09-10 10:50 UTC (permalink / raw)
  To: xen-devel
  Cc: consulting, Federico Serafini, Andrew Cooper, Jan Beulich,
	Julien Grall, Stefano Stabellini

Remove comment-based deviations since a project wide deviation that
cover such cases is present.

Signed-off-by: Federico Serafini <federico.serafini@bugseng.com>
---
Changes from v1:
- split modifications in two patches.
---
 xen/include/xen/bitmap.h | 3 ---
 1 file changed, 3 deletions(-)

diff --git a/xen/include/xen/bitmap.h b/xen/include/xen/bitmap.h
index 5d668053b0..4b642cd420 100644
--- a/xen/include/xen/bitmap.h
+++ b/xen/include/xen/bitmap.h
@@ -103,13 +103,10 @@ extern int bitmap_allocate_region(unsigned long *bitmap, int pos, int order);
 #define bitmap_switch(nbits, zero, small, large)			  \
 	unsigned int n__ = (nbits);					  \
 	if (__builtin_constant_p(nbits) && !n__) {			  \
-		/* SAF-7-safe Rule 20.7 non-parenthesized macro argument */ \
 		zero;							  \
 	} else if (__builtin_constant_p(nbits) && n__ <= BITS_PER_LONG) { \
-		/* SAF-7-safe Rule 20.7 non-parenthesized macro argument */ \
 		small;							  \
 	} else {							  \
-		/* SAF-7-safe Rule 20.7 non-parenthesized macro argument */ \
 		large;							  \
 	}
 
-- 
2.34.1



^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [XEN PATCH v2 1/2] automation/eclair: update configuration of Rule 20.7
  2024-09-10 10:50 ` [XEN PATCH v2 1/2] " Federico Serafini
@ 2024-09-12  0:35   ` Stefano Stabellini
  0 siblings, 0 replies; 5+ messages in thread
From: Stefano Stabellini @ 2024-09-12  0:35 UTC (permalink / raw)
  To: Federico Serafini
  Cc: xen-devel, consulting, Simone Ballarin, Doug Goldstein,
	Stefano Stabellini, Andrew Cooper, Jan Beulich, Julien Grall

On Tue, 10 Sep 2024, Federico Serafini wrote:
> MISRA C:2012 Rule 20.7 states that "Expressions resulting from the
> expansion of macro parameters shall be enclosed in parentheses".
> The rational of the rule is that if a macro argument expands to an
> expression, there may be problems related to operator precedence, e.g.,
> 
> define M(A, B) A * B
> 
> M(1+1, 2+2) will expand to: 1+1 * 2+2
> 
> Update ECLAIR configuration to tag as 'safe' the expansions of macro
> arguments surrounded tokens '{', '}' and ';', since in their presence
> problems related to operator precedence can not occur.
> 
> Signed-off-by: Federico Serafini <federico.serafini@bugseng.com>

Acked-by: Stefano Stabellini <sstabellini@kernel.org>


> ---
> Changes from v1:
> - more details to justify the deviation;
> - split modifications in two patches.
> ---
>  automation/eclair_analysis/ECLAIR/deviations.ecl | 4 ++++
>  docs/misra/deviations.rst                        | 5 +++++
>  2 files changed, 9 insertions(+)
> 
> diff --git a/automation/eclair_analysis/ECLAIR/deviations.ecl b/automation/eclair_analysis/ECLAIR/deviations.ecl
> index 9051f41602..e0d9426b7a 100644
> --- a/automation/eclair_analysis/ECLAIR/deviations.ecl
> +++ b/automation/eclair_analysis/ECLAIR/deviations.ecl
> @@ -581,6 +581,10 @@ of this macro do not lead to developer confusion, and can thus be deviated."
>  -config=MC3R1.R20.7,reports+={safe, "any_area(any_loc(any_exp(macro(^count_args_$))))"}
>  -doc_end
>  
> +-doc_begin="Problems related to operator precedence can not occur if the expansion of the macro argument is surrounded by tokens '{', '}' and ';'."
> +-config=MC3R1.R20.7,expansion_context+={safe, "left_right(^[\\{;]$,^[;\\}]$)"}
> +-doc_end
> +
>  -doc_begin="Uses of variadic macros that have one of their arguments defined as
>  a macro and used within the body for both ordinary parameter expansion and as an
>  operand to the # or ## operators have a behavior that is well-understood and
> diff --git a/docs/misra/deviations.rst b/docs/misra/deviations.rst
> index b66c271c4e..69f93a6a91 100644
> --- a/docs/misra/deviations.rst
> +++ b/docs/misra/deviations.rst
> @@ -534,6 +534,11 @@ Deviations related to MISRA C:2012 Rules:
>         refactoring it to add parentheses breaks its functionality.
>       - Tagged as `safe` for ECLAIR.
>  
> +   * - R20.7
> +     - Problems related to operator precedence can not occur if the expansion
> +       of the macro argument is surrounded by tokens '{', '}' and ';'.
> +     - Tagged as `safe` for ECLAIR.
> +
>     * - R20.12
>       - Variadic macros that use token pasting often employ the gcc extension
>         `ext_paste_comma`, as detailed in `C-language-toolchain.rst`, which is
> -- 
> 2.34.1
> 


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [XEN PATCH v2 2/2] xen/bitmap: remove redundant deviations
  2024-09-10 10:50 ` [XEN PATCH v2 2/2] xen/bitmap: remove redundant deviations Federico Serafini
@ 2024-09-12  0:35   ` Stefano Stabellini
  0 siblings, 0 replies; 5+ messages in thread
From: Stefano Stabellini @ 2024-09-12  0:35 UTC (permalink / raw)
  To: Federico Serafini
  Cc: xen-devel, consulting, Andrew Cooper, Jan Beulich, Julien Grall,
	Stefano Stabellini

On Tue, 10 Sep 2024, Federico Serafini wrote:
> Remove comment-based deviations since a project wide deviation that
> cover such cases is present.
> 
> Signed-off-by: Federico Serafini <federico.serafini@bugseng.com>

Acked-by: Stefano Stabellini <sstabellini@kernel.org>


> ---
> Changes from v1:
> - split modifications in two patches.
> ---
>  xen/include/xen/bitmap.h | 3 ---
>  1 file changed, 3 deletions(-)
> 
> diff --git a/xen/include/xen/bitmap.h b/xen/include/xen/bitmap.h
> index 5d668053b0..4b642cd420 100644
> --- a/xen/include/xen/bitmap.h
> +++ b/xen/include/xen/bitmap.h
> @@ -103,13 +103,10 @@ extern int bitmap_allocate_region(unsigned long *bitmap, int pos, int order);
>  #define bitmap_switch(nbits, zero, small, large)			  \
>  	unsigned int n__ = (nbits);					  \
>  	if (__builtin_constant_p(nbits) && !n__) {			  \
> -		/* SAF-7-safe Rule 20.7 non-parenthesized macro argument */ \
>  		zero;							  \
>  	} else if (__builtin_constant_p(nbits) && n__ <= BITS_PER_LONG) { \
> -		/* SAF-7-safe Rule 20.7 non-parenthesized macro argument */ \
>  		small;							  \
>  	} else {							  \
> -		/* SAF-7-safe Rule 20.7 non-parenthesized macro argument */ \
>  		large;							  \
>  	}
>  
> -- 
> 2.34.1
> 


^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2024-09-12  0:35 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-09-10 10:50 [XEN PATCH v2 0/2] automation/eclair: update configuration of Rule 20.7 Federico Serafini
2024-09-10 10:50 ` [XEN PATCH v2 1/2] " Federico Serafini
2024-09-12  0:35   ` Stefano Stabellini
2024-09-10 10:50 ` [XEN PATCH v2 2/2] xen/bitmap: remove redundant deviations Federico Serafini
2024-09-12  0:35   ` Stefano Stabellini

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.