Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement MISRA-C clarifications from amendments3, 4, at TC2. #820

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
53 changes: 27 additions & 26 deletions amendments.csv
Original file line number Diff line number Diff line change
Expand Up @@ -9,41 +9,42 @@ c,MISRA-C-2012,Amendment3,RULE-10-4,Yes,Refine,No,Import
c,MISRA-C-2012,Amendment3,RULE-10-5,Yes,Expand,No,Easy
c,MISRA-C-2012,Amendment3,RULE-10-7,Yes,Refine,No,Import
c,MISRA-C-2012,Amendment3,RULE-10-8,Yes,Refine,No,Import
c,MISRA-C-2012,Amendment3,RULE-21-11,Yes,Clarification,No,Import
c,MISRA-C-2012,Amendment3,RULE-21-11,Yes,Clarification,Yes,Import
c,MISRA-C-2012,Amendment3,RULE-21-12,Yes,Replace,No,Easy
c,MISRA-C-2012,Amendment4,RULE-11-3,Yes,Expand,No,Easy
c,MISRA-C-2012,Amendment4,RULE-11-8,Yes,Expand,No,Easy
c,MISRA-C-2012,Amendment4,RULE-13-2,Yes,Expand,No,Very Hard
c,MISRA-C-2012,Amendment4,RULE-18-6,Yes,Expand,No,Medium
c,MISRA-C-2012,Amendment4,RULE-18-8,Yes,Split,Yes,Easy
c,MISRA-C-2012,Corrigendum2,RULE-2-2,Yes,Clarification,No,Import
c,MISRA-C-2012,Corrigendum2,RULE-2-7,Yes,Clarification,No,Import
c,MISRA-C-2012,Corrigendum2,RULE-3-1,Yes,Refine,No,Easy
c,MISRA-C-2012,Corrigendum2,RULE-8-6,Yes,Clarification,No,Import
c,MISRA-C-2012,Corrigendum2,RULE-8-9,Yes,Clarification,No,Import
c,MISRA-C-2012,Corrigendum2,RULE-9-4,Yes,Clarification,No,Import
c,MISRA-C-2012,Corrigendum2,RULE-10-1,Yes,Clarification,No,Import
c,MISRA-C-2012,Corrigendum2,RULE-18-3,Yes,Clarification,No,Import
c,MISRA-C-2012,Corrigendum2,RULE-1-4,Yes,Replace,No,Easy
c,MISRA-C-2012,Corrigendum2,RULE-9-1,Yes,Refine,No,Easy
c,MISRA-C-2012,Corrigendum2,RULE-9-2,Yes,Refine,No,Import
c,MISRA-C-2012,Corrigendum2,DIR-4-10,Yes,Clarification,No,Import
c,MISRA-C-2012,Amendment4,RULE-2-2,Yes,Clarification,Yes,Import
c,MISRA-C-2012,Amendment4,RULE-2-7,Yes,Clarification,Yes,Import
c,MISRA-C-2012,Amendment4,RULE-3-1,Yes,Refine,No,Easy
c,MISRA-C-2012,Amendment4,RULE-8-6,Yes,Clarification,Yes,Import
c,MISRA-C-2012,Amendment4,RULE-8-9,Yes,Clarification,Yes,Import
c,MISRA-C-2012,Amendment4,RULE-9-4,Yes,Clarification,Yes,Import
c,MISRA-C-2012,Amendment4,RULE-10-1,Yes,Clarification,Yes,Import
c,MISRA-C-2012,Amendment4,RULE-18-3,Yes,Clarification,Yes,Import
c,MISRA-C-2012,Amendment4,RULE-1-4,Yes,Replace,No,Easy
c,MISRA-C-2012,Amendment4,RULE-9-1,Yes,Refine,No,Easy
c,MISRA-C-2012,Amendment4,RULE-9-2,Yes,Refine,No,Import
c,MISRA-C-2012,Corrigendum2,DIR-4-10,Yes,Clarification,Yes,Import
c,MISRA-C-2012,Corrigendum2,RULE-7-4,Yes,Refine,No,Easy
c,MISRA-C-2012,Corrigendum2,RULE-8-2,Yes,Clarification,No,Import
c,MISRA-C-2012,Corrigendum2,RULE-8-2,Yes,Clarification,Yes,Import
c,MISRA-C-2012,Corrigendum2,RULE-8-3,Yes,Refine,No,Easy
c,MISRA-C-2012,Corrigendum2,RULE-8-7,Yes,Clarification,No,Import
c,MISRA-C-2012,Corrigendum2,RULE-8-7,Yes,Clarification,Yes,Import
c,MISRA-C-2012,Corrigendum2,RULE-10-1,Yes,Clarification,Yes,Import
c,MISRA-C-2012,Corrigendum2,RULE-10-2,Yes,Refine,No,Easy
c,MISRA-C-2012,Corrigendum2,RULE-10-3,Yes,Clarification,No,Import
c,MISRA-C-2012,Corrigendum2,RULE-11-3,Yes,Clarification,No,Import
c,MISRA-C-2012,Corrigendum2,RULE-11-6,Yes,Clarification,No,Import
c,MISRA-C-2012,Corrigendum2,RULE-13-2,Yes,Clarification,No,Import
c,MISRA-C-2012,Corrigendum2,RULE-13-6,Yes,Clarification,No,Import
c,MISRA-C-2012,Corrigendum2,RULE-10-3,Yes,Clarification,Yes,Import
c,MISRA-C-2012,Corrigendum2,RULE-11-3,Yes,Clarification,Yes,Import
c,MISRA-C-2012,Corrigendum2,RULE-11-6,Yes,Clarification,Yes,Import
c,MISRA-C-2012,Corrigendum2,RULE-13-2,Yes,Clarification,Yes,Import
c,MISRA-C-2012,Corrigendum2,RULE-13-6,Yes,Clarification,Yes,Import
c,MISRA-C-2012,Corrigendum2,RULE-14-3,Yes,Refine,No,Easy
c,MISRA-C-2012,Corrigendum2,RULE-15-7,Yes,Clarification,No,Import
c,MISRA-C-2012,Corrigendum2,RULE-17-4,Yes,Clarification,No,Import
c,MISRA-C-2012,Corrigendum2,RULE-17-5,Yes,Clarification,No,Import
c,MISRA-C-2012,Corrigendum2,RULE-15-7,Yes,Clarification,Yes,Import
c,MISRA-C-2012,Corrigendum2,RULE-17-4,Yes,Clarification,Yes,Import
c,MISRA-C-2012,Corrigendum2,RULE-17-5,Yes,Clarification,Yes,Import
c,MISRA-C-2012,Corrigendum2,RULE-18-1,Yes,Refine,No,Easy
c,MISRA-C-2012,Corrigendum2,RULE-20-14,No,Clarification,No,Import
c,MISRA-C-2012,Corrigendum2,RULE-21-19,Yes,Clarification,No,Import
c,MISRA-C-2012,Corrigendum2,RULE-20-14,No,Clarification,Yes,Import
c,MISRA-C-2012,Corrigendum2,RULE-21-19,Yes,Clarification,Yes,Import
c,MISRA-C-2012,Corrigendum2,RULE-21-20,Yes,Refine,No,Easy
c,MISRA-C-2012,Corrigendum2,RULE-22-9,Yes,Clarification,No,Import
c,MISRA-C-2012,Corrigendum2,RULE-22-9,Yes,Clarification,Yes,Import
2 changes: 1 addition & 1 deletion c/misra/src/rules/RULE-13-6/SizeofOperandWithSideEffect.ql
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
* @tags external/misra/id/rule-13-6
* correctness
* external/misra/c/2012/third-edition-first-revision
* external/misra/obligation/mandatory
* external/misra/obligation/required
*/

