SlideShare a Scribd company logo
1 
An Insight into MISRA C 2012 
© 2014 Rolls‐Royce PLC
This talk is based on MISRA C 2012. However, the rationale behind MISRA C and the principles 
for its use apply to all three versions; 1998, 2004, and 2012. 
Nothing in this talk and presentation slide pack (with accompanying notes) should be taken as 
adding to, or altering the meaning of, any of the MISRA C publications. E&OE. Polite feedback is 
of course welcomed. 
2 
An Insight into MISRA C 2012 
© 2014 Rolls‐Royce PLC
3 
An Insight into MISRA C 2012 
© 2014 Rolls‐Royce PLC
Note: There are contradictions in the arguments cited for and against the use of C; nobody said 
the arguments were rational in their choice of focus. For example, structured programming is 
good, but imperative (machine action oriented) programming bad; except that structured 
programming relies on imperative programming! 
4 
An Insight into MISRA C 2012 
© 2014 Rolls‐Royce PLC
See http://en.wikipedia.org/wiki/History_of_programming_languages 
References 
1. Kernighan, Brian W.; Ritchie, Dennis M. (February 1978). The C Programming Language 
(1st ed.). Englewood Cliffs, NJ: Prentice Hall. ISBN 0‐13‐110163‐3. 
2. Page 3 in reference [1] 
C is an old language (circa 1972) that evolved and was then standardised by ANSI in 1989 (C89) 
and adopted by ISO and IEC in 1990 as ISO/IEC 9899 (C90). Corrections to the ISO/IEC 
document where made in 1995. The standard was then revised and published as ISO9899:1999 
(C99) and again in 2011 (C11). With each of the revisions to the standard, some archaic aspect 
of the language was deprecated and subsequently removed. New language and library features 
have of course been added. 
5 
An Insight into MISRA C 2012 
© 2014 Rolls‐Royce PLC
C’s design was driven by the needs of system programming for which it became synonymous 
with the UNIX operating system and system utilities. This in part goes a long way towards 
understanding C as being a hybrid of a generic machine‐code assembly language (2GL) and a 
structured programming language (3GL). This conflation of programming concerns gives cause 
for concern from those that would like to see strict adherence to structured programming 
techniques. However, back when C was conceived it was strictly the programmers problem to 
ensure their C program was correct because the compilers did not have sufficient working 
memory to perform anything but the programmes translation from source code to object code. 
To counter this problem a compilation like tool was created to perform automated checks on 
the source code and since this was seen as being a task akin to picking the fluff from fabric, the 
tool was called “lint”. 
Further reading: 
• Wikipedia article http://en.wikipedia.org/wiki/C_(programming_language) 
• Denis Ritchie article “The Development of the C Language” http://cm.bell‐labs. 
com/cm/cs/who/dmr/chist.html 
• “Safer C: Developing Software for High‐Integrity and Safety‐Critical Systems” Les Hatton, 
ISBN‐10: 0077076400, ISBN‐13: 978‐0077076405 
6 
An Insight into MISRA C 2012 
© 2014 Rolls‐Royce PLC
Some additional issues that are often cited as being problematic with C are: 
• The Preprocessor 
• Integer promotion rules for the small integer types are not intuitive 
• Integer type sizes are dictated by the target architecture; the standard only sets out the 
minimum requirements for each type 
• Implicit type conversion 
• Enumerate types are integers and are therefore not type distinct (fixed in C++) 
• Single name space (fixed in C++) 
• Standard heap memory manager is far to simplistic for practical long term use 
• And many more… 
Note that Rule 12.1 in MISRA C 2012 has a precedence table with 17 entries consisting of one 
entry for identifiers and literals, and 16 further entries for the operators. 
7 
An Insight into MISRA C 2012 
© 2014 Rolls‐Royce PLC
References: 
[1]: The Development of the C Language, Dennis M. Ritchie, April 1993, http://cm.bell‐labs. 
com/cm/cs/who/dmr/chist.html (accessed 26 August 2014) 
8 
An Insight into MISRA C 2012 
© 2014 Rolls‐Royce PLC
9 
An Insight into MISRA C 2012 
© 2014 Rolls‐Royce PLC
References: 
[1] Annex G in ISO/IEC 9899:1990 
[2] Annex J in ISO/IEC 9899:1999 
Define a “safe” subset from the ISO/IEC9899 standard: 
• Prohibit the use of language features that have: 
• Undefined behaviour 
• Critical Unspecified behaviour 
• Implementation chosen behaviour 
The safe subset has Standard defined program semantics 
• Consistently and predictably understood by all ISO C Standard conforming tools 
10 
An Insight into MISRA C 2012 
© 2014 Rolls‐Royce PLC
Note: “goto” is generally read as a synonym for unstructured programming, and unstructured 
programmes can be hard to verify correctness, let alone maintain. Hence “unstructured 
programming” ≡ “bad programming”, therefore “goto” ≡ “bad programming”. 
However, there are perfectly legitimate uses of “goto” as part of a structured programming 
approach to the use of C. For example, where avoiding its use leads to more convoluted code 
that is potentially harder to understand (i.e. read) than if a “goto” had been used. Examples of 
this are jumping out of nested loops, dealing with exceptions, etc. 
This is often referred to as a “tamed goto”. 
11 
An Insight into MISRA C 2012 
© 2014 Rolls‐Royce PLC
MISRA C 2004 provides coverage for ISO/IEC 9899:1990 with TC1 (1995) (C90). 
MISRA C 2012 provides coverage for ISO/IEC 9899:1990 with TC1 (1995) (C90) and ISO/IEC 
9899:1999 (C99) 
It says very little about: 
• Source code style 
That’s your business, but have one and be consistent 
• The software development process 
Have one 
Ideally requirements driven 
Bakes in the required qualities of the software 
Use it 
Collect evidence to prove it 
12 
An Insight into MISRA C 2012 
© 2014 Rolls‐Royce PLC
MISRA C 2012 has 159 guidelines. Divided into two classifications 
• Directives (16) 
• Rules (143) 
With three categories of compliance: 
• Mandatory (10) 
• Required (110) 
• Advisory (39) 
Rules are guidelines that have a complete description of what is required. Directives are 
guidelines that establish a principal, but one for which a complete description of what is 
required is not possible. In that sense, rules are precise about their C coding standard 
requirements and directives are abstract and require interpretation for each project and 
situation. 
The three categories of compliance set out a baseline expectation for claiming compliance to 
MISRA C. All mandatory guidelines must be satisfied. All required guidelines must be satisfied, 
except for those with explicit formal deviation statements. The advisory guidelines are 
recommendations that may (more freely) be deviated from. 
13 
An Insight into MISRA C 2012 
© 2014 Rolls‐Royce PLC
116 of the guidelines are considered to be decidable. That’s 73% of the 159 guidelines or 81% 
of the 143 rules, since the directives are implicitly undecidable. 
Rule decidability is discussed in section 6.5 in MISRA C 2012. It also provides in Appendix B a 
list of the guidelines with their “analysis” attributes, which include decidability. 
14 
An Insight into MISRA C 2012 
© 2014 Rolls‐Royce PLC
Note: MISRA C 2012 formally recognises Project and Specific deviations. The “architectural 
category” of deviation is drawn out, in this presentation, as a specific subset of the Project 
deviation category to emphasis the point that different coding standard rules can be defined 
for each aspect of the software systems architecture as required. 
15 
An Insight into MISRA C 2012 
© 2014 Rolls‐Royce PLC
Note: MISRA C 2012 states in section 6.2.2 “An organization or project may choose to treat any 
required guidelines as if they were mandatory”, and in section 6.2.3 “An organization or project 
may choose to treat any advisory guideline as if they were mandatory or required”. 
See MISRA C 2012 section 5.4 for the formal deviation process requirements. 
16 
An Insight into MISRA C 2012 
© 2014 Rolls‐Royce PLC
The default position is that all language features considered “harmful” are prohibited, e.g. 
• goto (Rule 15.1) 
• union (Rule 19.2) 
Such features can be “enabled” by a deviation to the guideline that prohibits their direct use. 
However, finer grained guidelines typically provide constraint on the use of such language 
features, e.g. 
• Rule 15.1 The goto statement should not be used (advisory) 
• Rule 15.2 The goto statement shall jump to a label declared later in the same function 
(required) 
• Rule 15.3 Any label referenced by a goto statement shall be declared in the same block or 
in any block enclosing the goto statement (required) 
• Rule 15.4 “There should be no more than one break or goto statement used to terminate 
any iteration statement” (advisory) 
• Rule 9.1 “The value of an object with automatic storage duration shall not be read before it 
has been set” (mandatory) – which prevents the use of goto from skipping over initialiser 
statements. 
17 
An Insight into MISRA C 2012 
© 2014 Rolls‐Royce PLC
18 
An Insight into MISRA C 2012 
© 2014 Rolls‐Royce PLC
19 
An Insight into MISRA C 2012 
© 2014 Rolls‐Royce PLC
20 
An Insight into MISRA C 2012 
© 2014 Rolls‐Royce PLC
21 
An Insight into MISRA C 2012 
© 2014 Rolls‐Royce PLC
The page image in this slide, and on the following slides, is from reference [1]. 
In order to use MISRA C, it is necessary to develop and document:[2] 
• A compliance matrix, showing how compliance with each MISRA C guideline will be 
checked; 
• A deviation process by which justifiable non‐compliances can be authorized and recorded; 
• The demonstration that the project’s C code is MISRA C compliant subject to the project’s 
approved deviations; 
• The Project’s engineering process meets the process requirements detailed in sections 3, 4, 
& 5 and summarised in Appendix F (see next slide); 
• People involved in the development of MISRA C compliant C source code are competent to 
do so. 
Note that compliance can only be claimed for the software project.[3] 
References: 
[1]: MISRA C Guidelines for the use of the C language in critical systems, March 2013, MIRA 
Limited, ISBN 978‐906400‐10‐1 (paperback) 
[2]: Section §5.2.1 in [1] 
[3]: Section §5.5 in [1] 
22 
An Insight into MISRA C 2012 
© 2014 Rolls‐Royce PLC
Verification that C code complies with the guidelines precisely and absolutely is fraught with 
the difficulty of proving that the implementation of such checks are robust. Informal and semi‐formal 
techniques will be used and the project must address the risk of approving C code that 
could be shown to be non‐compliant. A typical strategy is to use more than one technique (and 
tool) for each guideline with the assumption that flawed checks in one do not overlap with the 
flaws in the other. This layered set of verification “defences” (often referred to as the “Swiss 
Cheese” model) should have as many layers of checking as required to satisfy the project’s 
risk/integrity profile. Thus, projects at the lower end of the risk/integrity scale may decide that 
a single static analysis tool in conjunction with the compiler’s checks, source code inspection, 
and dynamic testing are sufficient. Whereas a project at the higher end of the risk/integrity 
scale may opt for multiple static analysis tools from different vendors with different pedigrees, 
combined with a sophisticated dynamic test process that leverages multiple compiler 
technologies for multiple test platforms. 
The next slide illustrates a compliance matrix for a project that has determined that its 
risk/integrity profile are best served by two independent compilers and static analysis tools. 
23 
An Insight into MISRA C 2012 
© 2014 Rolls‐Royce PLC
Note: Table extracted from reference [2] 
References 
[1]: MISRA C Guidelines for the use of the C language in critical systems, March 2013, MIRA 
Limited, ISBN 978‐906400‐10‐1 (paperback) 
[2]: Section §5.3 in [1] 
24 
An Insight into MISRA C 2012 
© 2014 Rolls‐Royce PLC
This is essentially process definition and process execution evidence, with the spot light over 
those areas that concern MISRA C; e.g. procedures and evidence for the assessment of 
development tool fitness for purpose. See next slide for the summary check list. 
25 
An Insight into MISRA C 2012 
© 2014 Rolls‐Royce PLC
Note: Page extracted from reference [1] 
References: 
[1]: MISRA C Guidelines for the use of the C language in critical systems, March 2013, MIRA 
Limited, ISBN 978‐906400‐10‐1 (paperback) 
26 
An Insight into MISRA C 2012 
© 2014 Rolls‐Royce PLC
Required for compliance, but no explicit guidance is provided by MISRA C. However, a clear test 
of competency for critical systems software development with MISRA C 2012 is the knowledge 
that MISRA C is more than just about the adherence to its guidelines! (I.e. the process 
objectives set out in sections 3, 4, & 5.) 
27 
An Insight into MISRA C 2012 
© 2014 Rolls‐Royce PLC
28 
An Insight into MISRA C 2012 
© 2014 Rolls‐Royce PLC
A copy of MISRA C 2012 can be purchased from www.misra.org.uk in both PDF and paperback 
formats. 
29 
An Insight into MISRA C 2012 
© 2014 Rolls‐Royce PLC
30 
An Insight into MISRA C 2012 
© 2014 Rolls‐Royce PLC
31 
An Insight into MISRA C 2012 
© 2014 Rolls‐Royce PLC

