Skip to content

Commit 17537bb

Browse files
author
Robert Marsh
committed
C++: respond to doc comments
1 parent 61f3384 commit 17537bb

File tree

4 files changed

+13
-13
lines changed

4 files changed

+13
-13
lines changed

change-notes/1.19/analysis-cpp.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,10 @@
66

77
| **Query** | **Tags** | **Purpose** |
88
|-----------------------------|-----------|--------------------------------------------------------------------|
9-
| Cast between HRESULT and a Boolean type (`cpp/hresult-boolean-conversion`) | external/cwe/cwe-253 | Finds logic errors caused by mistakenly treating the Windows `HRESULT` type as a Boolean instead of testing it with the appropriate macros. Enabled by default. |
9+
| Cast between `HRESULT` and a Boolean type (`cpp/hresult-boolean-conversion`) | external/cwe/cwe-253 | Finds logic errors caused by mistakenly treating the Windows `HRESULT` type as a Boolean instead of testing it with the appropriate macros. Enabled by default. |
1010
| Setting a DACL to `NULL` in a `SECURITY_DESCRIPTOR` (`cpp/unsafe-dacl-security-descriptor`) | external/cwe/cwe-732 | This query finds code that creates world-writable objects on Windows by setting their DACL to `NULL`. Enabled by default. |
11-
| Cast from char* to wchar_t* | security, external/cwe/cwe-704 | Detects potentially dangerous casts from char* to wchar_t*. Enabled by default on LGTM. |
12-
| Dead code due to goto or break statement (`cpp/dead-code-goto`) | maintainability, external/cwe/cwe-561 | Detects dead code following a goto or break statement. Enabled by default on LGTM. |
11+
| Cast from `char*` to `wchar_t*` | security, external/cwe/cwe-704 | Detects potentially dangerous casts from `char*` to `wchar_t*`. Enabled by default on LGTM. |
12+
| Dead code due to `goto` or `break` statement (`cpp/dead-code-goto`) | maintainability, external/cwe/cwe-561 | Detects dead code following a goto or break statement. Enabled by default on LGTM. |
1313

1414
## Changes to existing queries
1515

cpp/ql/src/Critical/DeadCodeGoto.qhelp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,23 +6,23 @@
66

77
<overview>
88
<p>
9-
Code following a goto or break statement will not be executed, unless there is a label or switch
10-
case. When the code is necessary, this leads to logical errors or resource leaks. If the code is
11-
unnecessary, it may confuse readers.
9+
Code immediately following a <code>goto</code> or <code>break</code> statement will not be executed,
10+
unless there is a label or switch case. When the code is necessary, this leads to logical errors or
11+
resource leaks. If the code is unnecessary, it may confuse readers.
1212
</p>
1313
</overview>
1414
<recommendation>
1515
<p>
16-
If the unreachable code is necessary, move the goto or break statement to after the code.
17-
Otherwise, delete the unreachable code.
16+
If the unreachable code is necessary, move the <code>goto</code> or <code>break</code> statement to
17+
after the code. Otherwise, delete the unreachable code.
1818
</p>
1919

2020
</recommendation>
2121
<example><sample src="DeadCodeGoto.cpp" />
2222
</example>
2323
<references>
2424
<li>
25-
The CERT C Secure Coding Standard: <a href="https://wiki.sei.cmu.edu/confluence/display/c/MSC12-C.+Detect+and+remove+code+that+has+no+effect+or+is+never+executed">MSC12-C. Detect and remove code that has no effect or is never executed</a>
25+
The CERT C Secure Coding Standard: <a href="https://wiki.sei.cmu.edu/confluence/display/c/MSC12-C.+Detect+and+remove+code+that+has+no+effect+or+is+never+executed">MSC12-C. Detect and remove code that has no effect or is never executed</a>.
2626
</li>
2727
</references>
2828
</qhelp>

cpp/ql/src/Critical/DeadCodeGoto.ql

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,4 +29,4 @@ where b.getStmt(i) = js
2929
and not s.(BreakStmt).getBreakable() instanceof SwitchStmt
3030
// the jump isn't a goto into the body of the next statement
3131
and not exists (LabelStmt ls | s.(Loop).getStmt().getAChild*() = ls | ls.getName() = js.(GotoStmt).getName())
32-
select js, "This statement makes $@ dead.", s, s.toString()
32+
select js, "This statement makes $@ unreachable.", s, s.toString()
Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
| test.cpp:2:2:2:12 | goto ... | This statement makes $@ dead. | test.cpp:3:2:3:5 | ExprStmt | ExprStmt |
2-
| test.cpp:9:3:9:8 | break; | This statement makes $@ dead. | test.cpp:10:3:10:6 | ExprStmt | ExprStmt |
3-
| test.cpp:37:3:37:8 | break; | This statement makes $@ dead. | test.cpp:38:3:38:11 | return ... | return ... |
1+
| test.cpp:2:2:2:12 | goto ... | This statement makes $@ unreachable. | test.cpp:3:2:3:5 | ExprStmt | ExprStmt |
2+
| test.cpp:9:3:9:8 | break; | This statement makes $@ unreachable. | test.cpp:10:3:10:6 | ExprStmt | ExprStmt |
3+
| test.cpp:37:3:37:8 | break; | This statement makes $@ unreachable. | test.cpp:38:3:38:11 | return ... | return ... |

0 commit comments

Comments
 (0)