Suppress generation of default cases for Stateflow switch statements if unreachable

Description

Specify whether to generate default cases for switch-case statements in the code for Stateflow® charts. This optimization works on a per-model basis. It applies to the code generated for a state that has multiple substates. For a list of the state functions in the generated code, see Inline State Functions in Generated Code.

Category: Code Generation > Code Style

Settings

Default: on

On

Do not generate the default case when it is unreachable. This setting enables better code coverage because every branch in the generated code is falsifiable.

Off

Generate a default case whether or not it is reachable. This setting supports MISRA C® compliance and provides a backup in case of RAM corruption.

For example, when the state has a nontrivial entry function, the following default case appears in the generated code for the during function:

default:
 entry_internal();
 break;

In this case, the code marks the corresponding substate as active.

Command-Line Information

Parameter: SuppressUnreachableDefaultCases
Type: character vector
Value: 'on' | 'off'
Default: 'on'

Recommended Settings

ApplicationSetting
DebuggingNoimpact
TraceabilityOn
EfficiencyOn (execution, ROM), Noimpact (RAM)
Safety precaution

No recommendation

Related Topics