-
Type:
Finding Detection
-
Status: Closed
-
Resolution: Won't Fix
-
Labels:
-
Message:Refactor this null statement line to match <whitespaces> ; <whitespace> <comment>
-
Default Severity:Major
-
Impact:Low
-
Likelihood:High
-
Targeted languages:C, C++
-
Remediation Function:Constant/Issue
-
Constant Cost:5mn
-
MISRA C 2004:14.3
-
MISRA C++ 2008:6-2-3
Null statements should not normally be included deliberately, but where they are used, they shall appear on a line by themselves. White-space characters may precede the null statement to preserve indentation. If a comment follows the null statement, then at least one white-space character shall separate the null statement from the comment. The use of a white-space character to separate the null statement from any following comment is required on the grounds that it provides an important visual cue to reviewers. Following this rule enables a static checking tool to warn of null statements appearing on a line with other text, which would normally indicate a programming error.
Noncompliant Code Example
while ( ( port & 0x80 ) == 0 ) { /* wait for pin */ ; // Noncompliant, comment before ; ;// wait for pin - Noncompliant, no white-space char after ; }
Compliant Solution
while ( ( port & 0x80 ) == 0 ) { ; // wait for pin - Compliant }
See Also
- MISRA C:2004, 14.3
- MISRA C++:2008, 6-2-3
- is related to
-
RSPEC-139 Comments should not be located at the end of lines of code
- Active
-
RSPEC-1116 Empty statements should be removed
- Active