More Related Content

PDF
Multi-Core (MC) Processor Qualification for Safety Critical Systems
AdaCore
 
PDF
MISRA C – Recent developments and a road map to the future
AdaCore
 
PDF
An Alternative Approach to DO-178B
AdaCore
 
PPTX
An Introduction to MISRA C:2012
PRQA
 
PDF
Bounded Model Checking for C Programs in an Enterprise Environment
AdaCore
 
PDF
Avionics Software Standards
Sushma Reddy
 
KEY
DO-178B/ED-12B Presentation
Ankit Singh
 
Multi-Core (MC) Processor Qualification for Safety Critical Systems
AdaCore
 
MISRA C – Recent developments and a road map to the future
AdaCore
 
An Alternative Approach to DO-178B
AdaCore
 
An Introduction to MISRA C:2012
PRQA
 
Bounded Model Checking for C Programs in an Enterprise Environment
AdaCore
 
Avionics Software Standards
Sushma Reddy
 
DO-178B/ED-12B Presentation
Ankit Singh
 

What's hot (20)

PPT
Introduction to DO-178B - Software Considerations in Airborne Systems and Equ...
Swamy Shettru
 
PDF
Embedded software static analysis_Polyspace-WhitePaper_final
TAMILMARAN C
 
DOC
Piyush_Kant_Singh_updated_resume
PIYUSH SINGH
 
