Search:

PmWiki

pmwiki.org

edit SideBar

Main / Misra

Intro

In 2013, this was the most widely used C language standard throughout the world. One interpretation is that it's less of a standard, and more a subset definition of the C language. The point is to help guide in making code portable, debuggable, readable, and more robust. The standard is a nice collection of best practices that are often referenced in many industries besides automotive.

It's different from DO-178 in that there is no official cert process. There are automated tools that check for compliance. Compliance can only be claimed per product, not per organization.

Three levels of guideline Category: Mandatory, Required, Advisory

One way that an expert has described the meaning of "compliant code" is Enforceability, Decidability, and Deviation. For example, ability to detect maximum number of possible violations is important in tool selection, and there must be a process in place to handle deviations in the code.

The layout of the standard's guidelines is as follows:
Rule/Directive ID and text
Category
Analysis scope
C language version applicability
Rationale
Code Example 

Guideline Spotlight

Hot Topics

The C enum: https://stackoverflow.com/questions/10589684/misra-violation-rule-10-1-and-enums and https://www.misra.org.uk/forum/viewtopic.php?t=1091

Rules of Interest

  • 2012:15.5 A function should have a single point of exit at end, no in-body returns
  • 2012:17.7 Value returned from non-void function shall be used
  • 2012:18.5 No more than two levels of pointer nesting
  • 2012:18.8 No variable-length array types
  • 2012:19.2 No unions
  • 2012:20.1 #include only at top of file
  • 2012:21.7-10 Various functions of stdlib.h shall not be used, such as string conversion, search/sort, time/date

Page last modified on April 11, 2019, at 06:29 PM