Skip to content

Commit 97fabeb

Browse files
authored
Merge pull request #820 from github/michaelrfairhurst/implement-misra-amendment-clarifications
Implement MISRA-C clarifications from amendments3, 4, at TC2.
2 parents 55362d0 + 9beb4e3 commit 97fabeb

22 files changed

+59
-52
lines changed

amendments.csv

+27-26
Original file line numberDiff line numberDiff line change
@@ -9,41 +9,42 @@ c,MISRA-C-2012,Amendment3,RULE-10-4,Yes,Refine,No,Import
99
c,MISRA-C-2012,Amendment3,RULE-10-5,Yes,Expand,No,Easy
1010
c,MISRA-C-2012,Amendment3,RULE-10-7,Yes,Refine,No,Import
1111
c,MISRA-C-2012,Amendment3,RULE-10-8,Yes,Refine,No,Import
12-
c,MISRA-C-2012,Amendment3,RULE-21-11,Yes,Clarification,No,Import
12+
c,MISRA-C-2012,Amendment3,RULE-21-11,Yes,Clarification,Yes,Import
1313
c,MISRA-C-2012,Amendment3,RULE-21-12,Yes,Replace,No,Easy
1414
c,MISRA-C-2012,Amendment4,RULE-11-3,Yes,Expand,No,Easy
1515
c,MISRA-C-2012,Amendment4,RULE-11-8,Yes,Expand,No,Easy
1616
c,MISRA-C-2012,Amendment4,RULE-13-2,Yes,Expand,No,Very Hard
1717
c,MISRA-C-2012,Amendment4,RULE-18-6,Yes,Expand,No,Medium
1818
c,MISRA-C-2012,Amendment4,RULE-18-8,Yes,Split,Yes,Easy
19-
c,MISRA-C-2012,Corrigendum2,RULE-2-2,Yes,Clarification,No,Import
20-
c,MISRA-C-2012,Corrigendum2,RULE-2-7,Yes,Clarification,No,Import
21-
c,MISRA-C-2012,Corrigendum2,RULE-3-1,Yes,Refine,No,Easy
22-
c,MISRA-C-2012,Corrigendum2,RULE-8-6,Yes,Clarification,No,Import
23-
c,MISRA-C-2012,Corrigendum2,RULE-8-9,Yes,Clarification,No,Import
24-
c,MISRA-C-2012,Corrigendum2,RULE-9-4,Yes,Clarification,No,Import
25-
c,MISRA-C-2012,Corrigendum2,RULE-10-1,Yes,Clarification,No,Import
26-
c,MISRA-C-2012,Corrigendum2,RULE-18-3,Yes,Clarification,No,Import
27-
c,MISRA-C-2012,Corrigendum2,RULE-1-4,Yes,Replace,No,Easy
28-
c,MISRA-C-2012,Corrigendum2,RULE-9-1,Yes,Refine,No,Easy
29-
c,MISRA-C-2012,Corrigendum2,RULE-9-2,Yes,Refine,No,Import
30-
c,MISRA-C-2012,Corrigendum2,DIR-4-10,Yes,Clarification,No,Import
19+
c,MISRA-C-2012,Amendment4,RULE-2-2,Yes,Clarification,Yes,Import
20+
c,MISRA-C-2012,Amendment4,RULE-2-7,Yes,Clarification,Yes,Import
21+
c,MISRA-C-2012,Amendment4,RULE-3-1,Yes,Refine,No,Easy
22+
c,MISRA-C-2012,Amendment4,RULE-8-6,Yes,Clarification,Yes,Import
23+
c,MISRA-C-2012,Amendment4,RULE-8-9,Yes,Clarification,Yes,Import
24+
c,MISRA-C-2012,Amendment4,RULE-9-4,Yes,Clarification,Yes,Import
25+
c,MISRA-C-2012,Amendment4,RULE-10-1,Yes,Clarification,Yes,Import
26+
c,MISRA-C-2012,Amendment4,RULE-18-3,Yes,Clarification,Yes,Import
27+
c,MISRA-C-2012,Amendment4,RULE-1-4,Yes,Replace,No,Easy
28+
c,MISRA-C-2012,Amendment4,RULE-9-1,Yes,Refine,No,Easy
29+
c,MISRA-C-2012,Amendment4,RULE-9-2,Yes,Refine,No,Import
30+
c,MISRA-C-2012,Corrigendum2,DIR-4-10,Yes,Clarification,Yes,Import
3131
c,MISRA-C-2012,Corrigendum2,RULE-7-4,Yes,Refine,No,Easy
32-
c,MISRA-C-2012,Corrigendum2,RULE-8-2,Yes,Clarification,No,Import
32+
c,MISRA-C-2012,Corrigendum2,RULE-8-2,Yes,Clarification,Yes,Import
3333
c,MISRA-C-2012,Corrigendum2,RULE-8-3,Yes,Refine,No,Easy
34-
c,MISRA-C-2012,Corrigendum2,RULE-8-7,Yes,Clarification,No,Import
34+
c,MISRA-C-2012,Corrigendum2,RULE-8-7,Yes,Clarification,Yes,Import
35+
c,MISRA-C-2012,Corrigendum2,RULE-10-1,Yes,Clarification,Yes,Import
3536
c,MISRA-C-2012,Corrigendum2,RULE-10-2,Yes,Refine,No,Easy
36-
c,MISRA-C-2012,Corrigendum2,RULE-10-3,Yes,Clarification,No,Import
37-
c,MISRA-C-2012,Corrigendum2,RULE-11-3,Yes,Clarification,No,Import
38-
c,MISRA-C-2012,Corrigendum2,RULE-11-6,Yes,Clarification,No,Import
39-
c,MISRA-C-2012,Corrigendum2,RULE-13-2,Yes,Clarification,No,Import
40-
c,MISRA-C-2012,Corrigendum2,RULE-13-6,Yes,Clarification,No,Import
37+
c,MISRA-C-2012,Corrigendum2,RULE-10-3,Yes,Clarification,Yes,Import
38+
c,MISRA-C-2012,Corrigendum2,RULE-11-3,Yes,Clarification,Yes,Import
39+
c,MISRA-C-2012,Corrigendum2,RULE-11-6,Yes,Clarification,Yes,Import
40+
c,MISRA-C-2012,Corrigendum2,RULE-13-2,Yes,Clarification,Yes,Import
41+
c,MISRA-C-2012,Corrigendum2,RULE-13-6,Yes,Clarification,Yes,Import
4142
c,MISRA-C-2012,Corrigendum2,RULE-14-3,Yes,Refine,No,Easy
42-
c,MISRA-C-2012,Corrigendum2,RULE-15-7,Yes,Clarification,No,Import
43-
c,MISRA-C-2012,Corrigendum2,RULE-17-4,Yes,Clarification,No,Import
44-
c,MISRA-C-2012,Corrigendum2,RULE-17-5,Yes,Clarification,No,Import
43+
c,MISRA-C-2012,Corrigendum2,RULE-15-7,Yes,Clarification,Yes,Import
44+
c,MISRA-C-2012,Corrigendum2,RULE-17-4,Yes,Clarification,Yes,Import
45+
c,MISRA-C-2012,Corrigendum2,RULE-17-5,Yes,Clarification,Yes,Import
4546
c,MISRA-C-2012,Corrigendum2,RULE-18-1,Yes,Refine,No,Easy
46-
c,MISRA-C-2012,Corrigendum2,RULE-20-14,No,Clarification,No,Import
47-
c,MISRA-C-2012,Corrigendum2,RULE-21-19,Yes,Clarification,No,Import
47+
c,MISRA-C-2012,Corrigendum2,RULE-20-14,No,Clarification,Yes,Import
48+
c,MISRA-C-2012,Corrigendum2,RULE-21-19,Yes,Clarification,Yes,Import
4849
c,MISRA-C-2012,Corrigendum2,RULE-21-20,Yes,Refine,No,Easy
49-
c,MISRA-C-2012,Corrigendum2,RULE-22-9,Yes,Clarification,No,Import
50+
c,MISRA-C-2012,Corrigendum2,RULE-22-9,Yes,Clarification,Yes,Import