PDF
Avionics Software Standards ppt in latex
Sushma Reddy
 
PDF
Verification Engineer - Opportunities and Career Path
Ramdas Mozhikunnath
 
PDF
Reliability Testing in OPNFV
OPNFV
 
DOC
5_16_15_Chron_Resume
Donald Franklin
 
PDF
Robust design and reliability engineering synergy webinar 2013 04 10
ASQ Reliability Division
 
PPTX
RISC-V Unconstrained
RISC-V International
 
PDF
D pduapi user-manual
linhdoanbro
 
PDF
Ripes: Teaching Computer Architecture Through Visual and Interactive Simulators
RISC-V International
 
PDF
Overview of DO-254: Design Assurance Guidance For Airborne Electronic Hardware
Oak Systems
 
DOCX
Michael Lang Resume - 2015 A1
Mike Lang
 
PDF
Sreda Software Solutions company information
Yaroslav Domaratsky
 
DOCX
Nishar_Resume
MD NISHAR
 
PPT
DO254 DMAP Training 2011 Trailer
DMAP
 
PPTX
Advances in Verification - Workshop at BMS College of Engineering
Ramdas Mozhikunnath
 
PDF
Securing the Future of Safety and Security of Embedded Software
AdaCore
 
PDF
Alley vsu functional_coverage_1f
Obsidian Software
 
PDF
Tools for quality matrix and kloc
Rajesh Kumar
 
Introduction to DO-178B - Software Considerations in Airborne Systems and Equ...
Swamy Shettru
 
Embedded software static analysis_Polyspace-WhitePaper_final
TAMILMARAN C
 
Piyush_Kant_Singh_updated_resume
PIYUSH SINGH
 
Avionics Software Standards ppt in latex
Sushma Reddy
 
