I am working on embedded program and in certain cases if a condition is not meant, I would like to return from function as quickly as possible. if I have the following code and I am doing embedded programming:
foo() {
if (a < b) {
return 0; // bail, since condition is met
} else {
// lots of calculations in this block
}
return 1;
}
My question is, is it bad having multiple return statements? Is it bad practice? Are there better methods? Does MISRA say anything about it?
NOTE: This question is particular to Embedded Systems, has to do with MISRA not just C/C++
Thanks...