Skip to content

Commit add33b1

Browse files
committed
Address review feedback
1 parent 578a35f commit add33b1

File tree

4 files changed

+13
-11
lines changed

4 files changed

+13
-11
lines changed

cpp/misra/src/rules/RULE-10-1-2/VolatileQualifierNotUsedAppropriately.ql

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
/**
22
* @id cpp/misra/volatile-qualifier-not-used-appropriately
33
* @name RULE-10-1-2: The volatile qualifier shall be used appropriately
4-
* @description Using the volatile qualifier on certain entities can lead to undefined behavior or
5-
* code that is hard to understand.
4+
* @description Using the volatile qualifier on certain entities has behavior that is not
5+
* well-defined and can make code harder to understand, especially as its application
6+
* to these entities does not prevent data races or guarantee safe multithreading.
67
* @kind problem
78
* @precision very-high
89
* @problem.severity error
@@ -28,4 +29,4 @@ where
2829
d instanceof Function or
2930
d.(Variable).isStructuredBinding()
3031
)
31-
select d, "Volatile entity declared."
32+
select d, "Volatile entity '" + d.getName() + "' declared."
Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
| test.cpp:2:16:2:16 | g1 | Volatile entity declared. |
2-
| test.cpp:4:21:4:21 | p | Volatile entity declared. |
3-
| test.cpp:5:16:5:16 | x | Volatile entity declared. |
4-
| test.cpp:9:18:9:18 | a | Volatile entity declared. |
5-
| test.cpp:12:14:12:15 | f1 | Volatile entity declared. |
6-
| test.cpp:15:23:15:23 | p | Volatile entity declared. |
7-
| test.cpp:19:16:19:16 | m | Volatile entity declared. |
1+
| test.cpp:2:16:2:16 | g1 | Volatile entity 'g1' declared. |
2+
| test.cpp:5:21:5:21 | p | Volatile entity 'p' declared. |
3+
| test.cpp:6:16:6:16 | x | Volatile entity 'x' declared. |
4+
| test.cpp:10:18:10:18 | a | Volatile entity 'a' declared. |
5+
| test.cpp:13:14:13:15 | f1 | Volatile entity 'f1' declared. |
6+
| test.cpp:16:23:16:23 | p | Volatile entity 'p' declared. |
7+
| test.cpp:20:16:20:16 | m | Volatile entity 'm' declared. |

cpp/misra/test/rules/RULE-10-1-2/test.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
int g[1] = {1};
22
auto volatile [g1] = g; // NON_COMPLIANT
3+
volatile int g2; // COMPLIANT
34

45
void f(volatile int p) { // NON_COMPLIANT
56
volatile int x = 1; // NON_COMPLIANT

rule_packages/cpp/Declarations4.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
},
88
"queries": [
99
{
10-
"description": "Using the volatile qualifier on certain entities can lead to undefined behavior or code that is hard to understand.",
10+
"description": "Using the volatile qualifier on certain entities has behavior that is not well-defined and can make code harder to understand, especially as its application to these entities does not prevent data races or guarantee safe multithreading.",
1111
"kind": "problem",
1212
"name": "The volatile qualifier shall be used appropriately",
1313
"precision": "very-high",

0 commit comments

Comments
 (0)