[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH 3/4] tools/misra: fix skipped rule numbers



On Mon, 28 Nov 2022, Luca Fancellu wrote:
> Currently the script convert_misra_doc.py is using a loop through
> range(1,22) to enumerate rules that needs to be skipped, however
> range function does not include the stop counter in the enumeration
> ending up into list rules until 21.21 instead of including rule 22.
> 
> Fix the issue using a dictionary that list the rules in misra c2012.

I think I understand the problem you are trying to solve with this
patch. But I am confused about the proposed solution.

The original code is trying to list all the possible MISRA C rules that
are not in docs/misra/rules.rst. Instead of list(range(1,22)) now we
have a dictionary: misra_c2012_rules. But misra_c2012_rules doesn't have
all the possible MISRA C rules missing from docs/misra/rules.rst.

As an example Rule 13.1 is missing from docs/misra/rules.rst but it is
also missing from misra_c2012_rules.

Can you please help me understand why misra_c2012_rules has only a small
subset of MISRA C rules to be skipped?


> Fixes: 57caa5375321 ("xen: Add MISRA support to cppcheck make rule")
> Signed-off-by: Luca Fancellu <luca.fancellu@xxxxxxx>
> ---
>  xen/tools/convert_misra_doc.py | 32 ++++++++++++++++++++++++++++++--
>  1 file changed, 30 insertions(+), 2 deletions(-)
> 
> diff --git a/xen/tools/convert_misra_doc.py b/xen/tools/convert_misra_doc.py
> index caa4487f645f..13074d8a2e91 100755
> --- a/xen/tools/convert_misra_doc.py
> +++ b/xen/tools/convert_misra_doc.py
> @@ -14,6 +14,34 @@ Usage:
>  
>  import sys, getopt, re
>  
> +# MISRA rule are identified by two numbers, e.g. Rule 1.2, the main rule 
> number
> +# and a sub-number. This dictionary contains the number of the MISRA rule as 
> key
> +# and the maximum sub-number for that rule as value.
> +misra_c2012_rules = {
> +    1:4,
> +    2:7,
> +    3:2,
> +    4:2,
> +    5:9,
> +    6:2,
> +    7:4,
> +    8:14,
> +    9:5,
> +    10:8,
> +    11:9,
> +    12:5,
> +    13:6,
> +    14:4,
> +    15:7,
> +    16:7,
> +    17:8,
> +    18:8,
> +    19:2,
> +    20:14,
> +    21:21,
> +    22:10
> +}
> +
>  def main(argv):
>      infile = ''
>      outfile = ''
> @@ -142,8 +170,8 @@ def main(argv):
>      skip_list = []
>  
>      # Search for missing rules and add a dummy text with the rule number
> -    for i in list(range(1,22)):
> -        for j in list(range(1,22)):
> +    for i in misra_c2012_rules:
> +        for j in list(range(1,misra_c2012_rules[i]+1)):
>              if str(i) + '.' + str(j) not in rule_list:
>                  outstr.write('Rule ' + str(i) + '.' + str(j) + '\n')
>                  outstr.write('No description for rule ' + str(i) + '.' + 
> str(j)
> -- 
> 2.17.1
> 



 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.