09-01-2008, 05:12 PM
When writing code for safety-critical systems, I have always considered treating all RAM locations to be \"volatile\" in nature. If I have code which can set a 16 bit unsigned integer (represeting an enum) explicitly to the values of 0, 1, 2, and 3, I also always handle the cases of it being any other value the storage may select, i.e. 4 to 65535.
Given
Treat color to be volatile, and assume that a failure mechanisum WILL exist to randomly set it.
Given this, the need for the default clause is not in question. (imho)
George
Given
Code:
typedef enum {
red,
green,
blue
} color_t;
...
color_t color;
...
color = red;
...
{
switch (color) {
case red:
/* do something */
break;
case green:
/* do something */
break;
case blue:
/* do something */
}
Treat color to be volatile, and assume that a failure mechanisum WILL exist to randomly set it.
Given this, the need for the default clause is not in question. (imho)
George