Writing Safety Critical Code Checklist

A best practice is a technique or methodology that, through experience and research, has proven to reliably lead to a desired result.  Use these recommended practices for writing code relating to systems where safety is critical.
 
How often should this be used?
Ad hoc as required.
 
Attribution:
Developed from the 'The Power of Ten -- Rules for Developing Safety Critical Code,'' IEEE Computer, June 2006, pp. 93-95 and this spinroot.com article
View Checklist

Writing Safety Critical Code

Writing Safety Critical Code

Restrict to simple control flow constructs.
Give all loops a fixed upper-bound.
Do not use dynamic memory allocation after initialization.
Limit functions to no more than 60 lines of text.
Use minimally two assertions per function on average.
Declare data objects at the smallest possible level of scope.
Check the return value of non-void functions, and check the validity of function parameters.
Limit the use of the preprocessor to file inclusion and simple macros.
Limit the use of pointers. Use no more than two levels of dereferencing per expression.
Compile with all warnings enabled, and use one or more source code analyzers.
Customize this template to suit your needs and get access to many more with Clever Checklist. Start Trial