![]() |
![]() |
2020 | ![]() |
||||
![]() | |||||||
| Switch statements | |||||||
The final 'case' or 'default' clause in this switch statement is not terminated with a jump statement. Although a 'break' statement is redundant in this context, it may be wise to include one in case an additional switch clause is added at a later time. Message 2020 is generated whenever the final clause of a switch statement is not terminated with either a 'break', a 'return', a 'continue' or a 'goto' statement. For example:
/*PRQA S 2006,2017,3120,3227,3408 ++*/
extern int f1(int value)
{
int r;
switch (value)
{
case 1:
r = 10;
break;
case 2:
r = 20;
break;
default:
r = 0;
} /* Message 2020 */
return r;
}
extern int f2(int value)
{
int r;
switch (value)
{
case 1:
return 10;
case 2:
return 20;
default:
r = 0;
} /* Message 2020 */
return r;
}
See also:
![]() | ||
| QA·C Source Code Analyser 8.1.2
© 2013 Programming Research. www.programmingresearch.com | Personality Groups | Glossary | Message Index | Contents |