Mode:
Duration:
1
Coding works best on desktop or with an external keyboard.
Coding works best on desktop or with an external keyboard.
Maintain a single return point in functions.
/* Non-compliant */
int compute(int x) {
if (x < 0) return -1;
return x * 2;
}
/* Compliant */
int compute(int x) {
int result;
if (x < 0) {
result = -1;
} else {
result = x * 2;
}
return result;
}MISRA C and MISRA C++ are coding standards developed to facilitate safety, reliability, and maintainability in embedded systems, especially in automotive, aerospace, and critical industries.
Origin & Creator
Created by the Motor Industry Software Reliability Association (MISRA) in 1998, initially for the automotive industry; later expanded to C++ and broader safety-critical domains.
Industrial Note
Extensively used in automotive ECUs, aerospace flight control software, industrial PLC firmware, and other high-integrity embedded systems.