c/misra/src/rules/RULE-13-6/SizeofOperandWithSideEffect.ql

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
* @tags external/misra/id/rule-13-6
1010
* correctness
1111
* external/misra/c/2012/third-edition-first-revision
12-
* external/misra/obligation/mandatory
12+
* external/misra/obligation/required
1313
*/
1414

1515
import cpp

c/misra/src/rules/RULE-17-5/ArrayFunctionArgumentNumberOfElements.ql

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
* @tags external/misra/id/rule-17-5
1010
* correctness
1111
* external/misra/c/2012/third-edition-first-revision
12-
* external/misra/obligation/advisory
12+
* external/misra/obligation/required
1313
*/
1414

1515
import cpp

c/misra/src/rules/RULE-21-11/StandardHeaderFileTgmathhUsed.ql

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
* @tags external/misra/id/rule-21-11
99
* correctness
1010
* external/misra/c/2012/third-edition-first-revision
11-
* external/misra/obligation/required
11+
* external/misra/obligation/advisory
1212
*/
1313

1414
import cpp
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
- `RULE-13-6` - `SizeofOperandWithSideEffect.ql`:
2+
- Changed from Mandatory to Required in implementation of Technical Corrigenda 2.
3+
- `RULE-17-5` - `ArrayFunctionArgumentNumberOfElements.ql`:
4+
- Changed from Advisory to Required in implementation of Technical Corrigenda 2.
5+
- `RULE-21-11` - `StandardHeaderFileTgmathhUsed.ql`:
6+
- Changed from Required to Advisory in implementation of Amendment 3.

