From: Stefano Stabellini Date: Fri, 10 Jun 2022 21:27:55 +0000 (-0700) Subject: add more MISRA C rules to docs/misra/rules.rst X-Git-Tag: archive/raspbian/4.17.0-1+rpi1^2~33^2~564 X-Git-Url: https://dgit.raspbian.org/?a=commitdiff_plain;h=162dea4e768b835114c736cfd3fa1fc3742d39c5;p=xen.git add more MISRA C rules to docs/misra/rules.rst Add the new MISRA C rules agreed by the MISRA C working group to docs/misra/rules.rst. Signed-off-by: Stefano Stabellini Reviewed-by: Bertrand Marquis Acked-by: Julien Grall Acked-by: Roger Pau Monné --- diff --git a/docs/misra/rules.rst b/docs/misra/rules.rst index 6ccff07765..8a659d8d47 100644 --- a/docs/misra/rules.rst +++ b/docs/misra/rules.rst @@ -89,6 +89,29 @@ existing codebase are work-in-progress. (xen/include/public/) are allowed to retain longer identifiers for backward compatibility. + * - `Rule 5.2 `_ + - Required + - Identifiers declared in the same scope and name space shall be + distinct + - The Xen characters limit for identifiers is 40. Public headers + (xen/include/public/) are allowed to retain longer identifiers + for backward compatibility. + + * - `Rule 5.3 `_ + - Required + - An identifier declared in an inner scope shall not hide an + identifier declared in an outer scope + - Using macros as macro parameters at invocation time is allowed + even if both macros use identically named local variables, e.g. + max(var0, min(var1, var2)) + + * - `Rule 5.4 `_ + - Required + - Macro identifiers shall be distinct + - The Xen characters limit for macro identifiers is 40. Public + headers (xen/include/public/) are allowed to retain longer + identifiers for backward compatibility. + * - `Rule 6.2 `_ - Required - Single-bit named bit fields shall not be of a signed type @@ -123,8 +146,75 @@ existing codebase are work-in-progress. declarations of objects and functions that have internal linkage - + * - `Rule 8.10 `_ + - Required + - An inline function shall be declared with the static storage class + - gnu_inline (without static) is allowed. + * - `Rule 8.12 `_ - Required - Within an enumerator list the value of an implicitly-specified enumeration constant shall be unique - + + * - `Rule 9.1 `_ + - Mandatory + - The value of an object with automatic storage duration shall not + be read before it has been set + - Rule clarification: do not use variables before they are + initialized. An explicit initializer is not necessarily required. + Try reducing the scope of the variable. If an explicit + initializer is added, consider initializing the variable to a + poison value. + + * - `Rule 9.2 `_ + - Required + - The initializer for an aggregate or union shall be enclosed in + braces + - + + * - `Rule 13.6 `_ + - Mandatory + - The operand of the sizeof operator shall not contain any + expression which has potential side effects + - + + * - `Rule 14.1 `_ + - Required + - A loop counter shall not have essentially floating type + - + + * - `Rule 16.7 `_ + - Required + - A switch-expression shall not have essentially Boolean type + - + + * - `Rule 17.3 `_ + - Mandatory + - A function shall not be declared implicitly + - + + * - `Rule 17.4 `_ + - Mandatory + - All exit paths from a function with non-void return type shall + have an explicit return statement with an expression + - + + * - `Rule 20.7 `_ + - Required + - Expressions resulting from the expansion of macro parameters + shall be enclosed in parentheses + - + + * - `Rule 20.13 `_ + - Required + - A line whose first token is # shall be a valid preprocessing + directive + - + + * - `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 + -