What is MISRA? More Irrelevant Software Requirements Again…uh no but certainly the sentiment of many developers. MISRA (Motor Industry Software Reliability Association) is a coding standard, which first released MISRA C in 1998 and has since been revised. Obviously, this came out of the automotive sector with a clear focus on helping software systems to be more reliable and maintainable.
MISRA has since grown. Now you see more and more industries adopting these standards. In 2008, MISRA released the C++ equivalent standard. So the obvious question is, should I apply this to my software source code base? In short, yes. Maybe you don’t need ALL of the MISRA rules, but there are certainly some that are worth your time.
Examples range from the very simple checker rules sets that mostly fall into the coding style category:
MISRA C rule 19.1: All #include directives in a file shall only be preceded by other preprocessor directives or comments.
MISRA C rule 2.2: You should only use /*…*/ style comments.
Down to more important issues (I hope everyone has the tools in place to find this):
MISRA C rule 9.1: Unintialized variables.
It really depends what you’re trying to accomplish. Certain rules such as 9.1 are very important, while others can help you with portability or just serve to make your code more maintainable and less complex going forward.
Word of warning, taking an existing software code base and apply the entire MISRA rule set is guaranteed to throw many errors. Take the zlib project, obviously not MISRA compliant, but to illustrate the impact of turning on all the MISRA rules, will throw over 5000+ issues. That is an issue for every line of code…yeah that’s useful. So be warned, don’t try to boil the ocean. Start iteratively, even if that means only one rule at a time.