Verification Engineer - Opportunities and Career Path
Ramdas Mozhikunnath
 
Reliability Testing in OPNFV
OPNFV
 
5_16_15_Chron_Resume
Donald Franklin
 
Robust design and reliability engineering synergy webinar 2013 04 10
ASQ Reliability Division
 
RISC-V Unconstrained
RISC-V International
 
D pduapi user-manual
linhdoanbro
 
Ripes: Teaching Computer Architecture Through Visual and Interactive Simulators
RISC-V International
 
Overview of DO-254: Design Assurance Guidance For Airborne Electronic Hardware
Oak Systems
 
Michael Lang Resume - 2015 A1
Mike Lang
 
Sreda Software Solutions company information
Yaroslav Domaratsky
 
Nishar_Resume
MD NISHAR
 
DO254 DMAP Training 2011 Trailer
DMAP
 
Advances in Verification - Workshop at BMS College of Engineering
Ramdas Mozhikunnath
 
Securing the Future of Safety and Security of Embedded Software
AdaCore
 
Alley vsu functional_coverage_1f
Obsidian Software
 
Tools for quality matrix and kloc
Rajesh Kumar
 
Ad

Viewers also liked (20)

PDF
HIS 2015: Roderick Chapman - Murphy Vs Satan Why programming secure systems i...
AdaCore
 
PDF
Practical Application of Agile Techniques in Developing Safety Related Systems
AdaCore
 
PDF
How should we build that? Evolving a development environment that's suitable ...
AdaCore
 
PDF
HIS 2015: Neil White - Advances in Practical Techniques for Critical Developm...
AdaCore
 
PDF
HIS 2015: Prof. Ian Phillips - Stronger than its weakest link
AdaCore
 
PDF
A Computer Vision Application for In Vitro Diagnostics Devices
AdaCore
 
PDF
Mind your language(s), A Discussion about Languages and Security
AdaCore
 
PDF
Mixed Criticality Systems and Many-Core Platforms
AdaCore
 
PDF
HIS 2015: Prof. Mark Little - Open Source Challenges in the Enterprise
AdaCore
 
PDF
The Muen Separation Kernel
AdaCore
 
PDF
HIS 2015: Prof. Phil Koopman - A Case Study of Toyota Unintended Acceleration...
AdaCore
 
PDF
HIS 2015: Tom Chothia - Formal Security of Critical Infrastructure
AdaCore
 
PDF
HIS 2015: Ivan Ellis - VISIUMCORE A High Integrity Processor for Safety Criti...
AdaCore
 
PDF
HIS 2015: Alastair F. Donaldson - Fighting for Software Correctness in a Mass...
AdaCore
 
PDF
The Application of Formal Methods to Railway Signalling Software
AdaCore
 
PDF
Ada 202x A broad overview of relevant news
AdaCore
 
PDF
Verification and Validation of Robotic Assistants
AdaCore
 
PPT
Misra c
Pradeep Kumar TS
 
PDF
Development of Safety Case for the Wolsong LILW disposal facility in Korea
Technical Research Center of Finland, VTT
 
PPT
Misra c rules
kiranyeligati
 
HIS 2015: Roderick Chapman - Murphy Vs Satan Why programming secure systems i...
AdaCore
 
Practical Application of Agile Techniques in Developing Safety Related Systems
AdaCore
 
How should we build that? Evolving a development environment that's suitable ...
AdaCore
 
HIS 2015: Neil White - Advances in Practical Techniques for Critical Developm...
AdaCore
 
HIS 2015: Prof. Ian Phillips - Stronger than its weakest link
AdaCore
 
A Computer Vision Application for In Vitro Diagnostics Devices
AdaCore
 
Mind your language(s), A Discussion about Languages and Security
AdaCore
 
Mixed Criticality Systems and Many-Core Platforms
AdaCore
 
HIS 2015: Prof. Mark Little - Open Source Challenges in the Enterprise
AdaCore
 
The Muen Separation Kernel
AdaCore
 
HIS 2015: Prof. Phil Koopman - A Case Study of Toyota Unintended Acceleration...
AdaCore
 
HIS 2015: Tom Chothia - Formal Security of Critical Infrastructure
AdaCore
 
HIS 2015: Ivan Ellis - VISIUMCORE A High Integrity Processor for Safety Criti...
AdaCore
 
HIS 2015: Alastair F. Donaldson - Fighting for Software Correctness in a Mass...
AdaCore
 
The Application of Formal Methods to Railway Signalling Software
AdaCore
 
Ada 202x A broad overview of relevant news
AdaCore
 
Verification and Validation of Robotic Assistants
AdaCore
 
Development of Safety Case for the Wolsong LILW disposal facility in Korea
Technical Research Center of Finland, VTT
 
Misra c rules
kiranyeligati
 
Ad

Similar to HIS Conf 2014: An Insight into MISRA-C (20)

PDF
VDA 2015 Presentation - Full
Andrew Banks
 
PDF
MISRA C in an ISO 26262 context
AdaCore
 
PDF
MISRA C 2012 Permits Deviation permits for MISRA Compliance First Edition, Ma...
yarenmuseled
 
PDF
Safety criticalc++
David Underdown
 
PDF
Evolution from LwCCM to UCM
Remedy IT
 
PDF
Model-Driven Development for Safety-Critical Software
gjuljo
 
PDF
Jpl coding standard_c
loyalj
 
