PREfast Warning 241 (Windows CE 5.0)
241 - Value returned from the finally-block overrides the value returned from its corresponding try-block.
Additional Information: See previous return at <location>.
This warning indicates that return statements occur in both the protected and handler blocks of a try/finally statement.
When a value is returned from both the protected and handler blocks of a try/finally statement, the last value returned (the one from the finally block) wins.
Example
Defective Source
__try {
if (rand()) {
return 1;
}
} __finally {
if (rand()) {
return 2;
}
}
Corrected Source
int RetVal;
__try {
if (rand()) {
RetVal = 1;
__leave;
}
} __finally {
if (rand()) {
RetVal = 2;
}
}
return RetVal;
Send Feedback on this topic to the authors