Skip to content

Commit 81062d7

Browse files
Improves error message to clarify that value must be int, literal, AND zero.
1 parent 1e07871 commit 81062d7

File tree

2 files changed

+36
-34
lines changed

2 files changed

+36
-34
lines changed

cpp/misra/src/rules/RULE-22-4-1/InvalidAssignmentToErrno.ql

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,9 @@ where
2626
assign.getRValue().getExplicitlyConverted() = rvalue and
2727
(
2828
not rvalue instanceof LiteralZero and
29-
message = "Assignment to 'errno' with non-zero literal value '" + rvalue.toString() + "'."
29+
message =
30+
"Assignment to 'errno' with value '" + rvalue.toString() +
31+
"' that is not a zero integer literal."
3032
or
3133
assign instanceof AssignOperation and
3234
message =
Lines changed: 33 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1,37 +1,37 @@
1-
| test.cpp:26:3:26:13 | ... = ... | Assignment to 'errno' with non-zero literal value '0.0'. |
2-
| test.cpp:27:3:27:14 | ... = ... | Assignment to 'errno' with non-zero literal value '0.0'. |
3-
| test.cpp:31:3:31:11 | ... = ... | Assignment to 'errno' with non-zero literal value '1'. |
4-
| test.cpp:32:3:32:12 | ... = ... | Assignment to 'errno' with non-zero literal value '42'. |
5-
| test.cpp:33:3:33:12 | ... = ... | Assignment to 'errno' with non-zero literal value '- ...'. |
6-
| test.cpp:39:3:39:22 | ... = ... | Assignment to 'errno' with non-zero literal value '42'. |
7-
| test.cpp:49:3:49:12 | ... = ... | Assignment to 'errno' with non-zero literal value 'l1'. |
8-
| test.cpp:50:3:50:12 | ... = ... | Assignment to 'errno' with non-zero literal value 'l2'. |
9-
| test.cpp:51:3:51:12 | ... = ... | Assignment to 'errno' with non-zero literal value 'l3'. |
10-
| test.cpp:52:3:52:12 | ... = ... | Assignment to 'errno' with non-zero literal value 'l4'. |
11-
| test.cpp:53:3:53:12 | ... = ... | Assignment to 'errno' with non-zero literal value 'l5'. |
12-
| test.cpp:57:3:57:16 | ... = ... | Assignment to 'errno' with non-zero literal value '22'. |
13-
| test.cpp:58:3:58:16 | ... = ... | Assignment to 'errno' with non-zero literal value '34'. |
14-
| test.cpp:59:3:59:14 | ... = ... | Assignment to 'errno' with non-zero literal value '33'. |
15-
| test.cpp:63:3:63:15 | ... = ... | Assignment to 'errno' with non-zero literal value '... + ...'. |
16-
| test.cpp:64:3:64:15 | ... = ... | Assignment to 'errno' with non-zero literal value '... - ...'. |
17-
| test.cpp:65:3:65:15 | ... = ... | Assignment to 'errno' with non-zero literal value '... * ...'. |
18-
| test.cpp:66:3:66:35 | ... = ... | Assignment to 'errno' with non-zero literal value '... - ...'. |
19-
| test.cpp:70:3:70:11 | ... = ... | Assignment to 'errno' with non-zero literal value '5'. |
1+
| test.cpp:26:3:26:13 | ... = ... | Assignment to 'errno' with value '0.0' that is not a zero integer literal. |
2+
| test.cpp:27:3:27:14 | ... = ... | Assignment to 'errno' with value '0.0' that is not a zero integer literal. |
3+
| test.cpp:31:3:31:11 | ... = ... | Assignment to 'errno' with value '1' that is not a zero integer literal. |
4+
| test.cpp:32:3:32:12 | ... = ... | Assignment to 'errno' with value '42' that is not a zero integer literal. |
5+
| test.cpp:33:3:33:12 | ... = ... | Assignment to 'errno' with value '- ...' that is not a zero integer literal. |
6+
| test.cpp:39:3:39:22 | ... = ... | Assignment to 'errno' with value '42' that is not a zero integer literal. |
7+
| test.cpp:49:3:49:12 | ... = ... | Assignment to 'errno' with value 'l1' that is not a zero integer literal. |
8+
| test.cpp:50:3:50:12 | ... = ... | Assignment to 'errno' with value 'l2' that is not a zero integer literal. |
9+
| test.cpp:51:3:51:12 | ... = ... | Assignment to 'errno' with value 'l3' that is not a zero integer literal. |
10+
| test.cpp:52:3:52:12 | ... = ... | Assignment to 'errno' with value 'l4' that is not a zero integer literal. |
11+
| test.cpp:53:3:53:12 | ... = ... | Assignment to 'errno' with value 'l5' that is not a zero integer literal. |
12+
| test.cpp:57:3:57:16 | ... = ... | Assignment to 'errno' with value '22' that is not a zero integer literal. |
13+
| test.cpp:58:3:58:16 | ... = ... | Assignment to 'errno' with value '34' that is not a zero integer literal. |
14+
| test.cpp:59:3:59:14 | ... = ... | Assignment to 'errno' with value '33' that is not a zero integer literal. |
15+
| test.cpp:63:3:63:15 | ... = ... | Assignment to 'errno' with value '... + ...' that is not a zero integer literal. |
16+
| test.cpp:64:3:64:15 | ... = ... | Assignment to 'errno' with value '... - ...' that is not a zero integer literal. |
17+
| test.cpp:65:3:65:15 | ... = ... | Assignment to 'errno' with value '... * ...' that is not a zero integer literal. |
18+
| test.cpp:66:3:66:35 | ... = ... | Assignment to 'errno' with value '... - ...' that is not a zero integer literal. |
19+
| test.cpp:70:3:70:11 | ... = ... | Assignment to 'errno' with value '5' that is not a zero integer literal. |
2020
| test.cpp:71:3:71:12 | ... += ... | Compound assignment to 'errno' with operator '+=' is not allowed. |
21-
| test.cpp:72:3:72:12 | ... -= ... | Assignment to 'errno' with non-zero literal value '5'. |
21+
| test.cpp:72:3:72:12 | ... -= ... | Assignment to 'errno' with value '5' that is not a zero integer literal. |
2222
| test.cpp:72:3:72:12 | ... -= ... | Compound assignment to 'errno' with operator '-=' is not allowed. |
2323
| test.cpp:73:3:73:12 | ... *= ... | Compound assignment to 'errno' with operator '*=' is not allowed. |
24-
| test.cpp:74:3:74:12 | ... /= ... | Assignment to 'errno' with non-zero literal value '1'. |
24+
| test.cpp:74:3:74:12 | ... /= ... | Assignment to 'errno' with value '1' that is not a zero integer literal. |
2525
| test.cpp:74:3:74:12 | ... /= ... | Compound assignment to 'errno' with operator '/=' is not allowed. |
26-
| test.cpp:81:3:81:14 | ... = ... | Assignment to 'errno' with non-zero literal value 'call to operator()'. |
27-
| test.cpp:82:3:82:14 | ... = ... | Assignment to 'errno' with non-zero literal value 'call to operator()'. |
28-
| test.cpp:86:3:86:29 | ... = ... | Assignment to 'errno' with non-zero literal value 'static_cast<int>...'. |
29-
| test.cpp:87:3:87:31 | ... = ... | Assignment to 'errno' with non-zero literal value 'static_cast<int>...'. |
30-
| test.cpp:88:3:88:16 | ... = ... | Assignment to 'errno' with non-zero literal value '(int)...'. |
31-
| test.cpp:89:3:89:16 | ... = ... | Assignment to 'errno' with non-zero literal value '(int)...'. |
32-
| test.cpp:108:3:108:40 | ... = ... | Assignment to 'errno' with non-zero literal value 'reinterpret_cast<int>...'. |
33-
| test.cpp:110:3:110:35 | ... = ... | Assignment to 'errno' with non-zero literal value 'reinterpret_cast<int>...'. |
34-
| test.cpp:111:3:111:35 | ... = ... | Assignment to 'errno' with non-zero literal value 'reinterpret_cast<int>...'. |
35-
| test.cpp:113:3:113:40 | ... = ... | Assignment to 'errno' with non-zero literal value 'reinterpret_cast<int>...'. |
36-
| test.cpp:122:3:122:13 | ... = ... | Assignment to 'errno' with non-zero literal value '48'. |
37-
| test.cpp:128:3:128:14 | ... = ... | Assignment to 'errno' with non-zero literal value '1'. |
26+
| test.cpp:81:3:81:14 | ... = ... | Assignment to 'errno' with value 'call to operator()' that is not a zero integer literal. |
27+
| test.cpp:82:3:82:14 | ... = ... | Assignment to 'errno' with value 'call to operator()' that is not a zero integer literal. |
28+
| test.cpp:86:3:86:29 | ... = ... | Assignment to 'errno' with value 'static_cast<int>...' that is not a zero integer literal. |
29+
| test.cpp:87:3:87:31 | ... = ... | Assignment to 'errno' with value 'static_cast<int>...' that is not a zero integer literal. |
30+
| test.cpp:88:3:88:16 | ... = ... | Assignment to 'errno' with value '(int)...' that is not a zero integer literal. |
31+
| test.cpp:89:3:89:16 | ... = ... | Assignment to 'errno' with value '(int)...' that is not a zero integer literal. |
32+
| test.cpp:108:3:108:40 | ... = ... | Assignment to 'errno' with value 'reinterpret_cast<int>...' that is not a zero integer literal. |
33+
| test.cpp:110:3:110:35 | ... = ... | Assignment to 'errno' with value 'reinterpret_cast<int>...' that is not a zero integer literal. |
34+
| test.cpp:111:3:111:35 | ... = ... | Assignment to 'errno' with value 'reinterpret_cast<int>...' that is not a zero integer literal. |
35+
| test.cpp:113:3:113:40 | ... = ... | Assignment to 'errno' with value 'reinterpret_cast<int>...' that is not a zero integer literal. |
36+
| test.cpp:122:3:122:13 | ... = ... | Assignment to 'errno' with value '48' that is not a zero integer literal. |
37+
| test.cpp:128:3:128:14 | ... = ... | Assignment to 'errno' with value '1' that is not a zero integer literal. |

0 commit comments

Comments
 (0)