PDF
MISRA-C-curse-or-cure
Chris Hills
 
PDF
comForte CSL: a messaging middleware framework for HP NonStop
Thomas Burg
 
PDF
Model Driven, Component Based Development for CBDDS and IDL to C++11
Remedy IT
 
PPT
Software Factories in the Real World: How an IBM WebSphere Integration Factor...
ghodgkinson
 
PDF
Draft Request For Proposal Unified Component Model for Distributed, Real-Time...
Johnny Willemsen
 
PDF
Security in Embedded systems
Naveen Jakhar, I.T.S
 
PPT
vu-sqa-lecture13.ppt
SofiaRehman2
 
PDF
Distributed Application Development (Introduction)
Dudy Ali
 
PDF
Keynote 4 cornelius_koetz_v04
goodgolier
 
PDF
Enterprise serverless
DmitryLozitskiy2
 
PPTX
Generic Vehicle Architecture – DDS at the Core.
Real-Time Innovations (RTI)
 
PPTX
Cocomo m odel
randhirlpu
 
PDF
AMI4CCM, custom DDS connectors, and IDL to C++11
Remedy IT
 
VDA 2015 Presentation - Full
Andrew Banks
 
MISRA C in an ISO 26262 context
AdaCore
 
MISRA C 2012 Permits Deviation permits for MISRA Compliance First Edition, Ma...
yarenmuseled
 
Safety criticalc++
David Underdown
 
Evolution from LwCCM to UCM
Remedy IT
 
Model-Driven Development for Safety-Critical Software
gjuljo
 
Jpl coding standard_c
loyalj
 
MISRA-C-curse-or-cure
Chris Hills
 
comForte CSL: a messaging middleware framework for HP NonStop
Thomas Burg
 
Model Driven, Component Based Development for CBDDS and IDL to C++11
Remedy IT
 
Software Factories in the Real World: How an IBM WebSphere Integration Factor...
ghodgkinson
 
Draft Request For Proposal Unified Component Model for Distributed, Real-Time...
Johnny Willemsen
 
Security in Embedded systems
Naveen Jakhar, I.T.S
 
vu-sqa-lecture13.ppt
SofiaRehman2
 
Distributed Application Development (Introduction)
Dudy Ali
 
Keynote 4 cornelius_koetz_v04
goodgolier
 
Enterprise serverless
DmitryLozitskiy2
 
Generic Vehicle Architecture – DDS at the Core.
Real-Time Innovations (RTI)
 
Cocomo m odel
randhirlpu
 
AMI4CCM, custom DDS connectors, and IDL to C++11
Remedy IT
 

More from AdaCore (16)

PDF
RCA OCORA: Safe Computing Platform using open standards
AdaCore
 
PDF
Have we a Human Ecosystem?
AdaCore
 
PDF
Rust and the coming age of high integrity languages
AdaCore
 
PDF
SPARKNaCl: A verified, fast cryptographic library
AdaCore
 
PDF
Developing Future High Integrity Processing Solutions
AdaCore
 
PDF
Taming event-driven software via formal verification
AdaCore
 
PDF
Pushing the Boundary of Mostly Automatic Program Proof
AdaCore
 
PDF
RCA OCORA: Safe Computing Platform using open standards
AdaCore
 
PDF
Product Lines and Ecosystems: from customization to configuration
AdaCore
 
PDF
Spark / Ada for Safe and Secure Firmware Development
AdaCore
 
PDF
Introducing the HICLASS Research Programme - Enabling Development of Complex ...
AdaCore
 
PDF
The Future of Aerospace – More Software Please!
AdaCore
 
PDF
Adaptive AUTOSAR - The New AUTOSAR Architecture
AdaCore
 
PDF
Using Tiers of Assurance Evidence to Reduce the Tears! Adopting the “Wheel of...
AdaCore
 
PDF
Software Engineering for Robotics - The RoboStar Technology
AdaCore
 
PPTX
Application of theorem proving for safety-critical vehicle software
AdaCore
 
RCA OCORA: Safe Computing Platform using open standards
AdaCore
 
Have we a Human Ecosystem?
AdaCore
 
Rust and the coming age of high integrity languages
AdaCore
 
SPARKNaCl: A verified, fast cryptographic library
AdaCore
 
Developing Future High Integrity Processing Solutions
AdaCore
 
Taming event-driven software via formal verification
AdaCore
 
Pushing the Boundary of Mostly Automatic Program Proof
AdaCore
 
RCA OCORA: Safe Computing Platform using open standards
AdaCore
 
Product Lines and Ecosystems: from customization to configuration
AdaCore
 
Spark / Ada for Safe and Secure Firmware Development
AdaCore
 
Introducing the HICLASS Research Programme - Enabling Development of Complex ...
AdaCore
 
The Future of Aerospace – More Software Please!
AdaCore
 
Adaptive AUTOSAR - The New AUTOSAR Architecture
AdaCore
 
Using Tiers of Assurance Evidence to Reduce the Tears! Adopting the “Wheel of...
AdaCore
 
Software Engineering for Robotics - The RoboStar Technology
AdaCore
 
Application of theorem proving for safety-critical vehicle software
AdaCore
 

Recently uploaded (20)

PPTX
ConcordeApp: Engineering Global Impact & Unlocking Billions in Event ROI with AI
chastechaste14
 
PDF
MiniTool Power Data Recovery Crack New Pre Activated Version Latest 2025
imang66g
 
PDF
Bandai Playdia The Book - David Glotz
BluePanther6
 
