Message ID | 82a29dff7a0da97cc6ad9d247a97372bcf71f17c.1654850751.git.bertrand.marquis@arm.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Series | [v3] xen: Add MISRA support to cppcheck make rule | expand |
On 10.06.2022 11:13, Bertrand Marquis wrote: > cppcheck MISRA addon can be used to check for non compliance to some of > the MISRA standard rules. > > Add a CPPCHECK_MISRA variable that can be set to "y" using make command > line to generate a cppcheck report including cppcheck misra checks. > > When MISRA checking is enabled, a file with a text description suitable > for cppcheck misra addon is generated out of Xen documentation file > which lists the rules followed by Xen (docs/misra/rules.rst). > > By default MISRA checking is turned off. > > While adding cppcheck-misra files to gitignore, also fix the missing / > for htmlreport gitignore > > Signed-off-by: Bertrand Marquis <bertrand.marquis@arm.com> The validation was successful so: Reviewed-by: Michal Orzel <michal.orzel@arm.com> Tested-by: Michal Orzel <michal.orzel@arm.com> Cheers
On Fri, 10 Jun 2022, Bertrand Marquis wrote: > cppcheck MISRA addon can be used to check for non compliance to some of > the MISRA standard rules. > > Add a CPPCHECK_MISRA variable that can be set to "y" using make command > line to generate a cppcheck report including cppcheck misra checks. > > When MISRA checking is enabled, a file with a text description suitable > for cppcheck misra addon is generated out of Xen documentation file > which lists the rules followed by Xen (docs/misra/rules.rst). > > By default MISRA checking is turned off. > > While adding cppcheck-misra files to gitignore, also fix the missing / > for htmlreport gitignore > > Signed-off-by: Bertrand Marquis <bertrand.marquis@arm.com> Hi Bertrand, I tried this patch and I am a bit confused by the output cppcheck-misra.txt file that I get (appended.) I can see that there are all the rules from docs/misra/rules.rst as it should be together with the one line summary, but there are also a bunch of additional rules not present in docs/misra/rules.rst. Starting from Rule 1.1 all the way to Rule 21.21. Is the expected? Cheers, Stefano Appendix A Summary of guidelines Rule 2.1 Required All source files shall compile without any compilation errors (Misra rule 2.1) Rule 4.7 Required If a function returns error information then that error information shall be tested (Misra rule 4.7) Rule 4.10 Required Precautions shall be taken in order to prevent the contents of a header file being included more than once (Misra rule 4.10) Rule 4.14 Required The validity of values received from external sources shall be checked (Misra rule 4.14) Rule 1.3 Required There shall be no occurrence of undefined or critical unspecified behaviour (Misra rule 1.3) Rule 3.2 Required Line-splicing shall not be used in // comments (Misra rule 3.2) Rule 5.1 Required External identifiers shall be distinct (Misra rule 5.1) Rule 5.2 Required Identifiers declared in the same scope and name space shall be distinct (Misra rule 5.2) Rule 5.3 Required An identifier declared in an inner scope shall not hide an identifier declared in an outer scope (Misra rule 5.3) Rule 5.4 Required Macro identifiers shall be distinct (Misra rule 5.4) Rule 6.2 Required Single-bit named bit fields shall not be of a signed type (Misra rule 6.2) Rule 8.1 Required Types shall be explicitly specified (Misra rule 8.1) Rule 8.4 Required A compatible declaration shall be visible when an object or function with external linkage is defined (Misra rule 8.4) Rule 8.5 Required An external object or function shall be declared once in one and only one file (Misra rule 8.5) Rule 8.6 Required An identifier with external linkage shall have exactly one external definition (Misra rule 8.6) Rule 8.8 Required The static storage class specifier shall be used in all declarations of objects and functions that have internal linkage (Misra rule 8.8) Rule 8.10 Required An inline function shall be declared with the static storage class (Misra rule 8.10) Rule 8.12 Required Within an enumerator list the value of an implicitly-specified enumeration constant shall be unique (Misra rule 8.12) Rule 9.1 Mandatory The value of an object with automatic storage duration shall not be read before it has been set (Misra rule 9.1) Rule 9.2 Required The initializer for an aggregate or union shall be enclosed in braces (Misra rule 9.2) Rule 13.6 Mandatory The operand of the sizeof operator shall not contain any expression which has potential side effects (Misra rule 13.6) Rule 14.1 Required A loop counter shall not have essentially floating type (Misra rule 14.1) Rule 16.7 Required A switch-expression shall not have essentially Boolean type (Misra rule 16.7) Rule 17.3 Mandatory A function shall not be declared implicitly (Misra rule 17.3) Rule 17.4 Mandatory All exit paths from a function with non-void return type shall have an explicit return statement with an expression (Misra rule 17.4) Rule 20.7 Required Expressions resulting from the expansion of macro parameters shall be enclosed in parentheses (Misra rule 20.7) Rule 20.13 Required A line whose first token is # shall be a valid preprocessing directive (Misra rule 20.13) Rule 20.14 Required All #else #elif and #endif preprocessor directives shall reside in the same file as the #if #ifdef or #ifndef directive to which they are related (Misra rule 20.14) Rule 1.1 No description for rule 1.1 Rule 1.2 No description for rule 1.2 Rule 1.4 No description for rule 1.4 Rule 1.5 No description for rule 1.5 Rule 1.6 No description for rule 1.6 Rule 1.7 No description for rule 1.7 Rule 1.8 No description for rule 1.8 Rule 1.9 No description for rule 1.9 Rule 1.10 No description for rule 1.10 Rule 1.11 No description for rule 1.11 Rule 1.12 No description for rule 1.12 Rule 1.13 No description for rule 1.13 Rule 1.14 No description for rule 1.14 Rule 1.15 No description for rule 1.15 Rule 1.16 No description for rule 1.16 Rule 1.17 No description for rule 1.17 Rule 1.18 No description for rule 1.18 Rule 1.19 No description for rule 1.19 Rule 1.20 No description for rule 1.20 Rule 1.21 No description for rule 1.21 Rule 2.2 No description for rule 2.2 Rule 2.3 No description for rule 2.3 Rule 2.4 No description for rule 2.4 Rule 2.5 No description for rule 2.5 Rule 2.6 No description for rule 2.6 Rule 2.7 No description for rule 2.7 Rule 2.8 No description for rule 2.8 Rule 2.9 No description for rule 2.9 Rule 2.10 No description for rule 2.10 Rule 2.11 No description for rule 2.11 Rule 2.12 No description for rule 2.12 Rule 2.13 No description for rule 2.13 Rule 2.14 No description for rule 2.14 Rule 2.15 No description for rule 2.15 Rule 2.16 No description for rule 2.16 Rule 2.17 No description for rule 2.17 Rule 2.18 No description for rule 2.18 Rule 2.19 No description for rule 2.19 Rule 2.20 No description for rule 2.20 Rule 2.21 No description for rule 2.21 Rule 3.1 No description for rule 3.1 Rule 3.3 No description for rule 3.3 Rule 3.4 No description for rule 3.4 Rule 3.5 No description for rule 3.5 Rule 3.6 No description for rule 3.6 Rule 3.7 No description for rule 3.7 Rule 3.8 No description for rule 3.8 Rule 3.9 No description for rule 3.9 Rule 3.10 No description for rule 3.10 Rule 3.11 No description for rule 3.11 Rule 3.12 No description for rule 3.12 Rule 3.13 No description for rule 3.13 Rule 3.14 No description for rule 3.14 Rule 3.15 No description for rule 3.15 Rule 3.16 No description for rule 3.16 Rule 3.17 No description for rule 3.17 Rule 3.18 No description for rule 3.18 Rule 3.19 No description for rule 3.19 Rule 3.20 No description for rule 3.20 Rule 3.21 No description for rule 3.21 Rule 4.1 No description for rule 4.1 Rule 4.2 No description for rule 4.2 Rule 4.3 No description for rule 4.3 Rule 4.4 No description for rule 4.4 Rule 4.5 No description for rule 4.5 Rule 4.6 No description for rule 4.6 Rule 4.8 No description for rule 4.8 Rule 4.9 No description for rule 4.9 Rule 4.11 No description for rule 4.11 Rule 4.12 No description for rule 4.12 Rule 4.13 No description for rule 4.13 Rule 4.15 No description for rule 4.15 Rule 4.16 No description for rule 4.16 Rule 4.17 No description for rule 4.17 Rule 4.18 No description for rule 4.18 Rule 4.19 No description for rule 4.19 Rule 4.20 No description for rule 4.20 Rule 4.21 No description for rule 4.21 Rule 5.5 No description for rule 5.5 Rule 5.6 No description for rule 5.6 Rule 5.7 No description for rule 5.7 Rule 5.8 No description for rule 5.8 Rule 5.9 No description for rule 5.9 Rule 5.10 No description for rule 5.10 Rule 5.11 No description for rule 5.11 Rule 5.12 No description for rule 5.12 Rule 5.13 No description for rule 5.13 Rule 5.14 No description for rule 5.14 Rule 5.15 No description for rule 5.15 Rule 5.16 No description for rule 5.16 Rule 5.17 No description for rule 5.17 Rule 5.18 No description for rule 5.18 Rule 5.19 No description for rule 5.19 Rule 5.20 No description for rule 5.20 Rule 5.21 No description for rule 5.21 Rule 6.1 No description for rule 6.1 Rule 6.3 No description for rule 6.3 Rule 6.4 No description for rule 6.4 Rule 6.5 No description for rule 6.5 Rule 6.6 No description for rule 6.6 Rule 6.7 No description for rule 6.7 Rule 6.8 No description for rule 6.8 Rule 6.9 No description for rule 6.9 Rule 6.10 No description for rule 6.10 Rule 6.11 No description for rule 6.11 Rule 6.12 No description for rule 6.12 Rule 6.13 No description for rule 6.13 Rule 6.14 No description for rule 6.14 Rule 6.15 No description for rule 6.15 Rule 6.16 No description for rule 6.16 Rule 6.17 No description for rule 6.17 Rule 6.18 No description for rule 6.18 Rule 6.19 No description for rule 6.19 Rule 6.20 No description for rule 6.20 Rule 6.21 No description for rule 6.21 Rule 7.1 No description for rule 7.1 Rule 7.2 No description for rule 7.2 Rule 7.3 No description for rule 7.3 Rule 7.4 No description for rule 7.4 Rule 7.5 No description for rule 7.5 Rule 7.6 No description for rule 7.6 Rule 7.7 No description for rule 7.7 Rule 7.8 No description for rule 7.8 Rule 7.9 No description for rule 7.9 Rule 7.10 No description for rule 7.10 Rule 7.11 No description for rule 7.11 Rule 7.12 No description for rule 7.12 Rule 7.13 No description for rule 7.13 Rule 7.14 No description for rule 7.14 Rule 7.15 No description for rule 7.15 Rule 7.16 No description for rule 7.16 Rule 7.17 No description for rule 7.17 Rule 7.18 No description for rule 7.18 Rule 7.19 No description for rule 7.19 Rule 7.20 No description for rule 7.20 Rule 7.21 No description for rule 7.21 Rule 8.2 No description for rule 8.2 Rule 8.3 No description for rule 8.3 Rule 8.7 No description for rule 8.7 Rule 8.9 No description for rule 8.9 Rule 8.11 No description for rule 8.11 Rule 8.13 No description for rule 8.13 Rule 8.14 No description for rule 8.14 Rule 8.15 No description for rule 8.15 Rule 8.16 No description for rule 8.16 Rule 8.17 No description for rule 8.17 Rule 8.18 No description for rule 8.18 Rule 8.19 No description for rule 8.19 Rule 8.20 No description for rule 8.20 Rule 8.21 No description for rule 8.21 Rule 9.3 No description for rule 9.3 Rule 9.4 No description for rule 9.4 Rule 9.5 No description for rule 9.5 Rule 9.6 No description for rule 9.6 Rule 9.7 No description for rule 9.7 Rule 9.8 No description for rule 9.8 Rule 9.9 No description for rule 9.9 Rule 9.10 No description for rule 9.10 Rule 9.11 No description for rule 9.11 Rule 9.12 No description for rule 9.12 Rule 9.13 No description for rule 9.13 Rule 9.14 No description for rule 9.14 Rule 9.15 No description for rule 9.15 Rule 9.16 No description for rule 9.16 Rule 9.17 No description for rule 9.17 Rule 9.18 No description for rule 9.18 Rule 9.19 No description for rule 9.19 Rule 9.20 No description for rule 9.20 Rule 9.21 No description for rule 9.21 Rule 10.1 No description for rule 10.1 Rule 10.2 No description for rule 10.2 Rule 10.3 No description for rule 10.3 Rule 10.4 No description for rule 10.4 Rule 10.5 No description for rule 10.5 Rule 10.6 No description for rule 10.6 Rule 10.7 No description for rule 10.7 Rule 10.8 No description for rule 10.8 Rule 10.9 No description for rule 10.9 Rule 10.10 No description for rule 10.10 Rule 10.11 No description for rule 10.11 Rule 10.12 No description for rule 10.12 Rule 10.13 No description for rule 10.13 Rule 10.14 No description for rule 10.14 Rule 10.15 No description for rule 10.15 Rule 10.16 No description for rule 10.16 Rule 10.17 No description for rule 10.17 Rule 10.18 No description for rule 10.18 Rule 10.19 No description for rule 10.19 Rule 10.20 No description for rule 10.20 Rule 10.21 No description for rule 10.21 Rule 11.1 No description for rule 11.1 Rule 11.2 No description for rule 11.2 Rule 11.3 No description for rule 11.3 Rule 11.4 No description for rule 11.4 Rule 11.5 No description for rule 11.5 Rule 11.6 No description for rule 11.6 Rule 11.7 No description for rule 11.7 Rule 11.8 No description for rule 11.8 Rule 11.9 No description for rule 11.9 Rule 11.10 No description for rule 11.10 Rule 11.11 No description for rule 11.11 Rule 11.12 No description for rule 11.12 Rule 11.13 No description for rule 11.13 Rule 11.14 No description for rule 11.14 Rule 11.15 No description for rule 11.15 Rule 11.16 No description for rule 11.16 Rule 11.17 No description for rule 11.17 Rule 11.18 No description for rule 11.18 Rule 11.19 No description for rule 11.19 Rule 11.20 No description for rule 11.20 Rule 11.21 No description for rule 11.21 Rule 12.1 No description for rule 12.1 Rule 12.2 No description for rule 12.2 Rule 12.3 No description for rule 12.3 Rule 12.4 No description for rule 12.4 Rule 12.5 No description for rule 12.5 Rule 12.6 No description for rule 12.6 Rule 12.7 No description for rule 12.7 Rule 12.8 No description for rule 12.8 Rule 12.9 No description for rule 12.9 Rule 12.10 No description for rule 12.10 Rule 12.11 No description for rule 12.11 Rule 12.12 No description for rule 12.12 Rule 12.13 No description for rule 12.13 Rule 12.14 No description for rule 12.14 Rule 12.15 No description for rule 12.15 Rule 12.16 No description for rule 12.16 Rule 12.17 No description for rule 12.17 Rule 12.18 No description for rule 12.18 Rule 12.19 No description for rule 12.19 Rule 12.20 No description for rule 12.20 Rule 12.21 No description for rule 12.21 Rule 13.1 No description for rule 13.1 Rule 13.2 No description for rule 13.2 Rule 13.3 No description for rule 13.3 Rule 13.4 No description for rule 13.4 Rule 13.5 No description for rule 13.5 Rule 13.7 No description for rule 13.7 Rule 13.8 No description for rule 13.8 Rule 13.9 No description for rule 13.9 Rule 13.10 No description for rule 13.10 Rule 13.11 No description for rule 13.11 Rule 13.12 No description for rule 13.12 Rule 13.13 No description for rule 13.13 Rule 13.14 No description for rule 13.14 Rule 13.15 No description for rule 13.15 Rule 13.16 No description for rule 13.16 Rule 13.17 No description for rule 13.17 Rule 13.18 No description for rule 13.18 Rule 13.19 No description for rule 13.19 Rule 13.20 No description for rule 13.20 Rule 13.21 No description for rule 13.21 Rule 14.2 No description for rule 14.2 Rule 14.3 No description for rule 14.3 Rule 14.4 No description for rule 14.4 Rule 14.5 No description for rule 14.5 Rule 14.6 No description for rule 14.6 Rule 14.7 No description for rule 14.7 Rule 14.8 No description for rule 14.8 Rule 14.9 No description for rule 14.9 Rule 14.10 No description for rule 14.10 Rule 14.11 No description for rule 14.11 Rule 14.12 No description for rule 14.12 Rule 14.13 No description for rule 14.13 Rule 14.14 No description for rule 14.14 Rule 14.15 No description for rule 14.15 Rule 14.16 No description for rule 14.16 Rule 14.17 No description for rule 14.17 Rule 14.18 No description for rule 14.18 Rule 14.19 No description for rule 14.19 Rule 14.20 No description for rule 14.20 Rule 14.21 No description for rule 14.21 Rule 15.1 No description for rule 15.1 Rule 15.2 No description for rule 15.2 Rule 15.3 No description for rule 15.3 Rule 15.4 No description for rule 15.4 Rule 15.5 No description for rule 15.5 Rule 15.6 No description for rule 15.6 Rule 15.7 No description for rule 15.7 Rule 15.8 No description for rule 15.8 Rule 15.9 No description for rule 15.9 Rule 15.10 No description for rule 15.10 Rule 15.11 No description for rule 15.11 Rule 15.12 No description for rule 15.12 Rule 15.13 No description for rule 15.13 Rule 15.14 No description for rule 15.14 Rule 15.15 No description for rule 15.15 Rule 15.16 No description for rule 15.16 Rule 15.17 No description for rule 15.17 Rule 15.18 No description for rule 15.18 Rule 15.19 No description for rule 15.19 Rule 15.20 No description for rule 15.20 Rule 15.21 No description for rule 15.21 Rule 16.1 No description for rule 16.1 Rule 16.2 No description for rule 16.2 Rule 16.3 No description for rule 16.3 Rule 16.4 No description for rule 16.4 Rule 16.5 No description for rule 16.5 Rule 16.6 No description for rule 16.6 Rule 16.8 No description for rule 16.8 Rule 16.9 No description for rule 16.9 Rule 16.10 No description for rule 16.10 Rule 16.11 No description for rule 16.11 Rule 16.12 No description for rule 16.12 Rule 16.13 No description for rule 16.13 Rule 16.14 No description for rule 16.14 Rule 16.15 No description for rule 16.15 Rule 16.16 No description for rule 16.16 Rule 16.17 No description for rule 16.17 Rule 16.18 No description for rule 16.18 Rule 16.19 No description for rule 16.19 Rule 16.20 No description for rule 16.20 Rule 16.21 No description for rule 16.21 Rule 17.1 No description for rule 17.1 Rule 17.2 No description for rule 17.2 Rule 17.5 No description for rule 17.5 Rule 17.6 No description for rule 17.6 Rule 17.7 No description for rule 17.7 Rule 17.8 No description for rule 17.8 Rule 17.9 No description for rule 17.9 Rule 17.10 No description for rule 17.10 Rule 17.11 No description for rule 17.11 Rule 17.12 No description for rule 17.12 Rule 17.13 No description for rule 17.13 Rule 17.14 No description for rule 17.14 Rule 17.15 No description for rule 17.15 Rule 17.16 No description for rule 17.16 Rule 17.17 No description for rule 17.17 Rule 17.18 No description for rule 17.18 Rule 17.19 No description for rule 17.19 Rule 17.20 No description for rule 17.20 Rule 17.21 No description for rule 17.21 Rule 18.1 No description for rule 18.1 Rule 18.2 No description for rule 18.2 Rule 18.3 No description for rule 18.3 Rule 18.4 No description for rule 18.4 Rule 18.5 No description for rule 18.5 Rule 18.6 No description for rule 18.6 Rule 18.7 No description for rule 18.7 Rule 18.8 No description for rule 18.8 Rule 18.9 No description for rule 18.9 Rule 18.10 No description for rule 18.10 Rule 18.11 No description for rule 18.11 Rule 18.12 No description for rule 18.12 Rule 18.13 No description for rule 18.13 Rule 18.14 No description for rule 18.14 Rule 18.15 No description for rule 18.15 Rule 18.16 No description for rule 18.16 Rule 18.17 No description for rule 18.17 Rule 18.18 No description for rule 18.18 Rule 18.19 No description for rule 18.19 Rule 18.20 No description for rule 18.20 Rule 18.21 No description for rule 18.21 Rule 19.1 No description for rule 19.1 Rule 19.2 No description for rule 19.2 Rule 19.3 No description for rule 19.3 Rule 19.4 No description for rule 19.4 Rule 19.5 No description for rule 19.5 Rule 19.6 No description for rule 19.6 Rule 19.7 No description for rule 19.7 Rule 19.8 No description for rule 19.8 Rule 19.9 No description for rule 19.9 Rule 19.10 No description for rule 19.10 Rule 19.11 No description for rule 19.11 Rule 19.12 No description for rule 19.12 Rule 19.13 No description for rule 19.13 Rule 19.14 No description for rule 19.14 Rule 19.15 No description for rule 19.15 Rule 19.16 No description for rule 19.16 Rule 19.17 No description for rule 19.17 Rule 19.18 No description for rule 19.18 Rule 19.19 No description for rule 19.19 Rule 19.20 No description for rule 19.20 Rule 19.21 No description for rule 19.21 Rule 20.1 No description for rule 20.1 Rule 20.2 No description for rule 20.2 Rule 20.3 No description for rule 20.3 Rule 20.4 No description for rule 20.4 Rule 20.5 No description for rule 20.5 Rule 20.6 No description for rule 20.6 Rule 20.8 No description for rule 20.8 Rule 20.9 No description for rule 20.9 Rule 20.10 No description for rule 20.10 Rule 20.11 No description for rule 20.11 Rule 20.12 No description for rule 20.12 Rule 20.15 No description for rule 20.15 Rule 20.16 No description for rule 20.16 Rule 20.17 No description for rule 20.17 Rule 20.18 No description for rule 20.18 Rule 20.19 No description for rule 20.19 Rule 20.20 No description for rule 20.20 Rule 20.21 No description for rule 20.21 Rule 21.1 No description for rule 21.1 Rule 21.2 No description for rule 21.2 Rule 21.3 No description for rule 21.3 Rule 21.4 No description for rule 21.4 Rule 21.5 No description for rule 21.5 Rule 21.6 No description for rule 21.6 Rule 21.7 No description for rule 21.7 Rule 21.8 No description for rule 21.8 Rule 21.9 No description for rule 21.9 Rule 21.10 No description for rule 21.10 Rule 21.11 No description for rule 21.11 Rule 21.12 No description for rule 21.12 Rule 21.13 No description for rule 21.13 Rule 21.14 No description for rule 21.14 Rule 21.15 No description for rule 21.15 Rule 21.16 No description for rule 21.16 Rule 21.17 No description for rule 21.17 Rule 21.18 No description for rule 21.18 Rule 21.19 No description for rule 21.19 Rule 21.20 No description for rule 21.20 Rule 21.21 No description for rule 21.21 Appendix B
Hi Stefano, > On 22 Jun 2022, at 01:00, Stefano Stabellini <sstabellini@kernel.org> wrote: > > On Fri, 10 Jun 2022, Bertrand Marquis wrote: >> cppcheck MISRA addon can be used to check for non compliance to some of >> the MISRA standard rules. >> >> Add a CPPCHECK_MISRA variable that can be set to "y" using make command >> line to generate a cppcheck report including cppcheck misra checks. >> >> When MISRA checking is enabled, a file with a text description suitable >> for cppcheck misra addon is generated out of Xen documentation file >> which lists the rules followed by Xen (docs/misra/rules.rst). >> >> By default MISRA checking is turned off. >> >> While adding cppcheck-misra files to gitignore, also fix the missing / >> for htmlreport gitignore >> >> Signed-off-by: Bertrand Marquis <bertrand.marquis@arm.com> > > Hi Bertrand, > > I tried this patch and I am a bit confused by the output > cppcheck-misra.txt file that I get (appended.) > > I can see that there are all the rules from docs/misra/rules.rst as it > should be together with the one line summary, but there are also a bunch > of additional rules not present in docs/misra/rules.rst. Starting from > Rule 1.1 all the way to Rule 21.21. Is the expected? To make cppcheck happy I need to give a text for all rules so the python script is generating a dummy sentence for not declared Misra rules to prevent cppcheck warnings. To make it simpler I just did it for 1 to 22 for main and sub numbers. So yes this is expected. Cheers Bertrand > > Cheers, > > Stefano > > > Appendix A Summary of guidelines > Rule 2.1 Required > All source files shall compile without any compilation errors (Misra rule 2.1) > Rule 4.7 Required > If a function returns error information then that error information shall be tested (Misra rule 4.7) > Rule 4.10 Required > Precautions shall be taken in order to prevent the contents of a header file being included more than once (Misra rule 4.10) > Rule 4.14 Required > The validity of values received from external sources shall be checked (Misra rule 4.14) > Rule 1.3 Required > There shall be no occurrence of undefined or critical unspecified behaviour (Misra rule 1.3) > Rule 3.2 Required > Line-splicing shall not be used in // comments (Misra rule 3.2) > Rule 5.1 Required > External identifiers shall be distinct (Misra rule 5.1) > Rule 5.2 Required > Identifiers declared in the same scope and name space shall be distinct (Misra rule 5.2) > Rule 5.3 Required > An identifier declared in an inner scope shall not hide an identifier declared in an outer scope (Misra rule 5.3) > Rule 5.4 Required > Macro identifiers shall be distinct (Misra rule 5.4) > Rule 6.2 Required > Single-bit named bit fields shall not be of a signed type (Misra rule 6.2) > Rule 8.1 Required > Types shall be explicitly specified (Misra rule 8.1) > Rule 8.4 Required > A compatible declaration shall be visible when an object or function with external linkage is defined (Misra rule 8.4) > Rule 8.5 Required > An external object or function shall be declared once in one and only one file (Misra rule 8.5) > Rule 8.6 Required > An identifier with external linkage shall have exactly one external definition (Misra rule 8.6) > Rule 8.8 Required > The static storage class specifier shall be used in all declarations of objects and functions that have internal linkage (Misra rule 8.8) > Rule 8.10 Required > An inline function shall be declared with the static storage class (Misra rule 8.10) > Rule 8.12 Required > Within an enumerator list the value of an implicitly-specified enumeration constant shall be unique (Misra rule 8.12) > Rule 9.1 Mandatory > The value of an object with automatic storage duration shall not be read before it has been set (Misra rule 9.1) > Rule 9.2 Required > The initializer for an aggregate or union shall be enclosed in braces (Misra rule 9.2) > Rule 13.6 Mandatory > The operand of the sizeof operator shall not contain any expression which has potential side effects (Misra rule 13.6) > Rule 14.1 Required > A loop counter shall not have essentially floating type (Misra rule 14.1) > Rule 16.7 Required > A switch-expression shall not have essentially Boolean type (Misra rule 16.7) > Rule 17.3 Mandatory > A function shall not be declared implicitly (Misra rule 17.3) > Rule 17.4 Mandatory > All exit paths from a function with non-void return type shall have an explicit return statement with an expression (Misra rule 17.4) > Rule 20.7 Required > Expressions resulting from the expansion of macro parameters shall be enclosed in parentheses (Misra rule 20.7) > Rule 20.13 Required > A line whose first token is # shall be a valid preprocessing directive (Misra rule 20.13) > Rule 20.14 Required > All #else #elif and #endif preprocessor directives shall reside in the same file as the #if #ifdef or #ifndef directive to which they are related (Misra rule 20.14) > Rule 1.1 > No description for rule 1.1 > Rule 1.2 > No description for rule 1.2 > Rule 1.4 > No description for rule 1.4 > Rule 1.5 > No description for rule 1.5 > Rule 1.6 > No description for rule 1.6 > Rule 1.7 > No description for rule 1.7 > Rule 1.8 > No description for rule 1.8 > Rule 1.9 > No description for rule 1.9 > Rule 1.10 > No description for rule 1.10 > Rule 1.11 > No description for rule 1.11 > Rule 1.12 > No description for rule 1.12 > Rule 1.13 > No description for rule 1.13 > Rule 1.14 > No description for rule 1.14 > Rule 1.15 > No description for rule 1.15 > Rule 1.16 > No description for rule 1.16 > Rule 1.17 > No description for rule 1.17 > Rule 1.18 > No description for rule 1.18 > Rule 1.19 > No description for rule 1.19 > Rule 1.20 > No description for rule 1.20 > Rule 1.21 > No description for rule 1.21 > Rule 2.2 > No description for rule 2.2 > Rule 2.3 > No description for rule 2.3 > Rule 2.4 > No description for rule 2.4 > Rule 2.5 > No description for rule 2.5 > Rule 2.6 > No description for rule 2.6 > Rule 2.7 > No description for rule 2.7 > Rule 2.8 > No description for rule 2.8 > Rule 2.9 > No description for rule 2.9 > Rule 2.10 > No description for rule 2.10 > Rule 2.11 > No description for rule 2.11 > Rule 2.12 > No description for rule 2.12 > Rule 2.13 > No description for rule 2.13 > Rule 2.14 > No description for rule 2.14 > Rule 2.15 > No description for rule 2.15 > Rule 2.16 > No description for rule 2.16 > Rule 2.17 > No description for rule 2.17 > Rule 2.18 > No description for rule 2.18 > Rule 2.19 > No description for rule 2.19 > Rule 2.20 > No description for rule 2.20 > Rule 2.21 > No description for rule 2.21 > Rule 3.1 > No description for rule 3.1 > Rule 3.3 > No description for rule 3.3 > Rule 3.4 > No description for rule 3.4 > Rule 3.5 > No description for rule 3.5 > Rule 3.6 > No description for rule 3.6 > Rule 3.7 > No description for rule 3.7 > Rule 3.8 > No description for rule 3.8 > Rule 3.9 > No description for rule 3.9 > Rule 3.10 > No description for rule 3.10 > Rule 3.11 > No description for rule 3.11 > Rule 3.12 > No description for rule 3.12 > Rule 3.13 > No description for rule 3.13 > Rule 3.14 > No description for rule 3.14 > Rule 3.15 > No description for rule 3.15 > Rule 3.16 > No description for rule 3.16 > Rule 3.17 > No description for rule 3.17 > Rule 3.18 > No description for rule 3.18 > Rule 3.19 > No description for rule 3.19 > Rule 3.20 > No description for rule 3.20 > Rule 3.21 > No description for rule 3.21 > Rule 4.1 > No description for rule 4.1 > Rule 4.2 > No description for rule 4.2 > Rule 4.3 > No description for rule 4.3 > Rule 4.4 > No description for rule 4.4 > Rule 4.5 > No description for rule 4.5 > Rule 4.6 > No description for rule 4.6 > Rule 4.8 > No description for rule 4.8 > Rule 4.9 > No description for rule 4.9 > Rule 4.11 > No description for rule 4.11 > Rule 4.12 > No description for rule 4.12 > Rule 4.13 > No description for rule 4.13 > Rule 4.15 > No description for rule 4.15 > Rule 4.16 > No description for rule 4.16 > Rule 4.17 > No description for rule 4.17 > Rule 4.18 > No description for rule 4.18 > Rule 4.19 > No description for rule 4.19 > Rule 4.20 > No description for rule 4.20 > Rule 4.21 > No description for rule 4.21 > Rule 5.5 > No description for rule 5.5 > Rule 5.6 > No description for rule 5.6 > Rule 5.7 > No description for rule 5.7 > Rule 5.8 > No description for rule 5.8 > Rule 5.9 > No description for rule 5.9 > Rule 5.10 > No description for rule 5.10 > Rule 5.11 > No description for rule 5.11 > Rule 5.12 > No description for rule 5.12 > Rule 5.13 > No description for rule 5.13 > Rule 5.14 > No description for rule 5.14 > Rule 5.15 > No description for rule 5.15 > Rule 5.16 > No description for rule 5.16 > Rule 5.17 > No description for rule 5.17 > Rule 5.18 > No description for rule 5.18 > Rule 5.19 > No description for rule 5.19 > Rule 5.20 > No description for rule 5.20 > Rule 5.21 > No description for rule 5.21 > Rule 6.1 > No description for rule 6.1 > Rule 6.3 > No description for rule 6.3 > Rule 6.4 > No description for rule 6.4 > Rule 6.5 > No description for rule 6.5 > Rule 6.6 > No description for rule 6.6 > Rule 6.7 > No description for rule 6.7 > Rule 6.8 > No description for rule 6.8 > Rule 6.9 > No description for rule 6.9 > Rule 6.10 > No description for rule 6.10 > Rule 6.11 > No description for rule 6.11 > Rule 6.12 > No description for rule 6.12 > Rule 6.13 > No description for rule 6.13 > Rule 6.14 > No description for rule 6.14 > Rule 6.15 > No description for rule 6.15 > Rule 6.16 > No description for rule 6.16 > Rule 6.17 > No description for rule 6.17 > Rule 6.18 > No description for rule 6.18 > Rule 6.19 > No description for rule 6.19 > Rule 6.20 > No description for rule 6.20 > Rule 6.21 > No description for rule 6.21 > Rule 7.1 > No description for rule 7.1 > Rule 7.2 > No description for rule 7.2 > Rule 7.3 > No description for rule 7.3 > Rule 7.4 > No description for rule 7.4 > Rule 7.5 > No description for rule 7.5 > Rule 7.6 > No description for rule 7.6 > Rule 7.7 > No description for rule 7.7 > Rule 7.8 > No description for rule 7.8 > Rule 7.9 > No description for rule 7.9 > Rule 7.10 > No description for rule 7.10 > Rule 7.11 > No description for rule 7.11 > Rule 7.12 > No description for rule 7.12 > Rule 7.13 > No description for rule 7.13 > Rule 7.14 > No description for rule 7.14 > Rule 7.15 > No description for rule 7.15 > Rule 7.16 > No description for rule 7.16 > Rule 7.17 > No description for rule 7.17 > Rule 7.18 > No description for rule 7.18 > Rule 7.19 > No description for rule 7.19 > Rule 7.20 > No description for rule 7.20 > Rule 7.21 > No description for rule 7.21 > Rule 8.2 > No description for rule 8.2 > Rule 8.3 > No description for rule 8.3 > Rule 8.7 > No description for rule 8.7 > Rule 8.9 > No description for rule 8.9 > Rule 8.11 > No description for rule 8.11 > Rule 8.13 > No description for rule 8.13 > Rule 8.14 > No description for rule 8.14 > Rule 8.15 > No description for rule 8.15 > Rule 8.16 > No description for rule 8.16 > Rule 8.17 > No description for rule 8.17 > Rule 8.18 > No description for rule 8.18 > Rule 8.19 > No description for rule 8.19 > Rule 8.20 > No description for rule 8.20 > Rule 8.21 > No description for rule 8.21 > Rule 9.3 > No description for rule 9.3 > Rule 9.4 > No description for rule 9.4 > Rule 9.5 > No description for rule 9.5 > Rule 9.6 > No description for rule 9.6 > Rule 9.7 > No description for rule 9.7 > Rule 9.8 > No description for rule 9.8 > Rule 9.9 > No description for rule 9.9 > Rule 9.10 > No description for rule 9.10 > Rule 9.11 > No description for rule 9.11 > Rule 9.12 > No description for rule 9.12 > Rule 9.13 > No description for rule 9.13 > Rule 9.14 > No description for rule 9.14 > Rule 9.15 > No description for rule 9.15 > Rule 9.16 > No description for rule 9.16 > Rule 9.17 > No description for rule 9.17 > Rule 9.18 > No description for rule 9.18 > Rule 9.19 > No description for rule 9.19 > Rule 9.20 > No description for rule 9.20 > Rule 9.21 > No description for rule 9.21 > Rule 10.1 > No description for rule 10.1 > Rule 10.2 > No description for rule 10.2 > Rule 10.3 > No description for rule 10.3 > Rule 10.4 > No description for rule 10.4 > Rule 10.5 > No description for rule 10.5 > Rule 10.6 > No description for rule 10.6 > Rule 10.7 > No description for rule 10.7 > Rule 10.8 > No description for rule 10.8 > Rule 10.9 > No description for rule 10.9 > Rule 10.10 > No description for rule 10.10 > Rule 10.11 > No description for rule 10.11 > Rule 10.12 > No description for rule 10.12 > Rule 10.13 > No description for rule 10.13 > Rule 10.14 > No description for rule 10.14 > Rule 10.15 > No description for rule 10.15 > Rule 10.16 > No description for rule 10.16 > Rule 10.17 > No description for rule 10.17 > Rule 10.18 > No description for rule 10.18 > Rule 10.19 > No description for rule 10.19 > Rule 10.20 > No description for rule 10.20 > Rule 10.21 > No description for rule 10.21 > Rule 11.1 > No description for rule 11.1 > Rule 11.2 > No description for rule 11.2 > Rule 11.3 > No description for rule 11.3 > Rule 11.4 > No description for rule 11.4 > Rule 11.5 > No description for rule 11.5 > Rule 11.6 > No description for rule 11.6 > Rule 11.7 > No description for rule 11.7 > Rule 11.8 > No description for rule 11.8 > Rule 11.9 > No description for rule 11.9 > Rule 11.10 > No description for rule 11.10 > Rule 11.11 > No description for rule 11.11 > Rule 11.12 > No description for rule 11.12 > Rule 11.13 > No description for rule 11.13 > Rule 11.14 > No description for rule 11.14 > Rule 11.15 > No description for rule 11.15 > Rule 11.16 > No description for rule 11.16 > Rule 11.17 > No description for rule 11.17 > Rule 11.18 > No description for rule 11.18 > Rule 11.19 > No description for rule 11.19 > Rule 11.20 > No description for rule 11.20 > Rule 11.21 > No description for rule 11.21 > Rule 12.1 > No description for rule 12.1 > Rule 12.2 > No description for rule 12.2 > Rule 12.3 > No description for rule 12.3 > Rule 12.4 > No description for rule 12.4 > Rule 12.5 > No description for rule 12.5 > Rule 12.6 > No description for rule 12.6 > Rule 12.7 > No description for rule 12.7 > Rule 12.8 > No description for rule 12.8 > Rule 12.9 > No description for rule 12.9 > Rule 12.10 > No description for rule 12.10 > Rule 12.11 > No description for rule 12.11 > Rule 12.12 > No description for rule 12.12 > Rule 12.13 > No description for rule 12.13 > Rule 12.14 > No description for rule 12.14 > Rule 12.15 > No description for rule 12.15 > Rule 12.16 > No description for rule 12.16 > Rule 12.17 > No description for rule 12.17 > Rule 12.18 > No description for rule 12.18 > Rule 12.19 > No description for rule 12.19 > Rule 12.20 > No description for rule 12.20 > Rule 12.21 > No description for rule 12.21 > Rule 13.1 > No description for rule 13.1 > Rule 13.2 > No description for rule 13.2 > Rule 13.3 > No description for rule 13.3 > Rule 13.4 > No description for rule 13.4 > Rule 13.5 > No description for rule 13.5 > Rule 13.7 > No description for rule 13.7 > Rule 13.8 > No description for rule 13.8 > Rule 13.9 > No description for rule 13.9 > Rule 13.10 > No description for rule 13.10 > Rule 13.11 > No description for rule 13.11 > Rule 13.12 > No description for rule 13.12 > Rule 13.13 > No description for rule 13.13 > Rule 13.14 > No description for rule 13.14 > Rule 13.15 > No description for rule 13.15 > Rule 13.16 > No description for rule 13.16 > Rule 13.17 > No description for rule 13.17 > Rule 13.18 > No description for rule 13.18 > Rule 13.19 > No description for rule 13.19 > Rule 13.20 > No description for rule 13.20 > Rule 13.21 > No description for rule 13.21 > Rule 14.2 > No description for rule 14.2 > Rule 14.3 > No description for rule 14.3 > Rule 14.4 > No description for rule 14.4 > Rule 14.5 > No description for rule 14.5 > Rule 14.6 > No description for rule 14.6 > Rule 14.7 > No description for rule 14.7 > Rule 14.8 > No description for rule 14.8 > Rule 14.9 > No description for rule 14.9 > Rule 14.10 > No description for rule 14.10 > Rule 14.11 > No description for rule 14.11 > Rule 14.12 > No description for rule 14.12 > Rule 14.13 > No description for rule 14.13 > Rule 14.14 > No description for rule 14.14 > Rule 14.15 > No description for rule 14.15 > Rule 14.16 > No description for rule 14.16 > Rule 14.17 > No description for rule 14.17 > Rule 14.18 > No description for rule 14.18 > Rule 14.19 > No description for rule 14.19 > Rule 14.20 > No description for rule 14.20 > Rule 14.21 > No description for rule 14.21 > Rule 15.1 > No description for rule 15.1 > Rule 15.2 > No description for rule 15.2 > Rule 15.3 > No description for rule 15.3 > Rule 15.4 > No description for rule 15.4 > Rule 15.5 > No description for rule 15.5 > Rule 15.6 > No description for rule 15.6 > Rule 15.7 > No description for rule 15.7 > Rule 15.8 > No description for rule 15.8 > Rule 15.9 > No description for rule 15.9 > Rule 15.10 > No description for rule 15.10 > Rule 15.11 > No description for rule 15.11 > Rule 15.12 > No description for rule 15.12 > Rule 15.13 > No description for rule 15.13 > Rule 15.14 > No description for rule 15.14 > Rule 15.15 > No description for rule 15.15 > Rule 15.16 > No description for rule 15.16 > Rule 15.17 > No description for rule 15.17 > Rule 15.18 > No description for rule 15.18 > Rule 15.19 > No description for rule 15.19 > Rule 15.20 > No description for rule 15.20 > Rule 15.21 > No description for rule 15.21 > Rule 16.1 > No description for rule 16.1 > Rule 16.2 > No description for rule 16.2 > Rule 16.3 > No description for rule 16.3 > Rule 16.4 > No description for rule 16.4 > Rule 16.5 > No description for rule 16.5 > Rule 16.6 > No description for rule 16.6 > Rule 16.8 > No description for rule 16.8 > Rule 16.9 > No description for rule 16.9 > Rule 16.10 > No description for rule 16.10 > Rule 16.11 > No description for rule 16.11 > Rule 16.12 > No description for rule 16.12 > Rule 16.13 > No description for rule 16.13 > Rule 16.14 > No description for rule 16.14 > Rule 16.15 > No description for rule 16.15 > Rule 16.16 > No description for rule 16.16 > Rule 16.17 > No description for rule 16.17 > Rule 16.18 > No description for rule 16.18 > Rule 16.19 > No description for rule 16.19 > Rule 16.20 > No description for rule 16.20 > Rule 16.21 > No description for rule 16.21 > Rule 17.1 > No description for rule 17.1 > Rule 17.2 > No description for rule 17.2 > Rule 17.5 > No description for rule 17.5 > Rule 17.6 > No description for rule 17.6 > Rule 17.7 > No description for rule 17.7 > Rule 17.8 > No description for rule 17.8 > Rule 17.9 > No description for rule 17.9 > Rule 17.10 > No description for rule 17.10 > Rule 17.11 > No description for rule 17.11 > Rule 17.12 > No description for rule 17.12 > Rule 17.13 > No description for rule 17.13 > Rule 17.14 > No description for rule 17.14 > Rule 17.15 > No description for rule 17.15 > Rule 17.16 > No description for rule 17.16 > Rule 17.17 > No description for rule 17.17 > Rule 17.18 > No description for rule 17.18 > Rule 17.19 > No description for rule 17.19 > Rule 17.20 > No description for rule 17.20 > Rule 17.21 > No description for rule 17.21 > Rule 18.1 > No description for rule 18.1 > Rule 18.2 > No description for rule 18.2 > Rule 18.3 > No description for rule 18.3 > Rule 18.4 > No description for rule 18.4 > Rule 18.5 > No description for rule 18.5 > Rule 18.6 > No description for rule 18.6 > Rule 18.7 > No description for rule 18.7 > Rule 18.8 > No description for rule 18.8 > Rule 18.9 > No description for rule 18.9 > Rule 18.10 > No description for rule 18.10 > Rule 18.11 > No description for rule 18.11 > Rule 18.12 > No description for rule 18.12 > Rule 18.13 > No description for rule 18.13 > Rule 18.14 > No description for rule 18.14 > Rule 18.15 > No description for rule 18.15 > Rule 18.16 > No description for rule 18.16 > Rule 18.17 > No description for rule 18.17 > Rule 18.18 > No description for rule 18.18 > Rule 18.19 > No description for rule 18.19 > Rule 18.20 > No description for rule 18.20 > Rule 18.21 > No description for rule 18.21 > Rule 19.1 > No description for rule 19.1 > Rule 19.2 > No description for rule 19.2 > Rule 19.3 > No description for rule 19.3 > Rule 19.4 > No description for rule 19.4 > Rule 19.5 > No description for rule 19.5 > Rule 19.6 > No description for rule 19.6 > Rule 19.7 > No description for rule 19.7 > Rule 19.8 > No description for rule 19.8 > Rule 19.9 > No description for rule 19.9 > Rule 19.10 > No description for rule 19.10 > Rule 19.11 > No description for rule 19.11 > Rule 19.12 > No description for rule 19.12 > Rule 19.13 > No description for rule 19.13 > Rule 19.14 > No description for rule 19.14 > Rule 19.15 > No description for rule 19.15 > Rule 19.16 > No description for rule 19.16 > Rule 19.17 > No description for rule 19.17 > Rule 19.18 > No description for rule 19.18 > Rule 19.19 > No description for rule 19.19 > Rule 19.20 > No description for rule 19.20 > Rule 19.21 > No description for rule 19.21 > Rule 20.1 > No description for rule 20.1 > Rule 20.2 > No description for rule 20.2 > Rule 20.3 > No description for rule 20.3 > Rule 20.4 > No description for rule 20.4 > Rule 20.5 > No description for rule 20.5 > Rule 20.6 > No description for rule 20.6 > Rule 20.8 > No description for rule 20.8 > Rule 20.9 > No description for rule 20.9 > Rule 20.10 > No description for rule 20.10 > Rule 20.11 > No description for rule 20.11 > Rule 20.12 > No description for rule 20.12 > Rule 20.15 > No description for rule 20.15 > Rule 20.16 > No description for rule 20.16 > Rule 20.17 > No description for rule 20.17 > Rule 20.18 > No description for rule 20.18 > Rule 20.19 > No description for rule 20.19 > Rule 20.20 > No description for rule 20.20 > Rule 20.21 > No description for rule 20.21 > Rule 21.1 > No description for rule 21.1 > Rule 21.2 > No description for rule 21.2 > Rule 21.3 > No description for rule 21.3 > Rule 21.4 > No description for rule 21.4 > Rule 21.5 > No description for rule 21.5 > Rule 21.6 > No description for rule 21.6 > Rule 21.7 > No description for rule 21.7 > Rule 21.8 > No description for rule 21.8 > Rule 21.9 > No description for rule 21.9 > Rule 21.10 > No description for rule 21.10 > Rule 21.11 > No description for rule 21.11 > Rule 21.12 > No description for rule 21.12 > Rule 21.13 > No description for rule 21.13 > Rule 21.14 > No description for rule 21.14 > Rule 21.15 > No description for rule 21.15 > Rule 21.16 > No description for rule 21.16 > Rule 21.17 > No description for rule 21.17 > Rule 21.18 > No description for rule 21.18 > Rule 21.19 > No description for rule 21.19 > Rule 21.20 > No description for rule 21.20 > Rule 21.21 > No description for rule 21.21 > Appendix B
On Wed, 22 Jun 2022, Bertrand Marquis wrote: > Hi Stefano, > > > On 22 Jun 2022, at 01:00, Stefano Stabellini <sstabellini@kernel.org> wrote: > > > > On Fri, 10 Jun 2022, Bertrand Marquis wrote: > >> cppcheck MISRA addon can be used to check for non compliance to some of > >> the MISRA standard rules. > >> > >> Add a CPPCHECK_MISRA variable that can be set to "y" using make command > >> line to generate a cppcheck report including cppcheck misra checks. > >> > >> When MISRA checking is enabled, a file with a text description suitable > >> for cppcheck misra addon is generated out of Xen documentation file > >> which lists the rules followed by Xen (docs/misra/rules.rst). > >> > >> By default MISRA checking is turned off. > >> > >> While adding cppcheck-misra files to gitignore, also fix the missing / > >> for htmlreport gitignore > >> > >> Signed-off-by: Bertrand Marquis <bertrand.marquis@arm.com> > > > > Hi Bertrand, > > > > I tried this patch and I am a bit confused by the output > > cppcheck-misra.txt file that I get (appended.) > > > > I can see that there are all the rules from docs/misra/rules.rst as it > > should be together with the one line summary, but there are also a bunch > > of additional rules not present in docs/misra/rules.rst. Starting from > > Rule 1.1 all the way to Rule 21.21. Is the expected? > > To make cppcheck happy I need to give a text for all rules so the python script is generating a dummy sentence for not declared Misra rules to prevent cppcheck warnings. To make it simpler I just did it for 1 to 22 for main and sub numbers. > > So yes this is expected. No problem about the dummy text sentence. My question was why are all those additional rules listed? If you see below, the first few rules from 2.1 to 20.14 are coming from docs/misra/rules.rst. Why are the other rules afterward from 1.1 to 21.21 listed and where are they coming from? Is it because all rules need to be listed? And the ones that are enabled are marked as "Required"? I take we couldn't just avoid listing the other rules (the ones not in docs/misra/rules.rst)? > > Appendix A Summary of guidelines > > Rule 2.1 Required > > All source files shall compile without any compilation errors (Misra rule 2.1) > > Rule 4.7 Required > > If a function returns error information then that error information shall be tested (Misra rule 4.7) > > Rule 4.10 Required > > Precautions shall be taken in order to prevent the contents of a header file being included more than once (Misra rule 4.10) > > Rule 4.14 Required > > The validity of values received from external sources shall be checked (Misra rule 4.14) > > Rule 1.3 Required > > There shall be no occurrence of undefined or critical unspecified behaviour (Misra rule 1.3) > > Rule 3.2 Required > > Line-splicing shall not be used in // comments (Misra rule 3.2) > > Rule 5.1 Required > > External identifiers shall be distinct (Misra rule 5.1) > > Rule 5.2 Required > > Identifiers declared in the same scope and name space shall be distinct (Misra rule 5.2) > > Rule 5.3 Required > > An identifier declared in an inner scope shall not hide an identifier declared in an outer scope (Misra rule 5.3) > > Rule 5.4 Required > > Macro identifiers shall be distinct (Misra rule 5.4) > > Rule 6.2 Required > > Single-bit named bit fields shall not be of a signed type (Misra rule 6.2) > > Rule 8.1 Required > > Types shall be explicitly specified (Misra rule 8.1) > > Rule 8.4 Required > > A compatible declaration shall be visible when an object or function with external linkage is defined (Misra rule 8.4) > > Rule 8.5 Required > > An external object or function shall be declared once in one and only one file (Misra rule 8.5) > > Rule 8.6 Required > > An identifier with external linkage shall have exactly one external definition (Misra rule 8.6) > > Rule 8.8 Required > > The static storage class specifier shall be used in all declarations of objects and functions that have internal linkage (Misra rule 8.8) > > Rule 8.10 Required > > An inline function shall be declared with the static storage class (Misra rule 8.10) > > Rule 8.12 Required > > Within an enumerator list the value of an implicitly-specified enumeration constant shall be unique (Misra rule 8.12) > > Rule 9.1 Mandatory > > The value of an object with automatic storage duration shall not be read before it has been set (Misra rule 9.1) > > Rule 9.2 Required > > The initializer for an aggregate or union shall be enclosed in braces (Misra rule 9.2) > > Rule 13.6 Mandatory > > The operand of the sizeof operator shall not contain any expression which has potential side effects (Misra rule 13.6) > > Rule 14.1 Required > > A loop counter shall not have essentially floating type (Misra rule 14.1) > > Rule 16.7 Required > > A switch-expression shall not have essentially Boolean type (Misra rule 16.7) > > Rule 17.3 Mandatory > > A function shall not be declared implicitly (Misra rule 17.3) > > Rule 17.4 Mandatory > > All exit paths from a function with non-void return type shall have an explicit return statement with an expression (Misra rule 17.4) > > Rule 20.7 Required > > Expressions resulting from the expansion of macro parameters shall be enclosed in parentheses (Misra rule 20.7) > > Rule 20.13 Required > > A line whose first token is # shall be a valid preprocessing directive (Misra rule 20.13) > > Rule 20.14 Required > > All #else #elif and #endif preprocessor directives shall reside in the same file as the #if #ifdef or #ifndef directive to which they are related (Misra rule 20.14) > > Rule 1.1 > > No description for rule 1.1 > > Rule 1.2 > > No description for rule 1.2 > > Rule 1.4 > > No description for rule 1.4 > > Rule 1.5 > > No description for rule 1.5 > > Rule 1.6 > > No description for rule 1.6 > > Rule 1.7 > > No description for rule 1.7 > > Rule 1.8 > > No description for rule 1.8 > > Rule 1.9 > > No description for rule 1.9 > > Rule 1.10 > > No description for rule 1.10 > > Rule 1.11 > > No description for rule 1.11 > > Rule 1.12 > > No description for rule 1.12 > > Rule 1.13 > > No description for rule 1.13 > > Rule 1.14 > > No description for rule 1.14 > > Rule 1.15 > > No description for rule 1.15 > > Rule 1.16 > > No description for rule 1.16 > > Rule 1.17 > > No description for rule 1.17 > > Rule 1.18 > > No description for rule 1.18 > > Rule 1.19 > > No description for rule 1.19 > > Rule 1.20 > > No description for rule 1.20 > > Rule 1.21 > > No description for rule 1.21 > > Rule 2.2 > > No description for rule 2.2 > > Rule 2.3 > > No description for rule 2.3 > > Rule 2.4 > > No description for rule 2.4 > > Rule 2.5 > > No description for rule 2.5 > > Rule 2.6 > > No description for rule 2.6 > > Rule 2.7 > > No description for rule 2.7 > > Rule 2.8 > > No description for rule 2.8 > > Rule 2.9 > > No description for rule 2.9 > > Rule 2.10 > > No description for rule 2.10 > > Rule 2.11 > > No description for rule 2.11 > > Rule 2.12 > > No description for rule 2.12 > > Rule 2.13 > > No description for rule 2.13 > > Rule 2.14 > > No description for rule 2.14 > > Rule 2.15 > > No description for rule 2.15 > > Rule 2.16 > > No description for rule 2.16 > > Rule 2.17 > > No description for rule 2.17 > > Rule 2.18 > > No description for rule 2.18 > > Rule 2.19 > > No description for rule 2.19 > > Rule 2.20 > > No description for rule 2.20 > > Rule 2.21 > > No description for rule 2.21 > > Rule 3.1 > > No description for rule 3.1 > > Rule 3.3 > > No description for rule 3.3 > > Rule 3.4 > > No description for rule 3.4 > > Rule 3.5 > > No description for rule 3.5 > > Rule 3.6 > > No description for rule 3.6 > > Rule 3.7 > > No description for rule 3.7 > > Rule 3.8 > > No description for rule 3.8 > > Rule 3.9 > > No description for rule 3.9 > > Rule 3.10 > > No description for rule 3.10 > > Rule 3.11 > > No description for rule 3.11 > > Rule 3.12 > > No description for rule 3.12 > > Rule 3.13 > > No description for rule 3.13 > > Rule 3.14 > > No description for rule 3.14 > > Rule 3.15 > > No description for rule 3.15 > > Rule 3.16 > > No description for rule 3.16 > > Rule 3.17 > > No description for rule 3.17 > > Rule 3.18 > > No description for rule 3.18 > > Rule 3.19 > > No description for rule 3.19 > > Rule 3.20 > > No description for rule 3.20 > > Rule 3.21 > > No description for rule 3.21 > > Rule 4.1 > > No description for rule 4.1 > > Rule 4.2 > > No description for rule 4.2 > > Rule 4.3 > > No description for rule 4.3 > > Rule 4.4 > > No description for rule 4.4 > > Rule 4.5 > > No description for rule 4.5 > > Rule 4.6 > > No description for rule 4.6 > > Rule 4.8 > > No description for rule 4.8 > > Rule 4.9 > > No description for rule 4.9 > > Rule 4.11 > > No description for rule 4.11 > > Rule 4.12 > > No description for rule 4.12 > > Rule 4.13 > > No description for rule 4.13 > > Rule 4.15 > > No description for rule 4.15 > > Rule 4.16 > > No description for rule 4.16 > > Rule 4.17 > > No description for rule 4.17 > > Rule 4.18 > > No description for rule 4.18 > > Rule 4.19 > > No description for rule 4.19 > > Rule 4.20 > > No description for rule 4.20 > > Rule 4.21 > > No description for rule 4.21 > > Rule 5.5 > > No description for rule 5.5 > > Rule 5.6 > > No description for rule 5.6 > > Rule 5.7 > > No description for rule 5.7 > > Rule 5.8 > > No description for rule 5.8 > > Rule 5.9 > > No description for rule 5.9 > > Rule 5.10 > > No description for rule 5.10 > > Rule 5.11 > > No description for rule 5.11 > > Rule 5.12 > > No description for rule 5.12 > > Rule 5.13 > > No description for rule 5.13 > > Rule 5.14 > > No description for rule 5.14 > > Rule 5.15 > > No description for rule 5.15 > > Rule 5.16 > > No description for rule 5.16 > > Rule 5.17 > > No description for rule 5.17 > > Rule 5.18 > > No description for rule 5.18 > > Rule 5.19 > > No description for rule 5.19 > > Rule 5.20 > > No description for rule 5.20 > > Rule 5.21 > > No description for rule 5.21 > > Rule 6.1 > > No description for rule 6.1 > > Rule 6.3 > > No description for rule 6.3 > > Rule 6.4 > > No description for rule 6.4 > > Rule 6.5 > > No description for rule 6.5 > > Rule 6.6 > > No description for rule 6.6 > > Rule 6.7 > > No description for rule 6.7 > > Rule 6.8 > > No description for rule 6.8 > > Rule 6.9 > > No description for rule 6.9 > > Rule 6.10 > > No description for rule 6.10 > > Rule 6.11 > > No description for rule 6.11 > > Rule 6.12 > > No description for rule 6.12 > > Rule 6.13 > > No description for rule 6.13 > > Rule 6.14 > > No description for rule 6.14 > > Rule 6.15 > > No description for rule 6.15 > > Rule 6.16 > > No description for rule 6.16 > > Rule 6.17 > > No description for rule 6.17 > > Rule 6.18 > > No description for rule 6.18 > > Rule 6.19 > > No description for rule 6.19 > > Rule 6.20 > > No description for rule 6.20 > > Rule 6.21 > > No description for rule 6.21 > > Rule 7.1 > > No description for rule 7.1 > > Rule 7.2 > > No description for rule 7.2 > > Rule 7.3 > > No description for rule 7.3 > > Rule 7.4 > > No description for rule 7.4 > > Rule 7.5 > > No description for rule 7.5 > > Rule 7.6 > > No description for rule 7.6 > > Rule 7.7 > > No description for rule 7.7 > > Rule 7.8 > > No description for rule 7.8 > > Rule 7.9 > > No description for rule 7.9 > > Rule 7.10 > > No description for rule 7.10 > > Rule 7.11 > > No description for rule 7.11 > > Rule 7.12 > > No description for rule 7.12 > > Rule 7.13 > > No description for rule 7.13 > > Rule 7.14 > > No description for rule 7.14 > > Rule 7.15 > > No description for rule 7.15 > > Rule 7.16 > > No description for rule 7.16 > > Rule 7.17 > > No description for rule 7.17 > > Rule 7.18 > > No description for rule 7.18 > > Rule 7.19 > > No description for rule 7.19 > > Rule 7.20 > > No description for rule 7.20 > > Rule 7.21 > > No description for rule 7.21 > > Rule 8.2 > > No description for rule 8.2 > > Rule 8.3 > > No description for rule 8.3 > > Rule 8.7 > > No description for rule 8.7 > > Rule 8.9 > > No description for rule 8.9 > > Rule 8.11 > > No description for rule 8.11 > > Rule 8.13 > > No description for rule 8.13 > > Rule 8.14 > > No description for rule 8.14 > > Rule 8.15 > > No description for rule 8.15 > > Rule 8.16 > > No description for rule 8.16 > > Rule 8.17 > > No description for rule 8.17 > > Rule 8.18 > > No description for rule 8.18 > > Rule 8.19 > > No description for rule 8.19 > > Rule 8.20 > > No description for rule 8.20 > > Rule 8.21 > > No description for rule 8.21 > > Rule 9.3 > > No description for rule 9.3 > > Rule 9.4 > > No description for rule 9.4 > > Rule 9.5 > > No description for rule 9.5 > > Rule 9.6 > > No description for rule 9.6 > > Rule 9.7 > > No description for rule 9.7 > > Rule 9.8 > > No description for rule 9.8 > > Rule 9.9 > > No description for rule 9.9 > > Rule 9.10 > > No description for rule 9.10 > > Rule 9.11 > > No description for rule 9.11 > > Rule 9.12 > > No description for rule 9.12 > > Rule 9.13 > > No description for rule 9.13 > > Rule 9.14 > > No description for rule 9.14 > > Rule 9.15 > > No description for rule 9.15 > > Rule 9.16 > > No description for rule 9.16 > > Rule 9.17 > > No description for rule 9.17 > > Rule 9.18 > > No description for rule 9.18 > > Rule 9.19 > > No description for rule 9.19 > > Rule 9.20 > > No description for rule 9.20 > > Rule 9.21 > > No description for rule 9.21 > > Rule 10.1 > > No description for rule 10.1 > > Rule 10.2 > > No description for rule 10.2 > > Rule 10.3 > > No description for rule 10.3 > > Rule 10.4 > > No description for rule 10.4 > > Rule 10.5 > > No description for rule 10.5 > > Rule 10.6 > > No description for rule 10.6 > > Rule 10.7 > > No description for rule 10.7 > > Rule 10.8 > > No description for rule 10.8 > > Rule 10.9 > > No description for rule 10.9 > > Rule 10.10 > > No description for rule 10.10 > > Rule 10.11 > > No description for rule 10.11 > > Rule 10.12 > > No description for rule 10.12 > > Rule 10.13 > > No description for rule 10.13 > > Rule 10.14 > > No description for rule 10.14 > > Rule 10.15 > > No description for rule 10.15 > > Rule 10.16 > > No description for rule 10.16 > > Rule 10.17 > > No description for rule 10.17 > > Rule 10.18 > > No description for rule 10.18 > > Rule 10.19 > > No description for rule 10.19 > > Rule 10.20 > > No description for rule 10.20 > > Rule 10.21 > > No description for rule 10.21 > > Rule 11.1 > > No description for rule 11.1 > > Rule 11.2 > > No description for rule 11.2 > > Rule 11.3 > > No description for rule 11.3 > > Rule 11.4 > > No description for rule 11.4 > > Rule 11.5 > > No description for rule 11.5 > > Rule 11.6 > > No description for rule 11.6 > > Rule 11.7 > > No description for rule 11.7 > > Rule 11.8 > > No description for rule 11.8 > > Rule 11.9 > > No description for rule 11.9 > > Rule 11.10 > > No description for rule 11.10 > > Rule 11.11 > > No description for rule 11.11 > > Rule 11.12 > > No description for rule 11.12 > > Rule 11.13 > > No description for rule 11.13 > > Rule 11.14 > > No description for rule 11.14 > > Rule 11.15 > > No description for rule 11.15 > > Rule 11.16 > > No description for rule 11.16 > > Rule 11.17 > > No description for rule 11.17 > > Rule 11.18 > > No description for rule 11.18 > > Rule 11.19 > > No description for rule 11.19 > > Rule 11.20 > > No description for rule 11.20 > > Rule 11.21 > > No description for rule 11.21 > > Rule 12.1 > > No description for rule 12.1 > > Rule 12.2 > > No description for rule 12.2 > > Rule 12.3 > > No description for rule 12.3 > > Rule 12.4 > > No description for rule 12.4 > > Rule 12.5 > > No description for rule 12.5 > > Rule 12.6 > > No description for rule 12.6 > > Rule 12.7 > > No description for rule 12.7 > > Rule 12.8 > > No description for rule 12.8 > > Rule 12.9 > > No description for rule 12.9 > > Rule 12.10 > > No description for rule 12.10 > > Rule 12.11 > > No description for rule 12.11 > > Rule 12.12 > > No description for rule 12.12 > > Rule 12.13 > > No description for rule 12.13 > > Rule 12.14 > > No description for rule 12.14 > > Rule 12.15 > > No description for rule 12.15 > > Rule 12.16 > > No description for rule 12.16 > > Rule 12.17 > > No description for rule 12.17 > > Rule 12.18 > > No description for rule 12.18 > > Rule 12.19 > > No description for rule 12.19 > > Rule 12.20 > > No description for rule 12.20 > > Rule 12.21 > > No description for rule 12.21 > > Rule 13.1 > > No description for rule 13.1 > > Rule 13.2 > > No description for rule 13.2 > > Rule 13.3 > > No description for rule 13.3 > > Rule 13.4 > > No description for rule 13.4 > > Rule 13.5 > > No description for rule 13.5 > > Rule 13.7 > > No description for rule 13.7 > > Rule 13.8 > > No description for rule 13.8 > > Rule 13.9 > > No description for rule 13.9 > > Rule 13.10 > > No description for rule 13.10 > > Rule 13.11 > > No description for rule 13.11 > > Rule 13.12 > > No description for rule 13.12 > > Rule 13.13 > > No description for rule 13.13 > > Rule 13.14 > > No description for rule 13.14 > > Rule 13.15 > > No description for rule 13.15 > > Rule 13.16 > > No description for rule 13.16 > > Rule 13.17 > > No description for rule 13.17 > > Rule 13.18 > > No description for rule 13.18 > > Rule 13.19 > > No description for rule 13.19 > > Rule 13.20 > > No description for rule 13.20 > > Rule 13.21 > > No description for rule 13.21 > > Rule 14.2 > > No description for rule 14.2 > > Rule 14.3 > > No description for rule 14.3 > > Rule 14.4 > > No description for rule 14.4 > > Rule 14.5 > > No description for rule 14.5 > > Rule 14.6 > > No description for rule 14.6 > > Rule 14.7 > > No description for rule 14.7 > > Rule 14.8 > > No description for rule 14.8 > > Rule 14.9 > > No description for rule 14.9 > > Rule 14.10 > > No description for rule 14.10 > > Rule 14.11 > > No description for rule 14.11 > > Rule 14.12 > > No description for rule 14.12 > > Rule 14.13 > > No description for rule 14.13 > > Rule 14.14 > > No description for rule 14.14 > > Rule 14.15 > > No description for rule 14.15 > > Rule 14.16 > > No description for rule 14.16 > > Rule 14.17 > > No description for rule 14.17 > > Rule 14.18 > > No description for rule 14.18 > > Rule 14.19 > > No description for rule 14.19 > > Rule 14.20 > > No description for rule 14.20 > > Rule 14.21 > > No description for rule 14.21 > > Rule 15.1 > > No description for rule 15.1 > > Rule 15.2 > > No description for rule 15.2 > > Rule 15.3 > > No description for rule 15.3 > > Rule 15.4 > > No description for rule 15.4 > > Rule 15.5 > > No description for rule 15.5 > > Rule 15.6 > > No description for rule 15.6 > > Rule 15.7 > > No description for rule 15.7 > > Rule 15.8 > > No description for rule 15.8 > > Rule 15.9 > > No description for rule 15.9 > > Rule 15.10 > > No description for rule 15.10 > > Rule 15.11 > > No description for rule 15.11 > > Rule 15.12 > > No description for rule 15.12 > > Rule 15.13 > > No description for rule 15.13 > > Rule 15.14 > > No description for rule 15.14 > > Rule 15.15 > > No description for rule 15.15 > > Rule 15.16 > > No description for rule 15.16 > > Rule 15.17 > > No description for rule 15.17 > > Rule 15.18 > > No description for rule 15.18 > > Rule 15.19 > > No description for rule 15.19 > > Rule 15.20 > > No description for rule 15.20 > > Rule 15.21 > > No description for rule 15.21 > > Rule 16.1 > > No description for rule 16.1 > > Rule 16.2 > > No description for rule 16.2 > > Rule 16.3 > > No description for rule 16.3 > > Rule 16.4 > > No description for rule 16.4 > > Rule 16.5 > > No description for rule 16.5 > > Rule 16.6 > > No description for rule 16.6 > > Rule 16.8 > > No description for rule 16.8 > > Rule 16.9 > > No description for rule 16.9 > > Rule 16.10 > > No description for rule 16.10 > > Rule 16.11 > > No description for rule 16.11 > > Rule 16.12 > > No description for rule 16.12 > > Rule 16.13 > > No description for rule 16.13 > > Rule 16.14 > > No description for rule 16.14 > > Rule 16.15 > > No description for rule 16.15 > > Rule 16.16 > > No description for rule 16.16 > > Rule 16.17 > > No description for rule 16.17 > > Rule 16.18 > > No description for rule 16.18 > > Rule 16.19 > > No description for rule 16.19 > > Rule 16.20 > > No description for rule 16.20 > > Rule 16.21 > > No description for rule 16.21 > > Rule 17.1 > > No description for rule 17.1 > > Rule 17.2 > > No description for rule 17.2 > > Rule 17.5 > > No description for rule 17.5 > > Rule 17.6 > > No description for rule 17.6 > > Rule 17.7 > > No description for rule 17.7 > > Rule 17.8 > > No description for rule 17.8 > > Rule 17.9 > > No description for rule 17.9 > > Rule 17.10 > > No description for rule 17.10 > > Rule 17.11 > > No description for rule 17.11 > > Rule 17.12 > > No description for rule 17.12 > > Rule 17.13 > > No description for rule 17.13 > > Rule 17.14 > > No description for rule 17.14 > > Rule 17.15 > > No description for rule 17.15 > > Rule 17.16 > > No description for rule 17.16 > > Rule 17.17 > > No description for rule 17.17 > > Rule 17.18 > > No description for rule 17.18 > > Rule 17.19 > > No description for rule 17.19 > > Rule 17.20 > > No description for rule 17.20 > > Rule 17.21 > > No description for rule 17.21 > > Rule 18.1 > > No description for rule 18.1 > > Rule 18.2 > > No description for rule 18.2 > > Rule 18.3 > > No description for rule 18.3 > > Rule 18.4 > > No description for rule 18.4 > > Rule 18.5 > > No description for rule 18.5 > > Rule 18.6 > > No description for rule 18.6 > > Rule 18.7 > > No description for rule 18.7 > > Rule 18.8 > > No description for rule 18.8 > > Rule 18.9 > > No description for rule 18.9 > > Rule 18.10 > > No description for rule 18.10 > > Rule 18.11 > > No description for rule 18.11 > > Rule 18.12 > > No description for rule 18.12 > > Rule 18.13 > > No description for rule 18.13 > > Rule 18.14 > > No description for rule 18.14 > > Rule 18.15 > > No description for rule 18.15 > > Rule 18.16 > > No description for rule 18.16 > > Rule 18.17 > > No description for rule 18.17 > > Rule 18.18 > > No description for rule 18.18 > > Rule 18.19 > > No description for rule 18.19 > > Rule 18.20 > > No description for rule 18.20 > > Rule 18.21 > > No description for rule 18.21 > > Rule 19.1 > > No description for rule 19.1 > > Rule 19.2 > > No description for rule 19.2 > > Rule 19.3 > > No description for rule 19.3 > > Rule 19.4 > > No description for rule 19.4 > > Rule 19.5 > > No description for rule 19.5 > > Rule 19.6 > > No description for rule 19.6 > > Rule 19.7 > > No description for rule 19.7 > > Rule 19.8 > > No description for rule 19.8 > > Rule 19.9 > > No description for rule 19.9 > > Rule 19.10 > > No description for rule 19.10 > > Rule 19.11 > > No description for rule 19.11 > > Rule 19.12 > > No description for rule 19.12 > > Rule 19.13 > > No description for rule 19.13 > > Rule 19.14 > > No description for rule 19.14 > > Rule 19.15 > > No description for rule 19.15 > > Rule 19.16 > > No description for rule 19.16 > > Rule 19.17 > > No description for rule 19.17 > > Rule 19.18 > > No description for rule 19.18 > > Rule 19.19 > > No description for rule 19.19 > > Rule 19.20 > > No description for rule 19.20 > > Rule 19.21 > > No description for rule 19.21 > > Rule 20.1 > > No description for rule 20.1 > > Rule 20.2 > > No description for rule 20.2 > > Rule 20.3 > > No description for rule 20.3 > > Rule 20.4 > > No description for rule 20.4 > > Rule 20.5 > > No description for rule 20.5 > > Rule 20.6 > > No description for rule 20.6 > > Rule 20.8 > > No description for rule 20.8 > > Rule 20.9 > > No description for rule 20.9 > > Rule 20.10 > > No description for rule 20.10 > > Rule 20.11 > > No description for rule 20.11 > > Rule 20.12 > > No description for rule 20.12 > > Rule 20.15 > > No description for rule 20.15 > > Rule 20.16 > > No description for rule 20.16 > > Rule 20.17 > > No description for rule 20.17 > > Rule 20.18 > > No description for rule 20.18 > > Rule 20.19 > > No description for rule 20.19 > > Rule 20.20 > > No description for rule 20.20 > > Rule 20.21 > > No description for rule 20.21 > > Rule 21.1 > > No description for rule 21.1 > > Rule 21.2 > > No description for rule 21.2 > > Rule 21.3 > > No description for rule 21.3 > > Rule 21.4 > > No description for rule 21.4 > > Rule 21.5 > > No description for rule 21.5 > > Rule 21.6 > > No description for rule 21.6 > > Rule 21.7 > > No description for rule 21.7 > > Rule 21.8 > > No description for rule 21.8 > > Rule 21.9 > > No description for rule 21.9 > > Rule 21.10 > > No description for rule 21.10 > > Rule 21.11 > > No description for rule 21.11 > > Rule 21.12 > > No description for rule 21.12 > > Rule 21.13 > > No description for rule 21.13 > > Rule 21.14 > > No description for rule 21.14 > > Rule 21.15 > > No description for rule 21.15 > > Rule 21.16 > > No description for rule 21.16 > > Rule 21.17 > > No description for rule 21.17 > > Rule 21.18 > > No description for rule 21.18 > > Rule 21.19 > > No description for rule 21.19 > > Rule 21.20 > > No description for rule 21.20 > > Rule 21.21 > > No description for rule 21.21 > > Appendix B >
Hi Stefano, > On 22 Jun 2022, at 22:52, Stefano Stabellini <sstabellini@kernel.org> wrote: > > On Wed, 22 Jun 2022, Bertrand Marquis wrote: >> Hi Stefano, >> >>> On 22 Jun 2022, at 01:00, Stefano Stabellini <sstabellini@kernel.org> wrote: >>> >>> On Fri, 10 Jun 2022, Bertrand Marquis wrote: >>>> cppcheck MISRA addon can be used to check for non compliance to some of >>>> the MISRA standard rules. >>>> >>>> Add a CPPCHECK_MISRA variable that can be set to "y" using make command >>>> line to generate a cppcheck report including cppcheck misra checks. >>>> >>>> When MISRA checking is enabled, a file with a text description suitable >>>> for cppcheck misra addon is generated out of Xen documentation file >>>> which lists the rules followed by Xen (docs/misra/rules.rst). >>>> >>>> By default MISRA checking is turned off. >>>> >>>> While adding cppcheck-misra files to gitignore, also fix the missing / >>>> for htmlreport gitignore >>>> >>>> Signed-off-by: Bertrand Marquis <bertrand.marquis@arm.com> >>> >>> Hi Bertrand, >>> >>> I tried this patch and I am a bit confused by the output >>> cppcheck-misra.txt file that I get (appended.) >>> >>> I can see that there are all the rules from docs/misra/rules.rst as it >>> should be together with the one line summary, but there are also a bunch >>> of additional rules not present in docs/misra/rules.rst. Starting from >>> Rule 1.1 all the way to Rule 21.21. Is the expected? >> >> To make cppcheck happy I need to give a text for all rules so the python script is generating a dummy sentence for not declared Misra rules to prevent cppcheck warnings. To make it simpler I just did it for 1 to 22 for main and sub numbers. >> >> So yes this is expected. > > No problem about the dummy text sentence. My question was why are all > those additional rules listed? > > If you see below, the first few rules from 2.1 to 20.14 are coming from > docs/misra/rules.rst. Why are the other rules afterward from 1.1 to > 21.21 listed and where are they coming from? Those are dummy entries generated by the python script. > > Is it because all rules need to be listed? And the ones that are enabled > are marked as "Required"? If a rule is not listed in the file, cppcheck will give a warning. > > I take we couldn't just avoid listing the other rules (the ones not in > docs/misra/rules.rst)? I can but each cppcheck command will output a warning for each rule which has no description in the generated file. Cheers Bertrand
On Thu, 23 Jun 2022, Bertrand Marquis wrote: > > On 22 Jun 2022, at 22:52, Stefano Stabellini <sstabellini@kernel.org> wrote: > > > > On Wed, 22 Jun 2022, Bertrand Marquis wrote: > >> Hi Stefano, > >> > >>> On 22 Jun 2022, at 01:00, Stefano Stabellini <sstabellini@kernel.org> wrote: > >>> > >>> On Fri, 10 Jun 2022, Bertrand Marquis wrote: > >>>> cppcheck MISRA addon can be used to check for non compliance to some of > >>>> the MISRA standard rules. > >>>> > >>>> Add a CPPCHECK_MISRA variable that can be set to "y" using make command > >>>> line to generate a cppcheck report including cppcheck misra checks. > >>>> > >>>> When MISRA checking is enabled, a file with a text description suitable > >>>> for cppcheck misra addon is generated out of Xen documentation file > >>>> which lists the rules followed by Xen (docs/misra/rules.rst). > >>>> > >>>> By default MISRA checking is turned off. > >>>> > >>>> While adding cppcheck-misra files to gitignore, also fix the missing / > >>>> for htmlreport gitignore > >>>> > >>>> Signed-off-by: Bertrand Marquis <bertrand.marquis@arm.com> > >>> > >>> Hi Bertrand, > >>> > >>> I tried this patch and I am a bit confused by the output > >>> cppcheck-misra.txt file that I get (appended.) > >>> > >>> I can see that there are all the rules from docs/misra/rules.rst as it > >>> should be together with the one line summary, but there are also a bunch > >>> of additional rules not present in docs/misra/rules.rst. Starting from > >>> Rule 1.1 all the way to Rule 21.21. Is the expected? > >> > >> To make cppcheck happy I need to give a text for all rules so the python script is generating a dummy sentence for not declared Misra rules to prevent cppcheck warnings. To make it simpler I just did it for 1 to 22 for main and sub numbers. > >> > >> So yes this is expected. > > > > No problem about the dummy text sentence. My question was why are all > > those additional rules listed? > > > > If you see below, the first few rules from 2.1 to 20.14 are coming from > > docs/misra/rules.rst. Why are the other rules afterward from 1.1 to > > 21.21 listed and where are they coming from? > > Those are dummy entries generated by the python script. > > > > > Is it because all rules need to be listed? And the ones that are enabled > > are marked as "Required"? > > If a rule is not listed in the file, cppcheck will give a warning. > > > > > I take we couldn't just avoid listing the other rules (the ones not in > > docs/misra/rules.rst)? > > I can but each cppcheck command will output a warning for each rule which has no description in the generated file. No, that makes sense. It is to silence a warning. Maybe explain this in the commit message and add my Acked-by: Stefano Stabellini <sstabellini@kernel.org>
diff --git a/.gitignore b/.gitignore index 18ef56a780..c9951063c3 100644 --- a/.gitignore +++ b/.gitignore @@ -297,7 +297,6 @@ xen/.banner xen/.config xen/.config.old xen/.xen.elf32 -xen/xen-cppcheck.xml xen/System.map xen/arch/x86/boot/mkelf32 xen/arch/x86/boot/cmdline.S @@ -318,7 +317,8 @@ xen/arch/*/efi/runtime.c xen/arch/*/include/asm/asm-offsets.h xen/common/config_data.S xen/common/config.gz -xen/cppcheck-htmlreport +xen/cppcheck-htmlreport/ +xen/cppcheck-misra.* xen/include/headers*.chk xen/include/compat/* xen/include/config/ @@ -347,6 +347,7 @@ xen/xsm/flask/xenpolicy-* tools/flask/policy/policy.conf tools/flask/policy/xenpolicy-* xen/xen +xen/xen-cppcheck.xml xen/xen-syms xen/xen-syms.map xen/xen.* diff --git a/xen/Makefile b/xen/Makefile index 82f5310b12..a4dce29efd 100644 --- a/xen/Makefile +++ b/xen/Makefile @@ -548,7 +548,7 @@ _clean: rm -f include/asm $(TARGET) $(TARGET).gz $(TARGET).efi $(TARGET).efi.map $(TARGET)-syms $(TARGET)-syms.map rm -f asm-offsets.s arch/*/include/asm/asm-offsets.h rm -f .banner .allconfig.tmp include/xen/compile.h - rm -f xen-cppcheck.xml + rm -f cppcheck-misra.* xen-cppcheck.xml .PHONY: _distclean _distclean: clean @@ -642,6 +642,10 @@ CPPCHECK_HTMLREPORT ?= cppcheck-htmlreport # build directory. This can be changed by giving a directory in this variable. CPPCHECK_HTMLREPORT_OUTDIR ?= cppcheck-htmlreport +# By default we do not check misra rules, to enable pass "CPPCHECK_MISRA=y" to +# make command line. +CPPCHECK_MISRA ?= n + # Compile flags to pass to cppcheck: # - include directories and defines Xen Makefile is passing (from CFLAGS) # - include config.h as this is passed directly to the compiler. @@ -666,6 +670,15 @@ CPPCHECKFILES := $(wildcard $(patsubst $(objtree)/%.o,$(srctree)/%.c, \ $(filter-out $(objtree)/tools/%, \ $(shell find $(objtree) -name "*.o")))) +# Headers and files required to run cppcheck on a file +CPPCHECKDEPS := $(objtree)/include/generated/autoconf.h \ + $(objtree)/include/generated/compiler-def.h + +ifeq ($(CPPCHECK_MISRA),y) + CPPCHECKFLAGS += --addon=cppcheck-misra.json + CPPCHECKDEPS += cppcheck-misra.json +endif + quiet_cmd_cppcheck_xml = CPPCHECK $(patsubst $(srctree)/%,%,$<) cmd_cppcheck_xml = $(CPPCHECK) -v -q --xml $(CPPCHECKFLAGS) \ --output-file=$@ $< @@ -690,7 +703,7 @@ ifeq ($(CPPCHECKFILES),) endif $(call if_changed,merge_cppcheck_reports) -$(objtree)/%.c.cppcheck: $(srctree)/%.c $(objtree)/include/generated/autoconf.h $(objtree)/include/generated/compiler-def.h | cppcheck-version +$(objtree)/%.c.cppcheck: $(srctree)/%.c $(CPPCHECKDEPS) | cppcheck-version $(call if_changed,cppcheck_xml) cppcheck-version: @@ -703,6 +716,18 @@ cppcheck-version: exit 1; \ fi +# List of Misra rules to respect is written inside a doc. +# In order to have some helpful text in the cppcheck output, generate a text +# file containing the rules identifier, classification and text from the Xen +# documentation file. Also generate a json file with the right arguments for +# cppcheck in json format including the list of rules to ignore. +# +cppcheck-misra.txt: $(XEN_ROOT)/docs/misra/rules.rst $(srctree)/tools/convert_misra_doc.py + $(Q)$(srctree)/tools/convert_misra_doc.py -i $< -o $@ -j $(@:.txt=.json) + +# convert_misra_doc is generating both files. +cppcheck-misra.json: cppcheck-misra.txt + # Put this in generated headers this way it is cleaned by include/Makefile $(objtree)/include/generated/compiler-def.h: $(Q)$(CC) -dM -E -o $@ - < /dev/null diff --git a/xen/tools/convert_misra_doc.py b/xen/tools/convert_misra_doc.py new file mode 100755 index 0000000000..caa4487f64 --- /dev/null +++ b/xen/tools/convert_misra_doc.py @@ -0,0 +1,173 @@ +#!/usr/bin/env python + +""" +This script is converting the misra documentation RST file into a text file +that can be used as text-rules for cppcheck. +Usage: + convert_misr_doc.py -i INPUT [-o OUTPUT] [-j JSON] + + INPUT - RST file containing the list of misra rules. + OUTPUT - file to store the text output to be used by cppcheck. + If not specified, the result will be printed to stdout. + JSON - cppcheck json file to be created (optional). +""" + +import sys, getopt, re + +def main(argv): + infile = '' + outfile = '' + outstr = sys.stdout + jsonfile = '' + + try: + opts, args = getopt.getopt(argv,"hi:o:j:",["input=","output=","json="]) + except getopt.GetoptError: + print('convert-misra.py -i <input> [-o <output>] [-j <json>') + sys.exit(2) + for opt, arg in opts: + if opt == '-h': + print('convert-misra.py -i <input> [-o <output>] [-j <json>') + print(' If output is not specified, print to stdout') + sys.exit(1) + elif opt in ("-i", "--input"): + infile = arg + elif opt in ("-o", "--output"): + outfile = arg + elif opt in ("-j", "--json"): + jsonfile = arg + + try: + file_stream = open(infile, 'rt') + except: + print('Error opening ' + infile) + sys.exit(1) + + if outfile: + try: + outstr = open(outfile, "w") + except: + print('Error creating ' + outfile) + sys.exit(1) + + # Each rule start with ' * - `[Dir|Rule]' and is followed by the + # severity, the summary and then notes + # Only the summary can be multi line + pattern_dir = re.compile(r'^ \* - `Dir ([0-9]+.[0-9]+).*$') + pattern_rule = re.compile(r'^ \* - `Rule ([0-9]+.[0-9]+).*$') + pattern_col = re.compile(r'^ - (.*)$') + # allow empty notes + pattern_notes = re.compile(r'^ -.*$') + pattern_cont = re.compile(r'^ (.*)$') + + rule_number = '' + rule_severity = '' + rule_summary = '' + rule_state = 0 + rule_list = [] + + # Start search by cppcheck misra + outstr.write('Appendix A Summary of guidelines\n') + + for line in file_stream: + + line = line.replace('\r', '').replace('\n', '') + + if len(line) == 0: + continue + + # New Rule or Directive + if rule_state == 0: + # new Rule + res = pattern_rule.match(line) + if res: + rule_number = res.group(1) + rule_list.append(rule_number) + rule_state = 1 + continue + + # new Directive + res = pattern_dir.match(line) + if res: + rule_number = res.group(1) + rule_list.append(rule_number) + rule_state = 1 + continue + continue + + # Severity + elif rule_state == 1: + res =pattern_col.match(line) + if res: + rule_severity = res.group(1) + rule_state = 2 + continue + + print('No severity for rule ' + rule_number) + sys.exit(1) + + # Summary + elif rule_state == 2: + res = pattern_col.match(line) + if res: + rule_summary = res.group(1) + rule_state = 3 + continue + + print('No summary for rule ' + rule_number) + sys.exit(1) + + # Notes or summary continuation + elif rule_state == 3: + res = pattern_cont.match(line) + if res: + rule_summary += res.group(1) + continue + res = pattern_notes.match(line) + if res: + outstr.write('Rule ' + rule_number + ' ' + rule_severity + + '\n') + outstr.write(rule_summary + ' (Misra rule ' + rule_number + + ')\n') + rule_state = 0 + rule_number = '' + continue + print('No notes for rule ' + rule_number) + sys.exit(1) + + else: + print('Impossible case in state machine') + sys.exit(1) + + 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)): + 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) + + '\n') + skip_list.append(str(i) + '.' + str(j)) + + # Make cppcheck happy by starting the appendix + outstr.write('Appendix B\n') + outstr.write('\n') + if outfile: + outstr.close() + + if jsonfile: + with open(jsonfile, "w") as f: + f.write('{\n') + f.write(' "script": "misra.py",\n') + f.write(' "args": [\n') + if outfile: + f.write(' "--rule-texts=' + outfile + '",\n') + + f.write(' "--suppress-rules=' + ",".join(skip_list) + '"\n') + f.write(' ]\n') + f.write('}\n') + f.close() + +if __name__ == "__main__": + main(sys.argv[1:])
cppcheck MISRA addon can be used to check for non compliance to some of the MISRA standard rules. Add a CPPCHECK_MISRA variable that can be set to "y" using make command line to generate a cppcheck report including cppcheck misra checks. When MISRA checking is enabled, a file with a text description suitable for cppcheck misra addon is generated out of Xen documentation file which lists the rules followed by Xen (docs/misra/rules.rst). By default MISRA checking is turned off. While adding cppcheck-misra files to gitignore, also fix the missing / for htmlreport gitignore Signed-off-by: Bertrand Marquis <bertrand.marquis@arm.com> --- Changes in v3: - fix .gitignore order for cppcheck entries - adapt python script to new rules.rst format Changes in v2: - fix missing / for htmlreport - use wildcard for cppcheck-misra remove and gitignore - fix comment in makefile - fix dependencies for generation of json and txt file --- .gitignore | 5 +- xen/Makefile | 29 +++++- xen/tools/convert_misra_doc.py | 173 +++++++++++++++++++++++++++++++++ 3 files changed, 203 insertions(+), 4 deletions(-) create mode 100755 xen/tools/convert_misra_doc.py