import cpp
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
* @tags external/misra/id/rule-17-5
* correctness
* external/misra/c/2012/third-edition-first-revision
* external/misra/obligation/advisory
* external/misra/obligation/required
*/

import cpp
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
* @tags external/misra/id/rule-21-11
* correctness
* external/misra/c/2012/third-edition-first-revision
* external/misra/obligation/required
* external/misra/obligation/advisory
*/

import cpp
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
- `RULE-13-6` - `SizeofOperandWithSideEffect.ql`:
- Changed from Mandatory to Required in implementation of Technical Corrigenda 2.
- `RULE-17-5` - `ArrayFunctionArgumentNumberOfElements.ql`:
- Changed from Advisory to Required in implementation of Technical Corrigenda 2.
- `RULE-21-11` - `StandardHeaderFileTgmathhUsed.ql`:
- Changed from Required to Advisory in implementation of Amendment 3.
2 changes: 1 addition & 1 deletion cpp/common/src/codingstandards/cpp/exclusions/c/Banned.qll
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ predicate isBannedQueryMetadata(Query query, string queryId, string ruleId, stri
// `@id` for the `standardHeaderFileTgmathhUsed` query
"c/misra/standard-header-file-tgmathh-used" and
ruleId = "RULE-21-11" and
category = "required"
category = "advisory"
or
query =
// `Query` instance for the `exceptionHandlingFeaturesOfFenvhUsed` query
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ predicate isContracts6QueryMetadata(Query query, string queryId, string ruleId,
// `@id` for the `arrayFunctionArgumentNumberOfElements` query
"c/misra/array-function-argument-number-of-elements" and
ruleId = "RULE-17-5" and
category = "advisory"
category = "required"
or
query =
// `Query` instance for the `valueReturnedByAFunctionNotUsed` query
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ predicate isSideEffects1QueryMetadata(Query query, string queryId, string ruleId
// `@id` for the `sizeofOperandWithSideEffect` query
"c/misra/sizeof-operand-with-side-effect" and
ruleId = "RULE-13-6" and
category = "mandatory"
category = "required"
}

module SideEffects1Package {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,8 +83,8 @@
<permit-id>DP2</permit-id>
</deviations-entry>
<deviations-entry>
<rule-id>RULE-13-6</rule-id>
<query-id>c/misra/sizeof-operand-with-side-effect</query-id>
<rule-id>RULE-9-1</rule-id>
<query-id>c/misra/object-with-auto-storage-duration-read-before-init</query-id>
</deviations-entry>
</deviations>
<deviation-permits>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,8 @@ deviations:
permit-id: non-existing-permit
- permit-id: DP1
- permit-id: DP2
- rule-id: RULE-13-6
query-id: c/misra/sizeof-operand-with-side-effect
- rule-id: RULE-9-1
query-id: c/misra/object-with-auto-storage-duration-read-before-init
deviation-permits:
- permit-id: DP1
justification: foo bar baz
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
| 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. |
| 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. |
| 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. |
| 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. |
| 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. |
| 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. |
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@
| A10-4-1 | advisory | required |
| A11-0-1 | advisory | mandatory |
| CON50-CPP | rule | required |
| RULE-13-6 | mandatory | required |
| RULE-9-1 | mandatory | required |
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
<category>mandatory</category>
</guideline-recategorizations-entry>
<guideline-recategorizations-entry>
<rule-id>RULE-13-6</rule-id>
<rule-id>RULE-9-1</rule-id>
<category>required</category>
</guideline-recategorizations-entry>
<guideline-recategorizations-entry>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ guideline-recategorizations:
category: "disapplied"
- rule-id: "A1-4-3"
category: "mandatory"
- rule-id: "RULE-13-6"
- rule-id: "RULE-9-1"
category: "required"
- rule-id: "CON50-CPP"
category: "required"
2 changes: 1 addition & 1 deletion rule_packages/c/Banned.json
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@
},
"RULE-21-11": {
"properties": {
"obligation": "required"
"obligation": "advisory"
},
"queries": [
{
Expand Down
2 changes: 1 addition & 1 deletion rule_packages/c/Contracts6.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
"MISRA-C-2012": {
"RULE-17-5": {
"properties": {
"obligation": "advisory"
"obligation": "required"
},
"queries": [
{
Expand Down
2 changes: 1 addition & 1 deletion rule_packages/c/Pointers1.json
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,7 @@
]
}
],
"title": "The relational operators >, >=, < and <= shall not be applied to objects of pointer type except where they point into the same object"
"title": "The relational operators >, >=, < and <= shall not be applied to expressions of pointer type except where they point into the same object"
},
"RULE-18-4": {
"properties": {
Expand Down
2 changes: 1 addition & 1 deletion rule_packages/c/SideEffects1.json
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@
},
"RULE-13-6": {
"properties": {
"obligation": "mandatory"
"obligation": "required"
},
"queries": [
{
Expand Down
6 changes: 3 additions & 3 deletions rules.csv
Original file line number Diff line number Diff line change
Expand Up @@ -708,7 +708,7 @@ c,MISRA-C-2012,RULE-13-2,Yes,Required,,,The value of an expression and its persi
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,
c,MISRA-C-2012,RULE-13-4,Yes,Advisory,,,The result of an assignment operator should not be used,M6-2-1,SideEffects1,Easy,
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,
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,
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,
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,
c,MISRA-C-2012,RULE-14-2,Yes,Required,,,A for loop shall be well-formed,M6-5-1...M6-5-6,Statements4,Medium,
c,MISRA-C-2012,RULE-14-3,Yes,Required,,,Controlling expressions shall not be invariant,,Statements5,Medium,
Expand All @@ -731,7 +731,7 @@ c,MISRA-C-2012,RULE-17-1,Yes,Required,,,The features of <stdarg.h> shall not be
c,MISRA-C-2012,RULE-17-2,Yes,Required,,,"Functions shall not call themselves, either directly or indirectly",A7-5-2,Statements3,Import,
c,MISRA-C-2012,RULE-17-3,Yes,Mandatory,,,A function shall not be declared implicitly,,Declarations6,Medium,
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,
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,
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,
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,
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,
c,MISRA-C-2012,RULE-17-8,Yes,Advisory,,,A function parameter should not be modified,,SideEffects2,Medium,
Expand Down Expand Up @@ -776,7 +776,7 @@ c,MISRA-C-2012,RULE-21-7,Yes,Required,,,"The Standard Library functions atof, at
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,
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,
c,MISRA-C-2012,RULE-21-10,Yes,Required,,,The Standard Library time and date functions shall not be used,,Banned,Easy,
c,MISRA-C-2012,RULE-21-11,Yes,Required,,,The standard header file <tgmath.h> shall not be used,,Banned,Easy,
c,MISRA-C-2012,RULE-21-11,Yes,Advisory,,,The standard header file <tgmath.h> shall not be used,,Banned,Easy,
c,MISRA-C-2012,RULE-21-12,Yes,Advisory,,,The exception handling features of <fenv.h> should not be used,,Banned,Easy,
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,
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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,8 @@ deviations:
permit-id: non-existing-permit
- permit-id: DP1
- permit-id: DP2
- rule-id: RULE-13-6
query-id: c/misra/sizeof-operand-with-side-effect
- rule-id: RULE-9-1
query-id: c/misra/object-with-auto-storage-duration-read-before-init
deviation-permits:
- permit-id: DP1
justification: foo bar baz
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
| A0-1-1 | required | advisory |
| A0-1-1 | required | mandatory |
| A0-1-2 | required | disapplied |
| RULE-13-6 | mandatory | required |
| RULE-9-1 | mandatory | required |
| CON50-CPP | rule | required |
| A0-1-6 | advisory | disapplied |
| A10-4-1 | advisory | required |
Expand All @@ -25,5 +25,5 @@
| invalid/coding-standards.xml:5:7:8:43 | 'Invalid recategorization from 'required' to 'advisory'.' for rule A0-1-1. |
| invalid/coding-standards.xml:9:7:12:43 | 'Invalid recategorization from 'required' to 'disapplied'.' for rule A0-1-2. |
| invalid/coding-standards.xml:13:7:16:43 | 'Unknown rule id 'A1-4-3'.' for rule A1-4-3. |
| invalid/coding-standards.xml:17:7:20:43 | 'Invalid recategorization from 'mandatory' to 'required'.' for rule RULE-13-6. |
| invalid/coding-standards.xml:17:7:20:43 | 'Invalid recategorization from 'mandatory' to 'required'.' for rule RULE-9-1. |
| invalid/coding-standards.xml:21:7:24:43 | 'Invalid recategorization from 'rule' to 'required'.' for rule CON50-CPP. |
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ guideline-recategorizations:
category: "disapplied"
- rule-id: "A1-4-3"
category: "mandatory"
- rule-id: "RULE-13-6"
- rule-id: "RULE-9-1"
category: "required"
- rule-id: "CON50-CPP"
category: "required"
Loading