PDF
lesson-2-rules-of-netiquette.pdf.bshhsjdj
jasmenrojas249
 
PPTX
classification of computer and basic part of digital computer
ravisinghrajpurohit3
 
PDF
Immersive experiences: what Pharo users do!
ESUG
 
PPT
Activate_Methodology_Summary presentatio
annapureddyn
 
PPTX
slidesgo-unlocking-the-code-the-dynamic-dance-of-variables-and-constants-2024...
kr2589474
 
PDF
Using licensed Data Loss Prevention (DLP) as a strategic proactive data secur...
Q-Advise
 
DOCX
Can You Build Dashboards Using Open Source Visualization Tool.docx
Varsha Nayak
 
PDF
WatchTraderHub - Watch Dealer software with inventory management and multi-ch...
WatchDealer Pavel
 
PPTX
ASSIGNMENT_1[1][1][1][1][1] (1) variables.pptx
kr2589474
 
PDF
Applitools Platform Pulse: What's New and What's Coming - July 2025
Applitools
 
PDF
New Download FL Studio Crack Full Version [Latest 2025]
imang66g
 
PDF
ChatPharo: an Open Architecture for Understanding How to Talk Live to LLMs
ESUG
 
PPTX
Visualising Data with Scatterplots in IBM SPSS Statistics.pptx
Version 1 Analytics
 
PDF
Adobe Illustrator Crack Full Download (Latest Version 2025) Pre-Activated
imang66g
 
PDF
Protecting the Digital World Cyber Securit
dnthakkar16
 
PDF
Enhancing Healthcare RPM Platforms with Contextual AI Integration
Cadabra Studio
 
PDF
On Software Engineers' Productivity - Beyond Misleading Metrics
Romén Rodríguez-Gil
 
ConcordeApp: Engineering Global Impact & Unlocking Billions in Event ROI with AI
chastechaste14
 
MiniTool Power Data Recovery Crack New Pre Activated Version Latest 2025
imang66g
 
Bandai Playdia The Book - David Glotz
BluePanther6
 
lesson-2-rules-of-netiquette.pdf.bshhsjdj
jasmenrojas249
 
classification of computer and basic part of digital computer
ravisinghrajpurohit3
 
Immersive experiences: what Pharo users do!
ESUG
 
Activate_Methodology_Summary presentatio
annapureddyn
 
slidesgo-unlocking-the-code-the-dynamic-dance-of-variables-and-constants-2024...
kr2589474
 
Using licensed Data Loss Prevention (DLP) as a strategic proactive data secur...
Q-Advise
 
Can You Build Dashboards Using Open Source Visualization Tool.docx
Varsha Nayak
 
WatchTraderHub - Watch Dealer software with inventory management and multi-ch...
WatchDealer Pavel
 
ASSIGNMENT_1[1][1][1][1][1] (1) variables.pptx
kr2589474
 
Applitools Platform Pulse: What's New and What's Coming - July 2025
Applitools
 
New Download FL Studio Crack Full Version [Latest 2025]
imang66g
 
ChatPharo: an Open Architecture for Understanding How to Talk Live to LLMs
ESUG
 
Visualising Data with Scatterplots in IBM SPSS Statistics.pptx
Version 1 Analytics
 
Adobe Illustrator Crack Full Download (Latest Version 2025) Pre-Activated
imang66g
 
Protecting the Digital World Cyber Securit
dnthakkar16
 
Enhancing Healthcare RPM Platforms with Contextual AI Integration
Cadabra Studio
 
On Software Engineers' Productivity - Beyond Misleading Metrics
Romén Rodríguez-Gil
 

