Rule Definition
If a label is declared but not used, then it is unclear to a reviewer if the label is redundant or it has
been left unused by mistake.
Remediation
Remove unused labels
Violation Code Sample
void unused_label ( void )
{
int16_t x = 6;
label1: use_int16 ( x ); /* Non-compliant */
}
Fixed Code Sample
void unused_label ( void )
{
.
{
.
.
goto label1;
}
.
.
.
int16_t x = 6;
label1: use_int16 ( x ); /* Non-compliant */
}
Reference
Standards Reference:
MISRA C 2012 - 2.6: A function should not contain unused label declarations
Related Technologies
Technical Criterion
CWE-561 - Dead Code
About CAST Appmarq
CAST Appmarq is by far the biggest repository of data about real IT systems. It's built on thousands of analyzed applications, made of 35 different technologies, by over 300 business organizations across major verticals. It provides IT Leaders with factual key analytics to let them know if their applications are on track.