MISRA C 2012 Mapping to Codesonar®
Total Page:16
File Type:pdf, Size:1020Kb
MISRA C 2012 Mapping to CodeSonar® Relationship CodeSonar Class Category ID Category Name CodeSonar Class Mnemonic Type (category Name to class) Language extensions should Misra2012:1.2 LANG.COMM.CPP C++ Comment in C closely mapped not be used Language extensions should Misra2012:1.2 LANG.EXT.GNU GNU Extension closely mapped not be used Language extensions should Misra2012:1.2 LANG.EXT.TYPEOF GNU Typeof closely mapped not be used Language extensions should Misra2012:1.2 LANG.EXT.MS Microsoft Extension closely mapped not be used A project shall not contain Misra2012:2.1 LANG.STRUCT.UC Unreachable Call closely mapped unreachable code A project shall not contain Unreachable Misra2012:2.1 LANG.STRUCT.UC closely mapped unreachable code Computation A project shall not contain Unreachable Misra2012:2.1 LANG.STRUCT.UC closely mapped unreachable code Conditional A project shall not contain Unreachable Control Misra2012:2.1 LANG.STRUCT.UC closely mapped unreachable code Flow A project shall not contain Unreachable Data Misra2012:2.1 LANG.STRUCT.UC closely mapped unreachable code Flow Function Call Has Misra2012:2.2 There shall be no dead code MISC.NOEFFECT closely mapped No Effect Misra2012:2.2 There shall be no dead code LANG.STRUCT.UUVAL Unused Value closely mapped Misra2012:2.2 There shall be no dead code LANG.STRUCT.UA Useless Assignment closely mapped A project should not contain Misra2012:2.3 LANG.STRUCT.UUTYPE Unused Type closely mapped unused type declarations A project should not contain Misra2012:2.4 LANG.STRUCT.UUTAG Unused Tag closely mapped unused tag declarations A project should not contain Misra2012:2.5 LANG.STRUCT.UUMACRO Unused Macro closely mapped unused macro declarations A function should not contain Misra2012:2.6 LANG.STRUCT.UULABEL Unused Label closely mapped unused label declarations There should be no unused Misra2012:2.7 LANG.STRUCT.UUPARAM Unused Parameter closely mapped parameters in functions The character sequences /* Misra2012:3.1 and // shall not be used within LANG.COMM.NEST.CSTYLE /* in Comment closely mapped a comment The character sequences /* LANG.COMM.NEST.CPPSTYL Misra2012:3.1 and // shall not be used within // in Comment closely mapped E a comment Line-splicing shall not be Line Splicing in Misra2012:3.2 LANG.COMM.SPLICE closely mapped used in // comments Comment Misra2012:4.2 Trigraphs should not be used LANG.STRUCT.TRIGRAPH Trigraph closely mapped Non-distinct External identifiers shall be Misra2012:5.1 LANG.ID.ND.EXT Identifiers: External closely mapped distinct Names Identifiers declared in the Non-distinct Misra2012:5.2 same scope and name space LANG.ID.ND.SS Identifiers: Same closely mapped shall be distinct Scope GrammaTech Confidential and Proprietary. CodeSonar is a registered trademark of GrammaTech, Inc. MISRA C 2012 Mapping to CodeSonar® An identifier declared in an Non-distinct inner scope shall not hide an Misra2012:5.3 LANG.ID.ND.NEST Identifiers: Nested closely mapped identifier declared in an outer Scope scope Non-distinct Macro identifiers shall be Misra2012:5.4 LANG.ID.ND.MM Identifiers: closely mapped distinct Macro/Macro Non-distinct Identifiers shall be distinct Misra2012:5.5 LANG.ID.ND.MO Identifiers: closely mapped from macro names Macro/Other A typedef name shall be a Non-unique Misra2012:5.6 LANG.ID.NU.TYPE closely mapped unique identifier Identifiers: Typedef A tag name shall be a unique Non-unique Misra2012:5.7 LANG.ID.NU.TAG closely mapped identifier Identifiers: Tag Identifiers that define objects Non-unique Misra2012:5.8 or functions with external LANG.ID.NU.EXT Identifiers: External closely mapped linkage shall be unique Name Identifiers that define objects Non-unique Misra2012:5.9 or functions with internal LANG.ID.NU.INT Identifiers: Internal closely mapped linkage should be unique Name Bit-fields shall only be Bit-field Signedness Misra2012:6.1 declared with an appropriate LANG.TYPE.BFSIGN closely mapped Not Explicit type Bit-fields shall only be Inappropriate Bit- Misra2012:6.1 declared with an appropriate LANG.TYPE.BFINT closely mapped field Type type Single-bit named bit fields Misra2012:6.2 LANG.TYPE.BFSHORT Bit-field Too Short closely mapped shall not be of a signed type Octal constants shall not be Misra2012:7.1 LANG.TYPE.OC Octal Constant closely mapped used A "u" or "U" suffix shall be applied to all integer Misra2012:7.2 constants that are LANG.TYPE.MSUF Missing Literal Suffix closely mapped represented in an unsigned type The lowercase character "l" Confusing Literal Misra2012:7.3 shall not be used in a literal LANG.TYPE.CSUF closely mapped Suffix suffix A string literal shall not be assigned to an object unless Non-const String Misra2012:7.4 LANG.TYPE.NCS closely mapped the object's type is "pointer to Literal const-qualified char" Function types shall be in Incomplete Function Misra2012:8.2 prototype form with named LANG.FUNCS.PROT closely mapped Prototype parameters All declarations of an object or Global Variable Misra2012:8.3 function shall use the same LANG.STRUCT.DECL.MGT Declared with closely mapped names and type qualifiers Different Types All declarations of an object or Inconsistent Misra2012:8.3 function shall use the same LANG.STRUCT.DECL.IF Function closely mapped names and type qualifiers Declarations GrammaTech Confidential and Proprietary. CodeSonar is a registered trademark of GrammaTech, Inc. MISRA C 2012 Mapping to CodeSonar® All declarations of an object or Inconsistent Object Misra2012:8.3 function shall use the same LANG.STRUCT.DECL.IO closely mapped Declarations names and type qualifiers An external object or function Missing External Misra2012:8.5 shall be declared once in one LANG.STRUCT.DECL.NOEXT closely mapped Declaration and only one file An external object or function Multiple Declarations Misra2012:8.5 shall be declared once in one LANG.STRUCT.DECL.MG closely mapped of a Global and only one file An external object or function LANG.STRUCT.DECL.MULTIE Multiple External Misra2012:8.5 shall be declared once in one closely mapped XT Declarations and only one file An identifier with external Missing External Misra2012:8.6 linkage shall have exactly one LANG.STRUCT.DEF.NOEXT closely mapped Definition external definition An identifier with external LANG.STRUCT.DEF.MULTIEX Multiple External Misra2012:8.6 linkage shall have exactly one closely mapped T Definitions external definition Functions and objects should not be defined with external Scope Could Be File Misra2012:8.7 LANG.STRUCT.SCOPE.FILE closely mapped linkage if they are referenced Static in only one translation unit Functions and objects should not be defined with external LANG.STRUCT.SCOPE.LOCA Scope Could Be Misra2012:8.7 closely mapped linkage if they are referenced L Local Static in only one translation unit The static storage class specifier shall be used in all Scope Could Be File Misra2012:8.8 declarations of objects and LANG.STRUCT.SCOPE.FILE closely mapped Static functions that have internal linkage The static storage class specifier shall be used in all LANG.STRUCT.SCOPE.LOCA Scope Could Be Misra2012:8.8 declarations of objects and closely mapped L Local Static functions that have internal linkage An object should be defined at block scope if its identifier LANG.STRUCT.SCOPE.LOCA Scope Could Be Misra2012:8.9 closely mapped only appears in a single L Local Static function An inline function shall be Inline Function Not Misra2012:8.10 declared with the static LANG.TYPE.INS closely mapped static storage class When an array with external Extern Array Without Misra2012:8.11 linkage is declared, its size LANG.STRUCT.DECL.EAWS closely mapped Size should be explicitly specified Within an enumerator list, the Inconsistent value of an implicitly-specified Misra2012:8.12 LANG.STRUCT.INIT.ENUM Enumerator closely mapped enumeration constant shall be Initialization unique GrammaTech Confidential and Proprietary. CodeSonar is a registered trademark of GrammaTech, Inc. MISRA C 2012 Mapping to CodeSonar® The restrict type qualifier shall Restrict Qualifier Misra2012:8.14 LANG.TYPE.RESTRICT closely mapped not be used Used The value of an object with automatic storage duration Misra2012:9.1 LANG.MEM.UVAR Uninitialized Variable closely mapped shall not be read before it has been set The initializer for an aggregate Missing Braces in Misra2012:9.2 or union shall be enclosed in LANG.STRUCT.INIT.MBI closely mapped Initialization braces Arrays shall not be partially Partially Uninitialized Misra2012:9.3 LANG.STRUCT.INIT.PIARR closely mapped initialized Array An element of an object shall Over-initialized Misra2012:9.4 not be initialized more than LANG.STRUCT.INIT.OIE closely mapped Element once Operands shall not be of an Inappropriate Misra2012:10.1 LANG.TYPE.IOT closely mapped inappropriate essential type Operand Type Expressions of essentially character type shall not be Inappropriate Misra2012:10.2 used inappropriately in LANG.TYPE.ICA closely mapped Character Arithmetic addition and subtraction operations The value of an expression shall not be assigned to an Inappropriate Misra2012:10.3 object with a narrower LANG.TYPE.IAT closely mapped Assignment Type essential type or of a different essential type category Both operands of an operator in which the usual arithmetic Mismatched Misra2012:10.4 conversions are performed LANG.TYPE.MOT closely mapped Operand Types shall have the same essential type category The value of an expression Inappropriate Cast Misra2012:10.5 should not be cast to an LANG.TYPE.ICT closely mapped Type inappropriate essential type The value of a composite Expression Value expression shall not be Misra2012:10.6 LANG.TYPE.AWID Widened by closely mapped assigned to an object with Assignment wider essential type If a composite expression is used as one operand of an operator in which the usual Expression Value Misra2012:10.7 arithmetic conversions are LANG.TYPE.OWID Widened by Other closely mapped performed then the other Operand operand shall not have wider essential type The value of a composite expression shall not be cast to Inappropriate Cast Misra2012:10.8 a different essential type LANG.TYPE.ICTE closely mapped Type: Expression category or a wider essential type GrammaTech Confidential and Proprietary.