cpp/common/src/codingstandards/cpp/exclusions/c/Banned.qll

+1-1
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ predicate isBannedQueryMetadata(Query query, string queryId, string ruleId, stri
7777
// `@id` for the `standardHeaderFileTgmathhUsed` query
7878
"c/misra/standard-header-file-tgmathh-used" and
7979
ruleId = "RULE-21-11" and
80-
category = "required"
80+
category = "advisory"
8181
or
8282
query =
8383
// `Query` instance for the `exceptionHandlingFeaturesOfFenvhUsed` query

cpp/common/src/codingstandards/cpp/exclusions/c/Contracts6.qll

+1-1
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ predicate isContracts6QueryMetadata(Query query, string queryId, string ruleId,
2525
// `@id` for the `arrayFunctionArgumentNumberOfElements` query
2626
"c/misra/array-function-argument-number-of-elements" and
2727
ruleId = "RULE-17-5" and
28-
category = "advisory"
28+
category = "required"
2929
or
3030
query =
3131
// `Query` instance for the `valueReturnedByAFunctionNotUsed` query

cpp/common/src/codingstandards/cpp/exclusions/c/SideEffects1.qll

+1-1
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ predicate isSideEffects1QueryMetadata(Query query, string queryId, string ruleId
104104
// `@id` for the `sizeofOperandWithSideEffect` query
105105
"c/misra/sizeof-operand-with-side-effect" and
106106
ruleId = "RULE-13-6" and
107-
category = "mandatory"
107+
category = "required"
108108
}
109109

110110
module SideEffects1Package {

cpp/common/test/deviations/invalid_deviations/coding-standards.xml

+2-2
Original file line numberDiff line numberDiff line change
@@ -83,8 +83,8 @@
8383
<permit-id>DP2</permit-id>
8484
</deviations-entry>
8585
<deviations-entry>
86-
<rule-id>RULE-13-6</rule-id>
87-
<query-id>c/misra/sizeof-operand-with-side-effect</query-id>
86+
<rule-id>RULE-9-1</rule-id>
87+
<query-id>c/misra/object-with-auto-storage-duration-read-before-init</query-id>
8888
</deviations-entry>
8989
</deviations>
9090
<deviation-permits>

cpp/common/test/deviations/invalid_deviations/coding-standards.yml

+2-2
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,8 @@ deviations:
4444
permit-id: non-existing-permit
4545
- permit-id: DP1
4646
- permit-id: DP2
47-
- rule-id: RULE-13-6
48-
query-id: c/misra/sizeof-operand-with-side-effect
47+
- rule-id: RULE-9-1
48+
query-id: c/misra/object-with-auto-storage-duration-read-before-init
4949
deviation-permits:
5050
- permit-id: DP1
5151
justification: foo bar baz
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
| invalid/coding-standards.xml:5:7:8:43 | guideline-recategorizations-entry | guideline_recategorizations/invalid/coding-standards.xml: 'Invalid recategorization from 'required' to 'advisory'.' for rule A0-1-1. |
22
| invalid/coding-standards.xml:9:7:12:43 | guideline-recategorizations-entry | guideline_recategorizations/invalid/coding-standards.xml: 'Invalid recategorization from 'required' to 'disapplied'.' for rule A0-1-2. |
33
| invalid/coding-standards.xml:13:7:16:43 | guideline-recategorizations-entry | guideline_recategorizations/invalid/coding-standards.xml: 'Unknown rule id 'A1-4-3'.' for rule A1-4-3. |
4-
| invalid/coding-standards.xml:17:7:20:43 | guideline-recategorizations-entry | guideline_recategorizations/invalid/coding-standards.xml: 'Invalid recategorization from 'mandatory' to 'required'.' for rule RULE-13-6. |
4+
| invalid/coding-standards.xml:17:7:20:43 | guideline-recategorizations-entry | guideline_recategorizations/invalid/coding-standards.xml: 'Invalid recategorization from 'mandatory' to 'required'.' for rule RULE-9-1. |
55
| invalid/coding-standards.xml:21:7:24:43 | guideline-recategorizations-entry | guideline_recategorizations/invalid/coding-standards.xml: 'Invalid recategorization from 'rule' to 'required'.' for rule CON50-CPP. |

cpp/common/test/guideline_recategorizations/ListGuidelineRecategorizations.expected

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,4 @@
55
| A10-4-1 | advisory | required |
66
| A11-0-1 | advisory | mandatory |
77
| CON50-CPP | rule | required |
8-
| RULE-13-6 | mandatory | required |
8+
| RULE-9-1 | mandatory | required |

cpp/common/test/guideline_recategorizations/invalid/coding-standards.xml

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
<category>mandatory</category>
1616
</guideline-recategorizations-entry>
1717
<guideline-recategorizations-entry>
18-
<rule-id>RULE-13-6</rule-id>
18+
<rule-id>RULE-9-1</rule-id>
1919
<category>required</category>
2020
</guideline-recategorizations-entry>
2121
<guideline-recategorizations-entry>

cpp/common/test/guideline_recategorizations/invalid/coding-standards.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ guideline-recategorizations:
55
category: "disapplied"
66
- rule-id: "A1-4-3"
77
category: "mandatory"
8-
- rule-id: "RULE-13-6"
8+
- rule-id: "RULE-9-1"
99
category: "required"
1010
- rule-id: "CON50-CPP"
1111
category: "required"

rule_packages/c/Banned.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@
104104
},
105105
"RULE-21-11": {
106106
"properties": {
107-
"obligation": "required"
107+
"obligation": "advisory"
108108
},
109109
"queries": [
110110
{

rule_packages/c/Contracts6.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
"MISRA-C-2012": {
2727
"RULE-17-5": {
2828
"properties": {
29-
"obligation": "advisory"
29+
"obligation": "required"
3030
},
3131
"queries": [
3232
{

rule_packages/c/Pointers1.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -244,7 +244,7 @@
244244
]
245245
}
246246
],
247-
"title": "The relational operators >, >=, < and <= shall not be applied to objects of pointer type except where they point into the same object"
247+
"title": "The relational operators >, >=, < and <= shall not be applied to expressions of pointer type except where they point into the same object"
248248
},
249249
"RULE-18-4": {
250250
"properties": {

rule_packages/c/SideEffects1.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,7 @@
166166
},
167167
"RULE-13-6": {
168168
"properties": {
169-
"obligation": "mandatory"
169+
"obligation": "required"
170170
},
171171
"queries": [
172172
{

rules.csv

+3-3
Original file line numberDiff line numberDiff line change
@@ -708,7 +708,7 @@ c,MISRA-C-2012,RULE-13-2,Yes,Required,,,The value of an expression and its persi
708708
c,MISRA-C-2012,RULE-13-3,Yes,Advisory,,,A full expression containing an increment (++) or decrement (--) operator should have no other potential side effects other than that caused by the increment or decrement operator,,SideEffects2,Medium,
709709
c,MISRA-C-2012,RULE-13-4,Yes,Advisory,,,The result of an assignment operator should not be used,M6-2-1,SideEffects1,Easy,
710710
c,MISRA-C-2012,RULE-13-5,Yes,Required,,,The right hand operand of a logical && or || operator shall not contain persistent side effects,M5-14-1,SideEffects1,Import,
711-
c,MISRA-C-2012,RULE-13-6,Yes,Mandatory,,,The operand of the sizeof operator shall not contain any expressiosn which has potential side effects,M5-3-4,SideEffects1,Import,
711+
c,MISRA-C-2012,RULE-13-6,Yes,Required,,,The operand of the sizeof operator shall not contain any expressiosn which has potential side effects,M5-3-4,SideEffects1,Import,
712712
c,MISRA-C-2012,RULE-14-1,Yes,Required,,,A loop counter shall not have essentially floating type,FLP30-C A6-5-2,EssentialTypes,Hard,
713713
c,MISRA-C-2012,RULE-14-2,Yes,Required,,,A for loop shall be well-formed,M6-5-1...M6-5-6,Statements4,Medium,
714714
c,MISRA-C-2012,RULE-14-3,Yes,Required,,,Controlling expressions shall not be invariant,,Statements5,Medium,
@@ -731,7 +731,7 @@ c,MISRA-C-2012,RULE-17-1,Yes,Required,,,The features of <stdarg.h> shall not be
731731
c,MISRA-C-2012,RULE-17-2,Yes,Required,,,"Functions shall not call themselves, either directly or indirectly",A7-5-2,Statements3,Import,
732732
c,MISRA-C-2012,RULE-17-3,Yes,Mandatory,,,A function shall not be declared implicitly,,Declarations6,Medium,
733733
c,MISRA-C-2012,RULE-17-4,Yes,Mandatory,,,All exit paths from a function with non-void return type shall have an explicit return statement with an expression,MSC52-CPP,Statements5,Medium,
734-
c,MISRA-C-2012,RULE-17-5,Yes,Advisory,,,The function argument corresponding to a parameter declared to have an array type shall have an appropriate number of elements,,Contracts6,Hard,
734+
c,MISRA-C-2012,RULE-17-5,Yes,Required,,,The function argument corresponding to a parameter declared to have an array type shall have an appropriate number of elements,,Contracts6,Hard,
735735
c,MISRA-C-2012,RULE-17-6,Yes,Mandatory,,,The declaration of an array parameter shall not contain the static keyword between the [ ],,Static,Easy,
736736
c,MISRA-C-2012,RULE-17-7,Yes,Required,,,The value returned by a function having non-void return type shall be used,A0-1-2,Contracts6,Easy,
737737
c,MISRA-C-2012,RULE-17-8,Yes,Advisory,,,A function parameter should not be modified,,SideEffects2,Medium,
@@ -776,7 +776,7 @@ c,MISRA-C-2012,RULE-21-7,Yes,Required,,,"The Standard Library functions atof, at
776776
c,MISRA-C-2012,RULE-21-8,Yes,Required,,,The Standard Library termination functions of <stdlib.h> shall not be used,ERR50-CPP,Banned,Easy,
777777
c,MISRA-C-2012,RULE-21-9,Yes,Required,,,The Standard Library functions bsearch and qsort of <stdlib.h> shall not be used,,Banned,Easy,
778778
c,MISRA-C-2012,RULE-21-10,Yes,Required,,,The Standard Library time and date functions shall not be used,,Banned,Easy,
779-
c,MISRA-C-2012,RULE-21-11,Yes,Required,,,The standard header file <tgmath.h> shall not be used,,Banned,Easy,
779+
c,MISRA-C-2012,RULE-21-11,Yes,Advisory,,,The standard header file <tgmath.h> shall not be used,,Banned,Easy,
780780
c,MISRA-C-2012,RULE-21-12,Yes,Advisory,,,The exception handling features of <fenv.h> should not be used,,Banned,Easy,
781781
c,MISRA-C-2012,RULE-21-13,Yes,Mandatory,,,Any value passed to a function in <ctype.h> shall be representable as an unsigned char or be the value EOF,,StandardLibraryFunctionTypes,Medium,
782782
c,MISRA-C-2012,RULE-21-14,Yes,Required,,,The Standard Library function memcmp shall not be used to compare null terminated strings,,EssentialTypes,Hard,

scripts/reports/test-data/deviations/invalid/coding-standards.yml

+2-2
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,8 @@ deviations:
4444
permit-id: non-existing-permit
4545
- permit-id: DP1
4646
- permit-id: DP2
47-
- rule-id: RULE-13-6
48-
query-id: c/misra/sizeof-operand-with-side-effect
47+
- rule-id: RULE-9-1
48+
query-id: c/misra/object-with-auto-storage-duration-read-before-init
4949
deviation-permits:
5050
- permit-id: DP1
5151
justification: foo bar baz

scripts/reports/test-data/guideline-recategorizations/guideline_recategorizations_report.md.expected

+2-2
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
| A0-1-1 | required | advisory |
1414
| A0-1-1 | required | mandatory |
1515
| A0-1-2 | required | disapplied |
16-
| RULE-13-6 | mandatory | required |
16+
| RULE-9-1 | mandatory | required |
1717
| CON50-CPP | rule | required |
1818
| A0-1-6 | advisory | disapplied |
1919
| A10-4-1 | advisory | required |
@@ -25,5 +25,5 @@
2525
| invalid/coding-standards.xml:5:7:8:43 | 'Invalid recategorization from 'required' to 'advisory'.' for rule A0-1-1. |
2626
| invalid/coding-standards.xml:9:7:12:43 | 'Invalid recategorization from 'required' to 'disapplied'.' for rule A0-1-2. |
2727
| invalid/coding-standards.xml:13:7:16:43 | 'Unknown rule id 'A1-4-3'.' for rule A1-4-3. |
28-
| invalid/coding-standards.xml:17:7:20:43 | 'Invalid recategorization from 'mandatory' to 'required'.' for rule RULE-13-6. |
28+
| invalid/coding-standards.xml:17:7:20:43 | 'Invalid recategorization from 'mandatory' to 'required'.' for rule RULE-9-1. |
2929
| invalid/coding-standards.xml:21:7:24:43 | 'Invalid recategorization from 'rule' to 'required'.' for rule CON50-CPP. |

scripts/reports/test-data/guideline-recategorizations/invalid/coding-standards.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ guideline-recategorizations:
55
category: "disapplied"
66
- rule-id: "A1-4-3"
77
category: "mandatory"
8-
- rule-id: "RULE-13-6"
8+
- rule-id: "RULE-9-1"
99
category: "required"
1010
- rule-id: "CON50-CPP"
1111
category: "required"

0 commit comments

Comments
 (0)