HIS Conf 2014: An Insight into MISRA-C

  • 1. 1 An Insight into MISRA C 2012 © 2014 Rolls‐Royce PLC
  • 2. This talk is based on MISRA C 2012. However, the rationale behind MISRA C and the principles for its use apply to all three versions; 1998, 2004, and 2012. Nothing in this talk and presentation slide pack (with accompanying notes) should be taken as adding to, or altering the meaning of, any of the MISRA C publications. E&OE. Polite feedback is of course welcomed. 2 An Insight into MISRA C 2012 © 2014 Rolls‐Royce PLC
  • 3. 3 An Insight into MISRA C 2012 © 2014 Rolls‐Royce PLC
  • 4. Note: There are contradictions in the arguments cited for and against the use of C; nobody said the arguments were rational in their choice of focus. For example, structured programming is good, but imperative (machine action oriented) programming bad; except that structured programming relies on imperative programming! 4 An Insight into MISRA C 2012 © 2014 Rolls‐Royce PLC
  • 5. See http://en.wikipedia.org/wiki/History_of_programming_languages References 1. Kernighan, Brian W.; Ritchie, Dennis M. (February 1978). The C Programming Language (1st ed.). Englewood Cliffs, NJ: Prentice Hall. ISBN 0‐13‐110163‐3. 2. Page 3 in reference [1] C is an old language (circa 1972) that evolved and was then standardised by ANSI in 1989 (C89) and adopted by ISO and IEC in 1990 as ISO/IEC 9899 (C90). Corrections to the ISO/IEC document where made in 1995. The standard was then revised and published as ISO9899:1999 (C99) and again in 2011 (C11). With each of the revisions to the standard, some archaic aspect of the language was deprecated and subsequently removed. New language and library features have of course been added. 5 An Insight into MISRA C 2012 © 2014 Rolls‐Royce PLC
  • 6. C’s design was driven by the needs of system programming for which it became synonymous with the UNIX operating system and system utilities. This in part goes a long way towards understanding C as being a hybrid of a generic machine‐code assembly language (2GL) and a structured programming language (3GL). This conflation of programming concerns gives cause for concern from those that would like to see strict adherence to structured programming techniques. However, back when C was conceived it was strictly the programmers problem to ensure their C program was correct because the compilers did not have sufficient working memory to perform anything but the programmes translation from source code to object code. To counter this problem a compilation like tool was created to perform automated checks on the source code and since this was seen as being a task akin to picking the fluff from fabric, the tool was called “lint”. Further reading: • Wikipedia article http://en.wikipedia.org/wiki/C_(programming_language) • Denis Ritchie article “The Development of the C Language” http://cm.bell‐labs. com/cm/cs/who/dmr/chist.html • “Safer C: Developing Software for High‐Integrity and Safety‐Critical Systems” Les Hatton, ISBN‐10: 0077076400, ISBN‐13: 978‐0077076405 6 An Insight into MISRA C 2012 © 2014 Rolls‐Royce PLC
  • 7. Some additional issues that are often cited as being problematic with C are: • The Preprocessor • Integer promotion rules for the small integer types are not intuitive • Integer type sizes are dictated by the target architecture; the standard only sets out the minimum requirements for each type • Implicit type conversion • Enumerate types are integers and are therefore not type distinct (fixed in C++) • Single name space (fixed in C++) • Standard heap memory manager is far to simplistic for practical long term use • And many more… Note that Rule 12.1 in MISRA C 2012 has a precedence table with 17 entries consisting of one entry for identifiers and literals, and 16 further entries for the operators. 7 An Insight into MISRA C 2012 © 2014 Rolls‐Royce PLC
  • 8. References: [1]: The Development of the C Language, Dennis M. Ritchie, April 1993, http://cm.bell‐labs. com/cm/cs/who/dmr/chist.html (accessed 26 August 2014) 8 An Insight into MISRA C 2012 © 2014 Rolls‐Royce PLC
  • 9. 9 An Insight into MISRA C 2012 © 2014 Rolls‐Royce PLC
  • 10. References: [1] Annex G in ISO/IEC 9899:1990 [2] Annex J in ISO/IEC 9899:1999 Define a “safe” subset from the ISO/IEC9899 standard: • Prohibit the use of language features that have: • Undefined behaviour • Critical Unspecified behaviour • Implementation chosen behaviour The safe subset has Standard defined program semantics • Consistently and predictably understood by all ISO C Standard conforming tools 10 An Insight into MISRA C 2012 © 2014 Rolls‐Royce PLC
  • 11. Note: “goto” is generally read as a synonym for unstructured programming, and unstructured programmes can be hard to verify correctness, let alone maintain. Hence “unstructured programming” ≡ “bad programming”, therefore “goto” ≡ “bad programming”. However, there are perfectly legitimate uses of “goto” as part of a structured programming approach to the use of C. For example, where avoiding its use leads to more convoluted code that is potentially harder to understand (i.e. read) than if a “goto” had been used. Examples of this are jumping out of nested loops, dealing with exceptions, etc. This is often referred to as a “tamed goto”. 11 An Insight into MISRA C 2012 © 2014 Rolls‐Royce PLC
  • 12. MISRA C 2004 provides coverage for ISO/IEC 9899:1990 with TC1 (1995) (C90). MISRA C 2012 provides coverage for ISO/IEC 9899:1990 with TC1 (1995) (C90) and ISO/IEC 9899:1999 (C99) It says very little about: • Source code style That’s your business, but have one and be consistent • The software development process Have one Ideally requirements driven Bakes in the required qualities of the software Use it Collect evidence to prove it 12 An Insight into MISRA C 2012 © 2014 Rolls‐Royce PLC
  • 13. MISRA C 2012 has 159 guidelines. Divided into two classifications • Directives (16) • Rules (143) With three categories of compliance: • Mandatory (10) • Required (110) • Advisory (39) Rules are guidelines that have a complete description of what is required. Directives are guidelines that establish a principal, but one for which a complete description of what is required is not possible. In that sense, rules are precise about their C coding standard requirements and directives are abstract and require interpretation for each project and situation. The three categories of compliance set out a baseline expectation for claiming compliance to MISRA C. All mandatory guidelines must be satisfied. All required guidelines must be satisfied, except for those with explicit formal deviation statements. The advisory guidelines are recommendations that may (more freely) be deviated from. 13 An Insight into MISRA C 2012 © 2014 Rolls‐Royce PLC
  • 14. 116 of the guidelines are considered to be decidable. That’s 73% of the 159 guidelines or 81% of the 143 rules, since the directives are implicitly undecidable. Rule decidability is discussed in section 6.5 in MISRA C 2012. It also provides in Appendix B a list of the guidelines with their “analysis” attributes, which include decidability. 14 An Insight into MISRA C 2012 © 2014 Rolls‐Royce PLC
  • 15. Note: MISRA C 2012 formally recognises Project and Specific deviations. The “architectural category” of deviation is drawn out, in this presentation, as a specific subset of the Project deviation category to emphasis the point that different coding standard rules can be defined for each aspect of the software systems architecture as required. 15 An Insight into MISRA C 2012 © 2014 Rolls‐Royce PLC
  • 16. Note: MISRA C 2012 states in section 6.2.2 “An organization or project may choose to treat any required guidelines as if they were mandatory”, and in section 6.2.3 “An organization or project may choose to treat any advisory guideline as if they were mandatory or required”. See MISRA C 2012 section 5.4 for the formal deviation process requirements. 16 An Insight into MISRA C 2012 © 2014 Rolls‐Royce PLC
  • 17. The default position is that all language features considered “harmful” are prohibited, e.g. • goto (Rule 15.1) • union (Rule 19.2) Such features can be “enabled” by a deviation to the guideline that prohibits their direct use. However, finer grained guidelines typically provide constraint on the use of such language features, e.g. • Rule 15.1 The goto statement should not be used (advisory) • Rule 15.2 The goto statement shall jump to a label declared later in the same function (required) • Rule 15.3 Any label referenced by a goto statement shall be declared in the same block or in any block enclosing the goto statement (required) • Rule 15.4 “There should be no more than one break or goto statement used to terminate any iteration statement” (advisory) • Rule 9.1 “The value of an object with automatic storage duration shall not be read before it has been set” (mandatory) – which prevents the use of goto from skipping over initialiser statements. 17 An Insight into MISRA C 2012 © 2014 Rolls‐Royce PLC
  • 18. 18 An Insight into MISRA C 2012 © 2014 Rolls‐Royce PLC
  • 19. 19 An Insight into MISRA C 2012 © 2014 Rolls‐Royce PLC
  • 20. 20 An Insight into MISRA C 2012 © 2014 Rolls‐Royce PLC
  • 21. 21 An Insight into MISRA C 2012 © 2014 Rolls‐Royce PLC
  • 22. The page image in this slide, and on the following slides, is from reference [1]. In order to use MISRA C, it is necessary to develop and document:[2] • A compliance matrix, showing how compliance with each MISRA C guideline will be checked; • A deviation process by which justifiable non‐compliances can be authorized and recorded; • The demonstration that the project’s C code is MISRA C compliant subject to the project’s approved deviations; • The Project’s engineering process meets the process requirements detailed in sections 3, 4, & 5 and summarised in Appendix F (see next slide); • People involved in the development of MISRA C compliant C source code are competent to do so. Note that compliance can only be claimed for the software project.[3] References: [1]: MISRA C Guidelines for the use of the C language in critical systems, March 2013, MIRA Limited, ISBN 978‐906400‐10‐1 (paperback) [2]: Section §5.2.1 in [1] [3]: Section §5.5 in [1] 22 An Insight into MISRA C 2012 © 2014 Rolls‐Royce PLC
  • 23. Verification that C code complies with the guidelines precisely and absolutely is fraught with the difficulty of proving that the implementation of such checks are robust. Informal and semi‐formal techniques will be used and the project must address the risk of approving C code that could be shown to be non‐compliant. A typical strategy is to use more than one technique (and tool) for each guideline with the assumption that flawed checks in one do not overlap with the flaws in the other. This layered set of verification “defences” (often referred to as the “Swiss Cheese” model) should have as many layers of checking as required to satisfy the project’s risk/integrity profile. Thus, projects at the lower end of the risk/integrity scale may decide that a single static analysis tool in conjunction with the compiler’s checks, source code inspection, and dynamic testing are sufficient. Whereas a project at the higher end of the risk/integrity scale may opt for multiple static analysis tools from different vendors with different pedigrees, combined with a sophisticated dynamic test process that leverages multiple compiler technologies for multiple test platforms. The next slide illustrates a compliance matrix for a project that has determined that its risk/integrity profile are best served by two independent compilers and static analysis tools. 23 An Insight into MISRA C 2012 © 2014 Rolls‐Royce PLC
  • 24. Note: Table extracted from reference [2] References [1]: MISRA C Guidelines for the use of the C language in critical systems, March 2013, MIRA Limited, ISBN 978‐906400‐10‐1 (paperback) [2]: Section §5.3 in [1] 24 An Insight into MISRA C 2012 © 2014 Rolls‐Royce PLC
  • 25. This is essentially process definition and process execution evidence, with the spot light over those areas that concern MISRA C; e.g. procedures and evidence for the assessment of development tool fitness for purpose. See next slide for the summary check list. 25 An Insight into MISRA C 2012 © 2014 Rolls‐Royce PLC
  • 26. Note: Page extracted from reference [1] References: [1]: MISRA C Guidelines for the use of the C language in critical systems, March 2013, MIRA Limited, ISBN 978‐906400‐10‐1 (paperback) 26 An Insight into MISRA C 2012 © 2014 Rolls‐Royce PLC
  • 27. Required for compliance, but no explicit guidance is provided by MISRA C. However, a clear test of competency for critical systems software development with MISRA C 2012 is the knowledge that MISRA C is more than just about the adherence to its guidelines! (I.e. the process objectives set out in sections 3, 4, & 5.) 27 An Insight into MISRA C 2012 © 2014 Rolls‐Royce PLC
  • 28. 28 An Insight into MISRA C 2012 © 2014 Rolls‐Royce PLC
  • 29. A copy of MISRA C 2012 can be purchased from www.misra.org.uk in both PDF and paperback formats. 29 An Insight into MISRA C 2012 © 2014 Rolls‐Royce PLC
  • 30. 30 An Insight into MISRA C 2012 © 2014 Rolls‐Royce PLC
  • 31. 31 An Insight into MISRA C 2012 © 2014 Rolls‐Royce PLC