MISRA C:2
012
Contents
1 The vision
2 Background to MISRA C
2.1 The popularity of C
2.2 Disadvantages of C
2.2.1 Language definition
2.2.2 Language misuse
2.2.3 Language misunderstanding
2.2.4 Run-time error checking
3 Tool selection
3.1 The C language and its compiler
3.2 Analysis tools
4 Prerequisite knowledge
4.1 Training
4.2 Understanding the compiler
4.3 Understanding the static analysis tools
5 Adopting and using MISRA C
5.1 Adoption
5.2 Software development process
5.2.1 Process activities required by MISRA C
5.2.2 Process activities expected by MISRA C
5.3 Compliance
5.3.1 Compiler configuration
5.3.2 Static analysis tool configuration
5.3.3 Investigating messages
5.4 Deviation procedure
5.5 Claiming compliance
6 Introduction to the guidelines
6.1 Guideline classification
6.2 Guideline categories
6.2.1 Mandatory guidelines
6.2.2 Required guidelines
6.2.3 Advisory guidelines
6.3 Organization of guidelines
6.4 Redundancy in the guidelines
6.5 Decidability of rules
6.6 Scope of analysis
6.7 Multi-organization projects
6.8 Automatically generated code
6.9 Presentation of guidelines
6.10 Understanding the source references
6.10.1 ISO C portability issue references
6.10.2 Other references
7 Directives
7.1 The implementation
7.2 Compilation and build
7.3 Requirements traceability
7.4 Code design
8 Rules
8.1 A standard C environment
8.2 Unused code
8.3 Comments
8.4 Character sets and lexical conventions
8.5 Identifiers
8.6 Types
8.7 Literals and constants
8.8 Declarations and definitions
8.9 Initialization
8.10 The essential type model
8.10.1 Rationale
8.10.2 Essential type
8.10.3 Composite operators and expressions
8.11 Pointer type conversions
8.12 Expressions
8.13 Side effects
8.14 Control statement expressions
8.15 Control flow
8.16 Switch statements
8.17 Functions
8.18 Pointers and arrays
8.19 Overlapping storage
8.20 Preprocessing directives
8.21 Standard libraries
8.22 Resources
9 References
Appendix A Summary of guidelines
Appendix B Guideline attributes
Appendix C Type safety issues with C
C.1 T ype conversions
C.1.1 Implicit conversions
C.1.2 Explicit conversions
C.1.3 Concerns with conversions
C.2 D eveloper confusion
C.2.1 Type widening in integer promotion
C.2.2 Evaluation type confusion
C.2.3 Change of signedness in arithmetic operations
C.2.4 Change of signedness in bitwise operations
Appendix D Essential types
D.1 The essential type category of expressions
D.2 The essential type of character data
D.3 The signed and unsigned type of lowest rank (STLR and UTLR)
D.4 The essential type of bit-fields
D.5 The essential type of enumerations
D.6 The essential type of literal constants
D.7 The essential type of expressions
Appendix E Applicability to automatically generatedcode
E.1 Guideline categories for automatically generated code
E.1.1 Additional categories
E.1.2 Hiding identifiers
E.1.3 Octal constants
E.1.4 Compatible declarations with external linkage
E.1.5 Essential type
E.1.6 Loop counters
E.1.7 Labels and goto
E.1.8 Switch statements
E.1.9 Readability
E.2 Documentation requirements for automatic code generation tools
E.2.1 Implementation-defined behaviour and language extensions
E.2.2 The essential type model
E.2.3 Run-time errors
Appendix F Process and tools checklist
Appendix G Implementation-defined behaviour checklist
Appendix H Undefined and critical unspecified behaviour
H.1 Undefined behaviour
H.2 Critical unspecified behaviour
Appendix I Example deviation record
Appendix J Glossary